Skip to content

feat(identity): support TAP ECDSA signatures and enforce RFC 9421 rules - #1363

Open
brendanjryan wants to merge 5 commits into
mainfrom
feat/tap-ecdsa-strict
Open

brendanjryan wants to merge 5 commits into
mainfrom
feat/tap-ecdsa-strict

Conversation

@brendanjryan

@brendanjryan brendanjryan commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1358.

Brings TAP signature algorithms and replay protection in line with RFC 9421 and the TAP merchant specification.

ECDSA (@hathbanger's commit from the issue)

  • Adds ecdsa-p256-sha256 and ecdsa-p384-sha384 (RFC 9421 §3.3.4–3.3.5) for local key pairs and remote signers, with raw fixed-width r || s signatures (64 and 96 bytes).
  • A key must match the signature's alg: key type, curve and hash.
  • Web Bot Auth and attestation signing keep their existing algorithms.

RFC 9421 checks

  • A signature that covers the same component twice, or covers @signature-params, is malformed (§2.5). Signing refuses such a list before calling a remote signer.
  • verify takes the algorithms a profile accepts. Web Bot Auth passes ed25519 and rsa-pss-sha512, so it rejects ECDSA before resolving a key; before this, ECDSA keys were rejected only because they have no JWK thumbprint.

TAP nonces

  • The TAP spec blocks any nonce seen within the 8-minute signature lifetime. TAP verification now claims nonces across every key (tap:<nonce>), not per key ID. Web Bot Auth keeps per-key nonces.
  • TAP also still claims the per-key entry (tap:<keyId>:<nonce>), so during a rolling deploy this release and the previous one each refuse a nonce the other accepted.

Vectors

  • test/fixtures/identity/tap.json holds one known-answer vector per algorithm (ed25519, ecdsa-p256-sha256, ecdsa-p384-sha384, rsa-pss-sha512). They use the RFC 9421 Appendix B test keys, plus a P-384 test key made for these vectors. Signatures are made with node:crypto, so mppx is checked against an independent implementation.
  • Tap.vectors.test.ts checks that each vector verifies, and that mppx produces the same signature base and Signature-Input. For Ed25519, which is deterministic, it also checks the exact Signature.
  • The fixture also lists invalid requests with the reason mppx gives: a keyId parameter, alg="Ed25519", a signature over the raw Signature-Input text with spaces after ;, a lifetime over 8 minutes, and @path covered twice.
  • Other SDKs can reuse the same file.

Checks: pnpm check:types, pnpm check:ci, identity tests (428 passed).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T23:52:20.646709Z fcefa81 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tempoxyz-bot

tempoxyz-bot commented Nov 24, 2026 •

Copy link
Copy Markdown

👁️ Cyclops Security Review

✅ Reviewed 01220d0 (latest) · Coverage: partial · ⚠️ 6 open, 1 not rechecked findings · report
⚠️ Not checked: Web Bot Auth server algorithm filtering and nonce-claim scope: ruled out without reading the cited code at this commit
ℹ️ Not verifiable from the source alone (needs running code or deployed state): No production TAP deployment configuration, backend timing trace, or request-limit data establishes how often the reproduced interleaving happens in service. To verify it: Provide a representative TAP
⏸️ The review of 01220d0 did not recheck 1 earlier finding, so whether it still applies is unknown

# Severity Finding Introduced Status
1 🟢 Low TAP cross-key nonce claim expires with the shortest signature lifetime ed16338 🟠 Open
2 🟢 Low TAP upgrades reopen already-consumed signatures ed16338 ✅ Fixed in 01220d0
3 🟢 Low Web Bot Auth resolver type widening breaks exhaustive consumer resolvers fcefa81 🟠 Open
4 🟡 Medium HTTP message signature component check raises unauthenticated verify CPU about fourfold fcefa81 🟠 Open
5 🟢 Low HTTP signature component uniqueness check misses mixed-case field name aliases fcefa81 🟠 Open
6 🟢 Low Web Bot Auth prover signs ECDSA after configured key is replaced fcefa81 🟠 Open
7 🟡 Medium TAP replay keys alias legacy keys, rejecting fresh proofs in mixed-version fleets fcefa81 ⏸️ Not rechecked since fcefa81
8 🟡 Medium Concurrent TAP copies consume a fresh nonce without accepting either request 01220d0 🟠 Open

@pkg-pr-new

pkg-pr-new Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/mppx@1363

commit: 01220d0

Comment on lines +247 to +249
options.nonceScope === 'namespace'
? `${options.nonceNamespace}:${input.nonce}`
: `${options.nonceNamespace}:${input.keyId}:${input.nonce}`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low (exposure and trigger unconfirmed): TAP cross-key nonce claim expires with the shortest signature lifetime

For TAP, HttpMessageSignature.verify records one replay claim per nonce across all keys, but the claim expires when the first accepted signature does. If a second key signs the same nonce with a longer lifetime, that signature is accepted after the first one expires, even though the TAP verifier says it blocks any nonce seen within the signature lifetime.

Valid? React with 👍 / 👎.

Comment on lines +247 to +249
options.nonceScope === 'namespace'
? `${options.nonceNamespace}:${input.nonce}`
: `${options.nonceNamespace}:${input.keyId}:${input.nonce}`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low (exposure and trigger unconfirmed) · unverified: TAP upgrades reopen already-consumed signatures

An already accepted TAP signature should remain consumed until it expires. The base verifier records tap:<keyId>:<nonce>, but the new TAP caller selects namespace scope and the verifier checks only tap:<nonce>. For example, a stable key agent and nonce abc previously consumed at tap:agent:abc can be submitted unchanged to an upgraded verifier before expiry.

Full finding

An already accepted TAP signature should remain consumed until it expires. The base verifier records tap:<keyId>:<nonce>, but the new TAP caller selects namespace scope and the verifier checks only tap:<nonce>. For example, a stable key agent and nonce abc previously consumed at tap:agent:abc can be submitted unchanged to an upgraded verifier before expiry. The signature still verifies, and the upgraded worker accepts it if tap:abc is free. Mixed-version workers also have the reverse gap: an old worker cannot see a claim written only by a new worker. A replay needs access to the original signed request, but no signing key. Acceptance bypasses the TAP request-identity replay gate; it does not establish a bypass of separate payment controls. Production rollout overlap, access to a live captured request, and the downstream route effect were not established. Preserve unexpired claims across versions with a coordinated migration and compatible readers, or stop and drain old TAP traffic and wait out the 480-second lifetime before enabling the new key format.

Valid? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in 01220d0

Comment on lines 2 to 11
export const Algorithms = {
/** EdDSA using the Ed25519 curve. */
ed25519: 'ed25519',
/** ECDSA using the P-256 curve and SHA-256. */
ecdsaP256Sha256: 'ecdsa-p256-sha256',
/** ECDSA using the P-384 curve and SHA-384. */
ecdsaP384Sha384: 'ecdsa-p384-sha384',
/** RSASSA-PSS using SHA-512 and a 64-byte salt. */
rsaPssSha512: 'rsa-pss-sha512',
} as const

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: Web Bot Auth resolver type widening breaks exhaustive consumer resolvers

Adding two ECDSA entries to the shared Algorithms constant widens the algorithm parameter of the WebBotAuth.Server.verifier keyResolver from two literals to four, although the verifier still forwards only Ed25519 and RSA-PSS SHA-512. A strict TypeScript resolver handling exactly those two compiled at the PR base and fails at head with TS7053 or TS2322.

Full finding

Adding two ECDSA entries to the shared Algorithms constant widens the algorithm parameter of the WebBotAuth.Server.verifier keyResolver from two literals to four, although the verifier still forwards only Ed25519 and RSA-PSS SHA-512. A strict TypeScript resolver handling exactly those two compiled at the PR base and fails at head with TS7053 or TS2322.

First reported at fcefa81; recheck at this head: still present.

Valid? React with 👍 / 👎.

id: id as string,
parameters,
}))
if (!hasValidComponents(components)) return undefined

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium (exposure unconfirmed): HTTP message signature component check raises unauthenticated verify CPU about fourfold

