Harden outer COSE_Sign1 decode with the same CBOR limits as the payload#12
Open
prasanna-anchorage wants to merge 2 commits into
Open
Harden outer COSE_Sign1 decode with the same CBOR limits as the payload#12prasanna-anchorage wants to merge 2 commits into
prasanna-anchorage wants to merge 2 commits into
Conversation
verifier.go decoded the outer COSE_Sign1 envelope with a bare cbor.Unmarshal, relying on fxamacker/cbor's much looser defaults (131,072 max array elements/map pairs) even though parser.go already applied tighter limits (32 nested levels, 128 max array elements/map pairs) to the inner attestation document. Both now share a single hardenedDecMode so no decode entry point is left on the looser defaults.
There was a problem hiding this comment.
Pull request overview
This PR hardens decoding of attacker-controlled CBOR by applying the same strict fxamacker/cbor resource limits to the outer COSE_Sign1 envelope as already used for the inner attestation document payload, preventing the outer wrapper from relying on permissive library defaults.
Changes:
- Replaced outer COSE_Sign1
cbor.Unmarshalcalls inverifier.gowith the sharedhardenedDecMode.Unmarshal. - Centralized CBOR decode limits into a single
hardenedDecModeinparser.goand reused it for inner document decoding. - Added a regression test ensuring oversized outer-envelope structures are rejected early.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| verifier.go | Uses the shared hardened CBOR decode mode when parsing the outer COSE_Sign1 envelope. |
| verifier_test.go | Adds a test that validates the outer COSE decode now enforces the hardened CBOR limits. |
| parser.go | Introduces a shared hardened CBOR DecMode and reuses it for inner document decoding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Reword the DecMode panic comment: it fires at package init (runtime), not build time. - Fix "un-configured" -> "unconfigured" hyphenation in the new test's comments.
prasanna-anchorage
enabled auto-merge
July 15, 2026 21:01
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
verifier.godecoded the outer COSE_Sign1 envelope with a barecbor.Unmarshal, relying on fxamacker/cbor's much looser defaults (131,072 max array elements/map pairs) even thoughparser.goalready applied tighter limits (32 nested levels, 128 max array elements/map pairs) to the inner attestation document payload.hardenedDecModeinparser.go, so no CBOR decode entry point in the package is left relying on the un-configured defaults.TestOuterCOSEDecodeHardeninginverifier_test.go, which smuggles an oversized array into the outer envelope's unprotected-headers slot (200 elements — over our 128 limit, but well under fxamacker's 131,072 default) and confirms it's now rejected at the outer decode, with an error distinguishable from the inner-document decode path.Test plan
go build ./...go vet ./...go test ./...— 123 passed (122 existing + 1 new)