Conversation
The share link hash was md5(user_id, conversation_id, refs), fully derivable from the sharer's sequential user id and conversation id with no random component, letting anyone who guesses those ids recompute a valid share hash and view another user's shared conversation without ever receiving the link. Generate a random 128-bit token instead, and reuse an existing share row for a conversation by looking it up (user_id, conversation_id) rather than relying on the hash itself being reproducible.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #416
Replaces the derived MD5 conversation-share hash (
md5(user_id, conversation_id, refs)) with a cryptographically random 128-bit token (utils.GenerateRandomHash, viacrypto/rand), since the old hash could be recomputed by anyone who knew or guessed a user's sequentialuser_idand a plausibleconversation_id, letting them view that user's shared conversation without ever receiving the link.ShareConversationnow looks up an existingsharingrow for a(user_id, conversation_id)pair viaSELECTto decide whether to reuse its hash (updatingrefs) or mint a new random one, instead of relying on the old hash being reproducible to triggerON DUPLICATE KEY UPDATE. The now-unusedSharedHashFormtype was removed.Verified
go build ./...succeeds with no regressions, and no other caller ofShareConversation/GetRefexists in the codebase.