toSignatureInput now runs hasValidComponents on the whole attacker-supplied covered-component list before any key lookup. It copies and serializes every component's parameters, so rejecting an unauthenticated request with parameterized components costs 3.8 to 5.5 times the CPU base spent. The cost is linear in header size and no component-count limit applies.

Full finding

toSignatureInput now runs hasValidComponents on the whole attacker-supplied covered-component list before any key lookup. It copies and serializes every component's parameters, so rejecting an unauthenticated request with parameterized components costs 3.8 to 5.5 times the CPU base spent. The cost is linear in header size and no component-count limit applies.

First reported at fcefa81; recheck at this head: still present.

Valid? React with 👍 / 👎.

Comment on lines +437 to 447
function hasValidComponents(components: readonly Component[]): boolean {
const identifiers = components.map(serializeComponent)
return (
new Set(identifiers).size === identifiers.length &&
!components.some((component) => component.id === Constants.components.signatureParams)
)
}

function serializeComponent(component: Component): string {
return `"${component.id}"${component.parameters?.size ? serializeParameters(new Map(component.parameters)) : ''}`
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low (exposure unconfirmed): HTTP signature component uniqueness check misses mixed-case field name aliases

hasValidComponents dedupes covered components by case-sensitive serialized identifier, but field values are read through case-insensitive Headers.get. A Signature-Input covering "x-example" and "X-Example" covers one field twice and still verifies. The base accepted every duplicate; the new check rejects only identically spelled ones.

Full finding

hasValidComponents dedupes covered components by case-sensitive serialized identifier, but field values are read through case-insensitive Headers.get. A Signature-Input covering "x-example" and "X-Example" covers one field twice and still verifies. The base accepted every duplicate; the new check rejects only identically spelled ones.

First reported at fcefa81; recheck at this head: still present.

Valid? React with 👍 / 👎.

const expiresIn = config.expiresIn ?? Constants.defaultSignatureLifetime
const signatureAgent = SignatureAgent.directoryOrigin(config.signatureAgent)
const { publicKey } = Signer.resolve(config.key)
const { publicKey } = Signer.resolve(config.key, [Algorithms.ed25519, Algorithms.rsaPssSha512])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: Web Bot Auth prover signs ECDSA after configured key is replaced

The Web Bot Auth prover checks its Ed25519/RSA-PSS allowlist only at construction. Each prove re-reads config.key and passes it to the shared signer, whose default allowlist now includes ECDSA, while keyid stays the original key's thumbprint. A key replaced after construction is signed with ECDSA instead of being refused.

Full finding

The Web Bot Auth prover checks its Ed25519/RSA-PSS allowlist only at construction. Each prove re-reads config.key and passes it to the shared signer, whose default allowlist now includes ECDSA, while keyid stays the original key's thumbprint. A key replaced after construction is signed with ECDSA instead of being refused.

First reported at fcefa81; recheck at this head: still present.

Valid? React with 👍 / 👎.

@tempoxyz-bot

Copy link
Copy Markdown

Medium (exposure and trigger unconfirmed): TAP replay keys alias legacy keys, rejecting fresh proofs in mixed-version fleets

Head TAP verification claims replay key tap:<nonce>, while released workers claim tap:<keyId>:<nonce> in the same store. A head-accepted proof whose literal nonce is <keyId>:<nonce> therefore occupies the legacy key of another signer's proof, and whichever arrives second on a mixed-version fleet is rejected as a replay. First reported at fcefa81; recheck at this head: still present.

Valid? React with 👍 / 👎.

Comment on lines +274 to +277
const perKey = await Store.tryClaim(store, `${namespace}:${input.keyId}:${input.nonce}`, expires)
if (scope !== 'namespace') return perKey
const shared = await Store.tryClaim(store, `${namespace}:${input.nonce}`, expires)
return perKey && shared

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium (trigger unconfirmed) · unverified: Concurrent TAP copies consume a fresh nonce without accepting either request

For two valid copies of a previously unseen TAP proof, exactly one should pass replay protection. With the incremental two-claim implementation, request A can commit the per-key marker but receive its asynchronous result late. Request B sees that marker, loses the per-key claim, and nevertheless wins the shared claim.

Full finding

For two valid copies of a previously unseen TAP proof, exactly one should pass replay protection. With the incremental two-claim implementation, request A can commit the per-key marker but receive its asynchronous result late. Request B sees that marker, loses the per-key claim, and nevertheless wins the shared claim. A then loses the shared claim. Both report replay and the markers remain, so an unchanged retry is also denied, even though no request was accepted. One atomic claim at the PR base admits one contender. A read-only Node harness executing the pinned helper and in-memory claim primitive with a delayed first acknowledgement observed [false,false] and a failed retry with a 60-second expiry; the single-key control returned [true,false]. When a route requires TAP, the rejection prevents the request from proceeding. The effect is limited to that proof: a fresh nonce can retry, and the rejected proof cannot remain live beyond TAP's 480-second limit. Setup requires a live, otherwise valid proof and two overlapping deliveries to verifiers sharing a store; intentional interference with another signer requires access to that signer's proof before its first accepted use. No payment is required to reach the claim. One extra delivery can cause both copies to fail instead of only the duplicate; sustained interference requires repeating the race for each fresh proof. Production store timing, request limits, and attainable race frequency were not established, so no hourly rate, spend, or service-wide capacity loss is claimed. Make the two-key consume operation atomic and all-or-nothing, or coordinate the migration to a single canonical atomic claim; add a concurrency test that delays the first claim acknowledgement.

Valid? React with 👍 / 👎.

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.

Support ECDSA P-256 and P-384 for TAP signatures

3 participants