Skip to content

verify_audit_bundle accepts non-canonical base64url in three fields (hardening) #867

Backlog

Description

@harshnair75567-cloud

Context

I'm asking to be vouched because I haven't contributed to cmcp before.In trace-spec I have two merged PRs (#239, #343). I also reported #68, which was fixed internally as #70. This finding is the same kind of gap: validation that accepts input it should reject.

While auditing cmcp_verify I found that #808 made the claim path strict, but three other decodes in verify_audit_bundle still use the lenient base64.urlsafe_b64decode: the receipt signature, cnf.jwk.x and bundle_signature. That decoder ignores the unused bits at the end of the string and silently skips characters outside the alphabet, so the same signature can be written in many ways and still verify.

I reproduced this on f848668 and fixed it in one commit that switches the three sites to _canonical_b64url_decode. The tests currently cover bundle_signature only: 3 fail on the old code and all 4 pass on the new code. It's low severity, hardening only. I left the nonce decodes, startup.py:147 and the lenient helper near line 58 out of scope.

I worked on this with an AI assistant (Claude) and checked it myself by running the tests against both versions. The branch is here: https://github.com/harshnair75567-cloud/cmcp/tree/fix/audit-bundle-canonical-b64url

My earlier PR for this (#866) was auto-closed, and I'd like to reopen it once vouched.

cmcp-gateway version

f848668 (upstream main; my branch is one commit on top)

Python version

3.14.10

TEE provider

none (verifier-side, verify_audit_bundle)

Reproduction steps

  1. Build a valid signed audit chain bundle.
  2. Change only the last character of bundle_signature to a same-bytes alias, or insert !!!! or newlines.
  3. Call verify_audit_bundle.

Expected behavior

A non-canonical encoding of bundle_signature is rejected with a reported failure, as the claim path already does after #808.

Actual behavior

verify_audit_bundle returns verified=True, failures=[] for a signature with a same-bytes alias or inserted junk. cnf.jwk.x and the receipt signature use the same lenient decode, but I have only written tests for bundle_signature so far.

Relevant logs or TRACE Claim output

FAILED test_same_byte_alias_of_bundle_signature_is_rejected
FAILED test_bundle_signature_with_ignored_characters_is_rejected[!!!!]
FAILED test_bundle_signature_with_ignored_characters_is_rejected[\n\n\n\n]
3 failed, 1 passed

AuditBundleResult(verified=True, entry_count=3, failures=[])

Conformance test ID (if applicable)

n/a

Activity

  1. added
    bug
    on Dec 2, 2026
  2. dinakarjs commented on Dec 3, 2026

    @dinakarjs
    Contributor

    I checked #866 at 48d2c60. Its three decoder replacements are already author-owned, and its description reserves the missing receipt-signature and cnf.jwk.x tests. I can contribute those two test groups after the draft is reopened or the author selects the receiving branch. Proposed controls: each canonical value verifies; same-byte unused-bit aliases, inserted punctuation/newlines and padding are refused; revert only the target decoder in each trial to demonstrate that its regression fails independently. The existing bundle_signature cases should remain unchanged. No competing implementation PR is proposed.

    Prepared with OpenAI Codex.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions