Harden chain depth bounds and parser input validation#10209
Draft
ColtonWilley wants to merge 1 commit intowolfSSL:masterfrom
Draft
Harden chain depth bounds and parser input validation#10209ColtonWilley wants to merge 1 commit intowolfSSL:masterfrom
ColtonWilley wants to merge 1 commit intowolfSSL:masterfrom
Conversation
Enforce MAX_CHAIN_DEPTH limits in OCSP chain processing (SendCertificateStatus, ProcessChainOCSPRequest), certificate loading (ProcessUserChain), and TLS 1.3 certificate sending (SendTls13Certificate). Add idx bounds checks to chain accessors in ssl.c. Harden SNI extension parser (TLSX_SNI_GetFromBuffer) with length checks preventing buffer overreads on malformed ClientHello. Fix off-by-one in TLSX_CSR_Free where <= should be < since csr->requests is a count, not a max index. Add remaining-buffer bounds checks to PKCS7 decoders: DecodeEnvelopedData, DecodeAuthEnvelopedData (encryptedContentSz and authTagSz), DecodeEncryptedData, SignedData null signature tag, and PwriKek_KeyUnWrap cekLen validation.
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.
Early PR for review — tests still needed.
Summary
MAX_CHAIN_DEPTHlimits in OCSP chain processing (SendCertificateStatus,ProcessChainOCSPRequest), certificate loading (ProcessUserChain), and TLS 1.3 certificate sending (SendTls13Certificate). Addidxbounds checks to chain accessors inssl.c.TLSX_SNI_GetFromBuffer) with length validation preventing buffer overreads on malformed ClientHello. Require exactlistLen == extLen - OPAQUE16_LENmatch to prevent extension boundary misalignment.TLSX_CSR_Free(<=to<) —csr->requestsis a count, and a full-depth chain with leaf OCSP could push the free loop one past therequest.ocsp[]array.DecodeEnvelopedDataandDecodeAuthEnvelopedData(encryptedContentSz,authTagSz),DecodeEncryptedData(two sites),SignedDatanull signature tag, andPwriKek_KeyUnWrapcekLenoff-by-4.Test plan
WOLFSSL_TLS_OCSP_MULTIMAX_CHAIN_DEPTHaccepted;MAX_CHAIN_DEPTH + 1rejected withMAX_CHAIN_ERRORAuthEnvelopedDatareturnsBUFFER_Einstead of OOB read