fix(tls): bound PSK identity length before decrypt#9
Open
alanhoff wants to merge 2 commits intoendel:mainfrom
Open
fix(tls): bound PSK identity length before decrypt#9alanhoff wants to merge 2 commits intoendel:mainfrom
alanhoff wants to merge 2 commits intoendel:mainfrom
Conversation
Reject oversized TLS 1.3 PSK ticket identities before copying or decrypting them into fixed-size stack buffers, and add a regression test covering the oversized identity case. Co-authored-by: Codex <noreply@openai.com>
There was a problem hiding this comment.
Pull request overview
This PR hardens the QUIC TLS 1.3 server-side PSK resumption path by rejecting oversized PSK ticket identities before they can be copied/decrypted into fixed-size stack buffers, and adds a regression test to ensure the oversized case is handled safely.
Changes:
- Add explicit upper bounds for
identity_len/ciphertext_lenintryProcessPskbefore any@memcpyor AEAD decrypt output slicing. - Keep oversized identities on the normal PSK rejection path (early return;
using_pskremains false). - Add a unit test that feeds an oversized PSK identity directly into
tryProcessPsk.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Derive the oversized PSK identity rejection limits from the actual decrypt and ticket buffers used in tryProcessPsk so the guard stays aligned with the implementation. Co-authored-by: Codex <noreply@openai.com>
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.
Summary
@memcpy/AEAD output slicestryProcessPskVulnerability
tryProcessPskreadsidentity_lenfrom the client-controlledpre_shared_keyextension, then copies that identity into an 80-byte stack buffer and decrypts it into a 64-byte stack buffer without first proving the length fits. A malicious client can keep the extension internally well-formed while choosing an identity length that exceeds those buffers.Concrete examples:
identity_lenof81bytes stays extension-valid, but it drivesciphertext_lento65, which exceeds the 64-byte plaintext buffer96bytes would overrun both the 80-byte ticket buffer and the decrypt output sliceValidation
zig build testzig buildzig build fuzzReferences