Repository navigation
fix(verify): require canonical base64url for receipt signature, cnf.jwk.x and bundle_signature - #866
Conversation
…wk.x and bundle_signature Signed-off-by: harshnair75567-cloud <harshnair75567@gmail.com>
|
Thanks for this, @harshnair75567-cloud. Closing it for now, and it is not about the change itself. This repository asks first-time contributors to be vouched by a maintainer before opening a pull request. That is because agent-written contributions are easy to produce and expensive to review, and we would rather talk to you first than review something neither of us can explain. To get vouched: open an issue saying what you want to change and why, in your own words. A maintainer will reply, and add you with See CONTRIBUTING.md for the detail. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
#808 (closing #804) added
_canonical_b64url_decodeand applied it to the claim path only. Three decodes inverify_audit_bundlestill used the lenientbase64.urlsafe_b64decode: the external-execution receipt signature, the claim'scnf.jwk.x, andbundle_signature. This PR switches all three to the strict helper and removes the manual padding.Why
The lenient decoder accepts non-canonical encodings of the same bytes: a last character with non-zero unused bits (e.g.
AvsB) and characters outside the alphabet (!!!!, newlines). Before this change,verify_audit_bundlereturnedverified=Truefor a bundle whosebundle_signaturewas aliased or padded with junk.Severity
Low. This is hardening and consistency with the claim path, not an exploit. The signature must still be valid for the bytes.
Error handling
The helper raises
ValueError. All three sites are insideexcept Exception, so a non-canonical value is reported as a verification failure, not a crash. Noexceptclause changed.Tests
tests/unit/test_audit_bundle_canonical_b64url.py: a valid control, a same-byte alias and junk characters (!!!!, newlines) forbundle_signature.Before the fix (3 failed, 1 passed):
After the fix: 4 passed.
Dedicated alias tests for
cnf.jwk.xand the receipt signature are still to come, which is why this is a draft.Out of scope
Nonce decodes,
startup.py:147, and the line-58 helper (lenient by design per its docstring)