only update UnorderedCrypter replay state after decryption succeeds - #5155
Closed
uwezkhan wants to merge 1 commit into
Closed
only update UnorderedCrypter replay state after decryption succeeds#5155uwezkhan wants to merge 1 commit into
uwezkhan wants to merge 1 commit into
Conversation
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.
UnorderedCrypter::decryptrecords the nonce inbuffered_read_noncesand advancesfurthest_read_noncebeforeaes_gcm_256_decryptruns. The nonce travels beside the ciphertext and is not covered by the AEAD tag (UnorderedChannelEncryptor::decryptreads it straight offPayload::nonce), so on the unreliable transports this crypter targets, whoever can put a packet on the wire picks it. Before: a forged packet reusing a nonce the sender has not sent yet makes the genuine message carrying that nonce fail withReplayedNonce, and one packet with a far-ahead nonce ratchets the window past everything still in flight.After: the window moves only once the tag verifies, so a forged packet costs one failed decryption and nothing more, which is what RFC 4303 3.4.3 and RFC 6347 4.1.2.6 require of an anti-replay window. The check belongs in the crypter because that is the only layer holding the window state and the first point where the nonce is trustworthy. Tradeoff: the replayed-nonce lookup now runs against the whole buffered set rather than only the span at or below
furthest_read_nonce, costing one extra hash lookup for nonces above the window; accepted traffic, out-of-order tolerance and window sizing are unchanged.