Skip to content

Do not XOR cookie plaintext in place - #94

Open
AshSgDe29071999 wants to merge 1 commit into
gorilla:mainfrom
AshSgDe29071999:fix/encrypt-copy-before-xor
Open

Do not XOR cookie plaintext in place#94
AshSgDe29071999 wants to merge 1 commit into
gorilla:mainfrom
AshSgDe29071999:fix/encrypt-copy-before-xor

Conversation

@AshSgDe29071999

Copy link
Copy Markdown

encrypt and decrypt passed the caller's buffer to cipher.Stream.XORKeyStream as both dst and src, so Encode mutated the original plaintext slice. Callers that reuse that buffer (or that share it with csrf cookie construction) then observed ciphertext in place of the input.

Copy into a new buffer before XOR. Decrypt similarly returns a distinct plaintext slice instead of aliasing the ciphertext.

Reported via gorilla/csrf#201.

encrypt and decrypt passed the caller's buffer to XORKeyStream as both
dst and src, which overwrote the original slice. Copy first so Encode
does not mutate caller-owned plaintext.

See gorilla/csrf#201
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant