Skip to content

fix(verify): require canonical base64url for receipt signature, cnf.jwk.x and bundle_signature - #866

Closed
harshnair75567-cloud wants to merge 1 commit into
agentrust-io:mainfrom
harshnair75567-cloud:fix/audit-bundle-canonical-b64url
Closed

harshnair75567-cloud wants to merge 1 commit into
agentrust-io:mainfrom
harshnair75567-cloud:fix/audit-bundle-canonical-b64url

Conversation

@harshnair75567-cloud

Copy link
Copy Markdown

Summary

#808 (closing #804) added _canonical_b64url_decode and applied it to the claim path only. Three decodes in verify_audit_bundle still used the lenient base64.urlsafe_b64decode: the external-execution receipt signature, the claim's cnf.jwk.x, and bundle_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. A vs B) and characters outside the alphabet (!!!!, newlines). Before this change, verify_audit_bundle returned verified=True for a bundle whose bundle_signature was 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 inside except Exception, so a non-canonical value is reported as a verification failure, not a crash. No except clause changed.

Tests

tests/unit/test_audit_bundle_canonical_b64url.py: a valid control, a same-byte alias and junk characters (!!!!, newlines) for bundle_signature.

Before the fix (3 failed, 1 passed):

FAILED test_same_byte_alias_of_bundle_signature_is_rejected - verified=True
FAILED test_bundle_signature_with_ignored_characters_is_rejected[!!!!]
FAILED test_bundle_signature_with_ignored_characters_is_rejected[\n\n\n\n]

After the fix: 4 passed.

Dedicated alias tests for cnf.jwk.x and 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)

…wk.x and bundle_signature

Signed-off-by: harshnair75567-cloud <harshnair75567@gmail.com>
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

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 /vouch. After that, reopen this pull request or open a new one.

See CONTRIBUTING.md for the detail.

@github-actions github-actions Bot closed this Dec 2, 2026
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants