Skip to content

E9-1 route 2 S2b-2b tests (lane MB): route 2's verifier in mandate-passkey, stubs and pending tests, DEC-2324 - #2153

Closed
kunwarshivam wants to merge 3 commits into
mainfrom
claude/mb-passkey-reduction
Closed

kunwarshivam wants to merge 3 commits into
mainfrom
claude/mb-passkey-reduction

Conversation

@kunwarshivam

Copy link
Copy Markdown
Owner

Story

E9-1, route 2, slice S2b-2b: the tests half of DEC-77 for route 2's own verifier. Spec: workspace API spec §4.10 route 2 items 2 and 4; identity spec §6.4 route 2. Decisions: DEC-2324 (Accepted, agent, approved by the coordinator), DEC-660, DEC-2121.

mandate_passkey::verify returns before the signature on the client data and the authenticator data. It also compares the backup-eligible flag against the stored credential, so a held passkey with another flag fails before any signature work, while an unknown one runs a decoy's check: a timing oracle on whether the passkey exists. §9.31 records no such flag anyway.

The new module mandate_passkey::reduction (its own file, so L1's credentials.rs and step-up's verify are untouched) adds these stubs, each todo!() under DEC-137's #[expect(clippy::todo)]:

  • verify_reduction(rp, challenge, key, assertion): the signature first and always, then the client data, then the authenticator data. No credential-id, backup-flag or counter compare.
  • cose_key(bytes): the public COSE_Key parser, for the public_key artifact.
  • decoy_for(signature): DER first (ES256), then 64 bytes (Ed25519), then any other shape (ES256).
  • DECOY_ES256, the P-256 base point, and DECOY_ED25519, RFC 8032's first test key. Both are valid keys, so a check against them is full work. Their secrets are published, which doesn't matter: a decoy's answer is never accepted.

Spec clause → test

All tests are in crates/mandate-passkey/tests/reduction.rs, #[ignore = "pending E9-1"], and each fails at its stub.

Spec clause or invariant Test name
§4.10 item 2: a held key verifies with no credential-id, backup-flag (BE, BE+BS) or counter compare a_held_key_verifies_whatever_id_flag_or_counter_the_assertion_carries
§4.10 item 4: a held key and a decoy take the same path up to the signature result. A bad signature is the answer whatever else is wrong: for 9 malformations, for unparsable data, and under a held, stranger or decoy key. Once signed well, the client data is judged, then the authenticator data a_bad_signature_is_the_answer_whatever_else_is_wrong_for_a_held_key_or_a_decoy
§4.10 item 4: the decoy is chosen by encoding, DER first. This includes 64-byte DER, and 64-byte non-DER: trailing, overrun and wrong-tag cases the_decoy_is_chosen_by_the_signatures_encoding_der_first
DEC-2324 item 4: each decoy is a valid key. A signature from its published secret verifies, so the check runs to the end each_decoy_is_a_valid_key_so_its_check_is_a_full_verification
DEC-2324 item 3: cose_key reads ES256 and EdDSA and refuses trailing, truncated, non-map and RS256 input a_cose_key_reads_as_its_algorithms_key_and_nothing_else_does

Dependencies

None.

Journal events added

None.

Not done

S2b-3: the route that resolves the key artifact, applies the decoy rule (DEC-2324 item 5) and the standing, and opens the session.

Decisions needed

None. DEC-2324 is Accepted. Where a backup-eligible flag would come from stays open, per DEC-2121's follow-ups.

Safety checklist (safety-critical changes)

  • No floats in money or quantity paths
  • No clock reads or randomness in the core
  • No unwrap, expect, or panics on trading paths (only the DEC-77 stubs)
  • Ordering: inputs processed in journal order
  • Replay: same inputs give identical outputs
  • No secrets or trading content in logs or notifications
  • No x-planned or (planned: ...) marker added to a value the code already serves, or a reviewer signed it off (DEC-683)

