Conversation
…res, hyphens parse_www_authenticate rejected any method identifier containing a character other than an ASCII lowercase letter (method_raw.chars().all(|c| c.is_ascii_lowercase())), so canonical identifiers like "x402" or "tempo-v2" were rejected outright -- before challenge selection or payment could even occur. Canonical mppx (Challenge.ts's deserialize validator) accepts the method-name ABNF ^[a-z][a-z0-9:_-]*$: a lowercase letter, followed by any number of lowercase letters, digits, colons, underscores, or hyphens. Add is_valid_method_name implementing that exact grammar and use it in place of the letters-only check. The digit-prefix and non-letter-first rejections (an identifier can't start with anything but a lowercase letter) are unchanged -- only the previously-blanket "every character must be a-z" requirement is relaxed to the full canonical charset for characters after the first. Found a pre-existing test, test_parse_www_authenticate_rejects_invalid_method_name_dash, that explicitly asserted the *bug*: "tempo-v2" should be rejected. Per the ABNF above hyphens are valid after the first character, so this assertion was backwards. Replaced it with test_parse_www_authenticate_accepts_hyphen_in_method_name (same input, corrected expectation) and added test_parse_www_authenticate_accepts_extension_characters_in_method_name covering colons, underscores, digits, and "x402" specifically (the identifier named in the issue this fixes). The other three existing method-name tests (digit-prefix, non-letter/invalid-char, mixed-case) were already asserting correct behavior per the ABNF and are unchanged. I could not run the test suite in my sandbox: `cargo test` always builds dev-dependencies (alloy-json-rpc, axum, tower, ...) regardless of --no-default-features, and one of their transitive dependencies (rand_pcg 0.10.2, via a fresh dependency resolution after deleting Cargo.lock) requires Cargo >= 1.85 (edition2024) which I don't have available. I reviewed the change carefully by hand and traced every call site of is_valid_method_name (there's exactly one). Please run `cargo test -p mpp headers::tests` before merging. Fixes tempoxyz/mpp-tools#218 (AGR-2026-092)
ygd58
requested review from
brendanjryan,
mattsse and
onbjerg
as code owners
September 10, 2026 03:46
This was referenced Sep 21, 2026
Collaborator
|
Superseded by #428, which retains this method-grammar fix, adds serde parity and broader tests, and is covered by tempoxyz/mpp-tools#240. Thank you for identifying this. |
Author
|
Thanks for the broader fix — closing this in favor of #428. |
brendanjryan
added a commit
to tempoxyz/mpp-tools
that referenced
this pull request
Sep 21, 2026
## Motivation Challenge-header behavior has drifted across SDKs because Unicode escape and extension-method cases were absent from the shared vectors. ## Summary - add BMP, astral, realm, literal escape, truncated escape, and raw Latin-1 scenarios - add the canonical extended method identifier scenario - exercise parse, format, and round-trip behavior where applicable ## Key design considerations - mppx wire behavior remains the golden reference - SDK updates: [mpp-rs #428](tempoxyz/mpp-rs#428), [mpp-go #168](tempoxyz/mpp-go#168), and [pympp #256](tempoxyz/pympp#256) - original reports: [mpp-rs #414](tempoxyz/mpp-rs#414), [mpp-rs #418](tempoxyz/mpp-rs#418), [mpp-go #154](tempoxyz/mpp-go#154), and [pympp #247](tempoxyz/pympp#247) - keep this draft until the pinned SDK revisions contain the corresponding fixes --------- Co-authored-by: Kanan <93033289+kriss39@users.noreply.github.com>
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.
What
parse_www_authenticaterejected any method identifier containing a character other than an ASCII lowercase letter (method_raw.chars().all(|c| c.is_ascii_lowercase())), so canonical identifiers likex402ortempo-v2were rejected outright — before challenge selection or payment could even occur. Canonical mppx (Challenge.ts's deserialize validator) accepts the method-name ABNF^[a-z][a-z0-9:_-]*$: a lowercase letter, followed by any number of lowercase letters, digits, colons, underscores, or hyphens.Flagged by the cross-SDK audit as AGR-2026-092 — high severity.
Fix
Add
is_valid_method_nameimplementing that exact grammar and use it in place of the letters-only check. The digit-prefix and non-letter-first rejections (an identifier can't start with anything but a lowercase letter) are unchanged — only the previously-blanket "every character must be a-z" requirement is relaxed to the full canonical charset for characters after the first.A pre-existing test asserted the bug
test_parse_www_authenticate_rejects_invalid_method_name_dashexplicitly asserted that"tempo-v2"should be rejected. Per the ABNF above, hyphens are valid after the first character, so this assertion was backwards. Replaced it withtest_parse_www_authenticate_accepts_hyphen_in_method_name(same input, corrected expectation) and addedtest_parse_www_authenticate_accepts_extension_characters_in_method_namecovering colons, underscores, digits, andx402specifically (the identifier named in the issue this fixes). The other three existing method-name tests (digit-prefix, non-letter/invalid-char, mixed-case) were already asserting correct behavior per the ABNF and are unchanged.Testing
I could not run the test suite in my sandbox:
cargo testalways builds dev-dependencies (alloy-json-rpc,axum,tower, ...) regardless of--no-default-features, and one of their transitive dependencies (rand_pcg 0.10.2, confirmed even after deletingCargo.lockand letting it re-resolve) requires Cargo >= 1.85 (edition2024), which I don't have available. I reviewed the change carefully by hand and traced every call site ofis_valid_method_name(there's exactly one). Please runcargo test -p mpp headers::testsbefore merging, happy to fix anything that doesn't match.Fixes tempoxyz/mpp-tools#218