Repository navigation
feat(identity): support TAP ECDSA signatures and enforce RFC 9421 rules - #1363
brendanjryan wants to merge 5 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
👁️ Cyclops Security Review✅ Reviewed 01220d0 (latest) · Coverage: partial ·
|
commit: |
| options.nonceScope === 'namespace' | ||
| ? `${options.nonceNamespace}:${input.nonce}` | ||
| : `${options.nonceNamespace}:${input.keyId}:${input.nonce}`, |
There was a problem hiding this comment.
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 👍 / 👎.
| options.nonceScope === 'namespace' | ||
| ? `${options.nonceNamespace}:${input.nonce}` | ||
| : `${options.nonceNamespace}:${input.keyId}:${input.nonce}`, |
There was a problem hiding this comment.
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 👍 / 👎.
| 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 👍 / 👎.
| 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)) : ''}` | ||
| } |
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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 👍 / 👎.
|
Medium (exposure and trigger unconfirmed): TAP replay keys alias legacy keys, rejecting fresh proofs in mixed-version fleets Head TAP verification claims replay key Valid? React with 👍 / 👎. |
| 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 |
There was a problem hiding this comment.
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 👍 / 👎.
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)
ecdsa-p256-sha256andecdsa-p384-sha384(RFC 9421 §3.3.4–3.3.5) for local key pairs and remote signers, with raw fixed-widthr || ssignatures (64 and 96 bytes).alg: key type, curve and hash.RFC 9421 checks
@signature-params, is malformed (§2.5). Signing refuses such a list before calling a remote signer.verifytakes the algorithms a profile accepts. Web Bot Auth passesed25519andrsa-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
tap:<nonce>), not per key ID. Web Bot Auth keeps per-key nonces.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.jsonholds 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 withnode:crypto, so mppx is checked against an independent implementation.Tap.vectors.test.tschecks that each vector verifies, and that mppx produces the same signature base andSignature-Input. For Ed25519, which is deterministic, it also checks the exactSignature.keyIdparameter,alg="Ed25519", a signature over the rawSignature-Inputtext with spaces after;, a lifetime over 8 minutes, and@pathcovered twice.Checks:
pnpm check:types,pnpm check:ci, identity tests (428 passed).