Checks

  • fmt, clippy -D warnings, markers and typos are clean; the 5 pending tests fail at their stubs.
  • Review agent report attached (the coordinator routes it to L1's reviewer)

Generated by Claude Code

…2324 (E9-1 S2b-2b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K
…: stubs, pending tests, DEC-2324 item 4 (review of #2153)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

Copy link
Copy Markdown
Owner Author

Included in #2154 (DEC-77 tests + impl landed combined).


Generated by Claude Code

kunwarshivam added a commit that referenced this pull request Oct 22, 2026
… implemented (#2154)

## Story

E9-1, route 2, slice S2b-2b: the implementation half of DEC-77, on top of #2153. Spec: workspace API spec §4.10 route 2 items 2 and 4. Decision: DEC-2324.

- **`verify_reduction`** computes all three results before it answers:
  - the signature result: `cose::verify` over `authenticator_data || SHA-256(client_data_json)`;
  - the client data result: `client_data::check` for a `get` ceremony;
  - the authenticator data result: `AuthData::parse`, then no attested data, then `check`.

  It answers `signed.and(client_data).and(authenticator_data)`. Nothing returns before the signature has been verified.
- **`cose_key`** is `cbor::read_all` (nothing after the key) followed by the existing `cose::public_key`.
- **`decoy_for`** uses `ecdsa_der`: a `SEQUENCE` whose short-form length is the rest, holding exactly two `INTEGER`s. Then 64 bytes, then anything else.

The tests change only by deleting their five `#[ignore = "pending E9-1"]` lines.

## Spec clause → test

The same five tests as #2153, in `crates/mandate-passkey/tests/reduction.rs`.

## Dependencies

None.

## Journal events added

None.

## Not done

As listed on #2153.

## Decisions needed

None.

## Safety checklist (safety-critical changes)

- [x] No floats in money or quantity paths
- [x] No clock reads or randomness in the core
- [x] No `unwrap`, `expect`, or panics on trading paths
- [x] Ordering: inputs processed in journal order
- [x] Replay: same inputs give identical outputs
- [x] No secrets or trading content in logs or notifications
- [x] No `x-planned` or `(planned: ...)` marker added to a value the code already serves, or a reviewer signed it off (DEC-683)

## Checks

- [x] fmt and clippy `-D warnings` clean; `mandate-passkey` nextest 89/89.
- [x] `cargo mutants --in-diff` on the `mandate-passkey` diff against main: 13 mutants, 11 caught, 2 unviable, 0 missed.
- [x] Review agent report attached

---
_Generated by [Claude Code](https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K)_

## Independent review (different model)

Round 1 FAIL at #2153 7c426a1 / #2154 fdd6d36 on a measured timing oracle: a decoy chosen by the signature's encoding let a wrong-shaped signature against a held passkey be rejected without the math (346 ns against 76 µs for an unknown id, 221 times faster; 759 ns against 45 µs for the other shape), revealing whether a passkey exists and its algorithm. The rest passed: a bad signature is always `signature_invalid`; the decoys are real keys costing a full verification; `cose_key` refuses 40,000 fuzzed and mutated inputs without a panic; route 1's `verify` is untouched.

Round 2 PASS at #2153 f2ec6fd / #2154 7eae72e. `verify_reduction(rp, challenge, key: Option<&PublicKey>, assertion)` runs one ES256 and then one Ed25519 check on every call, the held key in its own slot and decoys elsewhere, and answers only the held key's check; `decoy_for` is gone. The reviewer's release-mode probe over six signature shapes × {held ES256, held Ed25519, none} now gives a max/min ratio of 1.002 to 1.020 per shape (64 raw bytes about 1,070 ns for all three, the DER shapes about 71 µs for all three); only the shape, which the caller chooses, still varies. The counting `SignatureCheck` test pins the work, and both seeded bugs (skipping the Ed25519 check when no key is held; a held Ed25519 key given the decoy slot) fail it. #2153's five pending tests fail at `todo!()` stubs. Workspace API §4.10 item 4, DEC-2119's Status line and DEC-2324 item 4 state the constant-work rule. Mutants on the diff: 4, 3 caught, 1 unviable, 0 missed.

Coordinator: the merge with main compiles across the workspace, all targets. Landed combined (DEC-77): #2154 contains #2153's head.

Coordinator-approved-head: 7eae72e


---
_Generated by [Claude Code](https://claude.ai/code)_
kunwarshivam added a commit that referenced this pull request Oct 25, 2026
…, implemented (#2167)

* Route 2's gate bounded in all: ReductionLimits gains max_outstanding, reserve and max_failure_keys; pending tests (E9-1 S2a, DEC-2119 items 4 and 11)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's gate bounded in all: max_outstanding, the reserve, and max_failure_keys with the oldest key dropped first (E9-1 S2a, DEC-2119 items 4 and 11)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Pin which failure key the gate drops first, address before device at a tie

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Bound the reduction gate's challenges in all and its failure keys

Stop dropping failure keys when a removal removes nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's session in the store: stubs and pending tests (E9-1 S2b-1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's session in the store: open it, mark it, never refresh it (E9-1 S2b-1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's passkey records and interim standing: stubs, pending tests, and DEC-2319 (Proposed) (E9-1 S2b-2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's passkey records and interim standing, implemented (E9-1 S2b-2, DEC-2319 item 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Pin eviction by latest failure against earliest, with a lapsed failure, and bound a failure's cost (review of #2128, B1 and B2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Index failure keys by their latest failure, so lapsing and the bound cost no scan of the keys (review of #2131, B2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's verifier in mandate-passkey: stubs, pending tests, and DEC-2324 (E9-1 S2b-2b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Size the 64-byte DER cases to 64 bytes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's verifier in mandate-passkey, implemented (E9-1 S2b-2b, DEC-2324)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Pin subject() on a live passkey session and a tagged cookie with the wrong secret (review of #2135, B1 and B2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's judge: stubs and pending tests (E9-1 S2b-3a, DEC-2324 item 5, DEC-2319 item 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's judge, implemented (E9-1 S2b-3a, DEC-2324 item 5, DEC-2319 item 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's presentations: take, settle, and the sign-in standing, stubs and pending tests (E9-1 S2b-3b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's presentations: take, settle, and the sign-in standing, implemented (E9-1 S2b-3b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Route 2's verifier does one ES256 and one Ed25519 check on every call: stubs, pending tests, DEC-2324 item 4 (review of #2153)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* The judge's doc names the constant-work verifier (DEC-2324 item 4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* The judge verifies with the held key or None, the verifier doing the constant work (DEC-2324 item 4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Pin that a lapsed key leaves its map with its index entry, so live keys fill the bound exactly (review of #2131)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Merge the desync test into the implementation (review of #2131)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Pin an Ed25519 key recorded as es256 refused, and DEC-2319 item 2 reads at or after the sign-in (review of #2161)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Merge the reverse-algorithm test; a key-store miss parses a decoy key, so a hit and a miss cost the same parse (review of #2162)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Pin refused presentations of taken challenges as failures, and the address limit through settle (review of #2166)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Merge the refused-presentation tests into the implementation (review of #2166)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iKGDLLDHxGNmpHbTwqW8K

* Name E9-13 as the end of the interim standing, now DEC-2319 is accepted

Claude-Session: https://claude.ai/code/session_01XaatUQzQSGvN12QXK3pnJh

* Pin route 2's 300 s failure window, single use across threads, and a poisoned lock (review of #2166)

The review found the T0+339 assertion vacuous: settle answers false there
whether or not the failure lapsed. Two devices now pin the window to the
second, one reaching its limit at 338 s only if a failure at 39 s still
counts, the other reaching it afresh at 339 s only if it lapsed then.
Sixteen threads taking one challenge must find exactly one Some, and a
panic inside issue that poisons the store's locks must leave take and
settle working. Sessions::standing's doc names Standings as the standing's
one owner, which the session store alone writes.

Claude-Session: https://claude.ai/code/session_01XaatUQzQSGvN12QXK3pnJh

---------

Co-authored-by: Claude <noreply@anthropic.com>
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