Work on Linear issue MM-502: Suggested branch name:…
- User
Work on Linear issue MM-502:
Suggested branch name: malpercio/mm-502-oauth-conformance-cover-the-wallet-device-key-consent-path
The protocol legs on either side of consent (PAR, token exchange, refresh, resource errors) are shared and are covered, so this is a real but bounded gap: what is untested is the approval ceremony itself and everything that depends on it.
Why it matters
The consent paths are not equivalent. The password path could not carry the PAR-time DPoP key binding at all — its PAR row is consumed by the GET that renders the form, so the only carrier left is an attacker-controllable hidden field (see the comment in
oauth_authorize.rs). The wallet path keeps its pending request server-side and does bind.Confirmed empirically during review of #506. A conformance test written to prove the binding end-to-end failed: PAR accepted the DPoP proof, but a different key then redeemed the resulting code with a 200. So
dpop_jktenforcement is currently exercised end-to-end nowhere — the only coverage is a Rust unit test that writes the binding directly onto the code row, skipping the PAR and consent legs entirely. The failing test was kept, inverted to pin the gap (flow.test.ts, "a PAR DPoP proof is accepted, but the password consent path drops the binding"); it will fail and demand attention if the behaviour ever changes.That raises this from a coverage gap to the thing standing between a shipped security control and any evidence it works.
What it needs
Two pieces of infrastructure, neither of which exists today:
- A JS port of the OAuth consent envelope. The canonical encoding lives only in Rust (
crates/crypto/src/oauth_consent.rs): length-prefixedname:len:value\nin fixed field order, withscopeHashas lowercase-hex SHA-256 of the space-joined granted scope. There is a golden vector attest-vectors/oauth-consent-envelope-v1.jsonalready consumed by a Rust test, so the port can be pinned against the identical file — the same pattern as the sovereign-session and account-delete envelopes. - A mock plc.directory serving audit logs. Wallet approval verifies the signature against the account's authoritative signing authority, resolved live from
/{did}/log/audit(identity/authority.rs→identity/plc.rs). The suite's mock directory (tools/oauth-conformance/test/mock-plc.ts) currently serves DID documents only; it would need to serve a real audit-log array. The genesis op is available client-side from 's , so the material exists.
- A JS port of the OAuth consent envelope. The canonical encoding lives only in Rust (
Assistant
I'll start with the Linear workflow skill since this is an MM-issue.
Assistant
No Linear MCP server is authorized in this session (only
plugin:linear:linear, which needs OAuth, and no UUID-named alternative is present) — so I can't move MM-502 to "In Progress" from here. You'll want to flip that manually or in an interactive session. The branch is already correct:claude/oauth-wallet-consent-coverage-49ac53sits exactly on theorigin/maintip (efa6a552), zero commits behind, so the base is fresh.Let me dig into the actual work.
Assistant
★ Insight ─────────────────────────────────────- The two consent paths differ in where the pending request lives. The password form consumes its PAR row on the GET and rebuilds the request from hidden form fields — so
oauth_authorize.rsdeliberately dropsdpop_jktrather than trust an attacker-suppliable copy. The wallet path writes a server-sidepending_oauth_authorizationsrow that carriesdpop_jktstraight through tostore_authorization_code. That's why only one of them can prove the binding. - The mock plc needs
/{did}/log/auditrather than a DID document becauserotationKeysexist only in PLC operations — a DID document never carries them.fetch_current_plc_statereads the newest non-nullified entry'soperationobject and never verifies its signature, so a faithful mock just needs to replay the real genesis op. - The number-match half (V060) latches only after
notify_deviceactually enqueues a sealed payload, which needs[notifications] relay— and iroh binds with the preset (n0 discovery + relay servers), i.e. real network. That collides with this suite's "nothing reaches the network" property.
- The two consent paths differ in where the pending request lives. The password form consumes its PAR row on the GET and rebuilds the request from hidden form fields — so
Assistant
Those diagnostics are only the missing
@types/node—node_modulesisn't installed in this worktree yet. Now the mock directory:Assistant
@ipld/dag-cboris interop's dependency, not this suite's. Rather than add it just to compute a field the server never verifies, the CID belongs beside the DID in interop — both derive from the same signed bytes, exactly ascrates/cryptopairsbuild_did_plc_genesis_opwithcompute_cid:Assistant
Now simplify
plc-audit-log.tsto use that:Assistant
Now the interop type declarations and the fixture:
Assistant
Now the markup half —
consent.tsstays the only file that knows the page:Assistant
Now the wallet-path markup parser and completion form driver:
Assistant
Now the wallet's own side — the signed approval client:
Assistant
While deps install, one call is genuinely yours to make. Everything else in the issue is reachable black-box, but the V060 positive half is not:
Assistant
Now the test file itself:
Assistant
Good. Now the remaining type fixes:
Assistant
While that builds, update the pinned-gap test in
flow.test.ts— its premise has changed:Assistant
Now the README — the consent-seam section and the coverage/gap list:
Assistant
Confirmed: SHA-256, low-S, raw 64-byte compact — exactly the contract
verify_did_key_signatureenforces. Fixing the error-page status assertion (error_pagereturns 400, not 200):Assistant
All 49 green. But green is exactly what this suite exists to distrust — the README's standard is that each assertion was checked by breaking the server and watching it go red. Let me do that for the headline claim:
Assistant
Exactly one test fails, and its message prints the full token set the server handed to the wrong key. Restoring:
Assistant
The design plan carries two claims this change makes false. Truing them up:
Assistant
Now rebuild with the restored source and confirm the full suite is green again, plus the type-check and docs gate:
Assistant
★ Insight ─────────────────────────────────────- The derived-DID check in
plc-audit-log.tsis what makes rebuilding the genesis op safe rather than sloppy. Adid:plcisbase32(sha256(dag-cbor(signed op)))[..24], so "the rebuilt op derives the account's DID" is a total proof of byte-identity — no field-by-field comparison needed, and it fails loudly the day the ceremony's shape changes. - PLC signing being RFC 6979 deterministic (via
@noble/curveswithlowS: true) is why a rebuild is byte-identical at all. A randomized-nonce ECDSA would produce a valid-but-different signature, a different CID, and a different DID — the check would trip on every run. - The break test earned more than a green tick: because the enforcement is
if let Some(bound_jkt) = …, the passing test proves the wallet path carries the binding, and the failing-when-broken test proves the token endpoint enforces it. One experiment covers both halves of the chain.─────────────────────────────────────────────────
Let me commit.
- The derived-DID check in
Assistant