Repository navigation
proto_handshake: clear the cookie before freeing it - #441
Open
woahwhattheheck wants to merge 2 commits into
Open
woahwhattheheck wants to merge 2 commits into
woahwhattheheck wants to merge 2 commits into
Conversation
woahwhattheheck
force-pushed
the
proto-handshake-clear-cookie
branch
from
September 20, 2026 02:13
a04c261 to
c7fe6da
Compare
Route every handshake-cookie release through one helper so the secret-wipe invariant is enforced at a single cleanup boundary rather than duplicated at four exit sites.
|
Following up on first-reporter bug bounty #440. This PR is the |
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 #440.
struct handshake_cookieholdsx— the diffie-hellman private value, whosebeing forgotten is what makes the PFS handshake forward-secret — and the two
diffie-hellman parameter MAC keys derived from the shared secret. All four
sites which free the cookie did so without wiping it:
handshakefail()proto_handshake()aterr1handshakedone(), which runs once per successful connection, at exactly thepoint where
xhas served its purposeproto_handshake_cancel()Four
insecure_memzero()calls and the include; no other change.Why all four rather than only where
xis populatederr1is reached before the diffie-hellman value is ever generated, sostrictly it has nothing to protect. I wiped it anyway so that "the cookie is
always cleared before it is freed" is a property that holds without the reader
having to trace which paths populate what — the same reasoning as
scryptenc.c, which wipesdkaterr1on paths where it may never havebeen filled in. Happy to drop that one if you would rather keep it exact.
The nonces and
yh_*values in the cookie go over the wire in the clear, sothey are not the point here; they are simply covered by wiping the whole
structure, which is cheaper and less fragile than picking members.