Fix RSA PKCS#1 v1.5 forgery via nested DigestAlgorithm garbage - #1152
Open
Krysthyan wants to merge 1 commit into
Open
Fix RSA PKCS#1 v1.5 forgery via nested DigestAlgorithm garbage#1152Krysthyan wants to merge 1 commit into
Krysthyan wants to merge 1 commit into
Conversation
Require DigestAlgorithm SEQUENCE element count (OID + optional NULL) so asn1.validate cannot ignore interior padding that bypasses CVE-2026-33894. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Hi @Krysthyan I can get behind this solution instead of the one I've made, since it's simpler and does not introduce the potential overhead of adding captureAsn1 to check the same thing. Have you run the rest of the suites just in case they also pass? @davidlehn can you check this? The CVE is blocking several pipelines as much as I can see in the mentions of #1149 I will close my PR in favor of this one. |
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
obj.value.length === 2on the outerDigestInfoSEQUENCE.asn1.validatestill ignores extra children inside the nestedDigestAlgorithmSEQUENCE, so attackers can stuff ~314 garbage bytes there and forge signatures for low public exponent keys (e.g.e=3).DigestAlgorithmSEQUENCE to contain only the OID plus an optional NULL (same pattern as the outer length check).Test plan
DigestAlgorithmchildren[OID, NULL, garbage]verified astruebefore the change; throws invalid DigestInfo after.should check nested DigestAlgorithm element countintests/unit/rsa.js.npx mocha tests/unit/rsa.js— 101 passing, 4 pending.Related: #1151 (same issue; this PR uses
obj.value[0].value.lengthinstead of addingcaptureAsn1).