Skip to content

Bound passkey lifecycle storage - #10

Merged
FlyOverCoderKY merged 5 commits into
mainfrom
claude/passkey-quotas-and-revocation
Nov 6, 2026
Merged

FlyOverCoderKY merged 5 commits into
mainfrom
claude/passkey-quotas-and-revocation

Conversation

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor

Summary

  • add durable per-principal passkey capacity reservations with validated active and retained-record limits
  • add bounded registration-proof and revoked-record maintenance with cursor-based collection
  • make passkey removal converge across concurrent counter updates before reporting success
  • cover the lifecycle paths against memory storage and Azurite, and document the host settings

Validation

  • CI=1 pnpm run format:check
  • CI=1 pnpm run check
  • CI=1 pnpm test
  • CI=1 pnpm audit --prod --audit-level=high

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

OpenRouter review posted (clean). #10 (review)

@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-06T18:01:07.506902Z 1b1c3a9 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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OpenRouter pull-request review

Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: 1b1c3a9a0ce9e451996a3f2bc66f08b77995c0fe
Judge: openai/gpt-5.6-luna
Cost: $0.4752 (lanes $0.4704 + judge $0.0048)

Lanes

  • meta/muse-spark-1.2: ok (7 finding(s), 114.6s, 344538+9888 tokens (83283 cached), 5 tool round(s), via Meta, $0.38)
  • z-ai/glm-5.3-flash: ok (4 finding(s), 698.4s, 3556474+61506 tokens (3349568 cached), 36 tool round(s), via OpenInference, $0.0893)

Warning

meta/muse-spark-1.2: coverage claims 3 finding(s) in 'packages/identity/src/passkeys.ts' but 4 were reported

Findings

🟠 Issue 1 — Passkey sweep aborts on malformed storage rows instead of isolating them

packages/identity/src/passkeys.ts:1699 · risk · identified by meta/muse-spark-1.2

Concrete failure: a single corrupt row in pegma_identity_registration_proofs, pegma_identity_credential_indexes, pegma_identity_passkeys or pegma_identity_passkey_principals causes sweepPasskeys() to throw storage_corrupt and abort the page, leaving nextCursor never returned so the caller cannot advance and later rows never get inspected.

Evidence: passkeys.ts:1737-1800 iterates page.records and assumes collection.codec.decode succeeded; there is no try/catch per row and no rejected counter. challenges.ts:500-590 shows the intended pattern: it uses challengeScanCollection (raw StoredRecord), scanRecord/try/catch per row, increments rejected and continues, and never throws on decode failure. The passkey sweep uses the typed collections directly, so a corrupt retireAt, slots JSON, or expiresAt will bubble and fail the whole scan page.

Checked: records.ts:444-620 decoders deliberately throw storage_corrupt on malformed invariants (hash, timestamp, enum, partition), and passkeys.test.ts explicitly exercises corrupt-row isolation for sweepChallenges but has no equivalent for sweepPasskeys. No per-row guard was found in passkeys.ts sweep implementation; proof gap: whether adapter pre-filters corrupt rows is not guaranteed by storage-core contract.

🟠 Issue 2 — Principal capacity check depends on complete list enumeration which may paginate

packages/identity/src/passkeys.ts:429 · risk · identified by meta/muse-spark-1.2

Concrete failure: reservePrincipalSlot and ensurePrincipalState call passkeys.list(partition) to merge mirrors into mergedPrincipalSlots. If the underlying adapter implements list as a bounded page (or truncates after e.g. 100 items), the merge undercounts existing credentials, allowing concurrent registrations to bypass both maxActiveCredentials (10 default, 64 max) and maxRetainedCredentials (20 default, 128 max) and exceed the documented limits.

Evidence: passkeys.ts:429-460 (mergedPrincipalSlots) and passkeys.ts:1190-1210 (beginRegistration active-count check) rely on await passkeys.list(passkeyPartition(digest)) returning the complete set. storage-core also exposes authoritative bounded scan for this reason; challenges.ts switched to scan for sweeping to avoid list limits. No limit or pagination handling is present for the passkey list path.

Checked: grep for list\( shows all principal-size checks use list; the test store is createMemoryStore which returns all, but createAzureTablesStore scan/list behavior for large partitions was not verified in this review, leaving a proof gap on adapter pagination guarantees.

🔴 Issue 3 — Removal success requires exact retireAt equality, breaking legacy tombstones

packages/identity/src/passkeys.ts:1575 · bug · identified by meta/muse-spark-1.2

Concrete failure: removePasskey only returns true after verifying mirror.retireAt === confirmed.retireAt and mirror.retireAt === index.retireAt (passkeys.ts:1567-1585). Existing rows written before this PR have retireAt = null and rely on computed after(updatedAt, tombstoneRetentionMs) fallback elsewhere (records.ts allows retireAt: null for revoked). After the code change, a removal that creates a new retireAt timestamp will still compare against a legacy mirror/index that still has null (until repair synchronises), causing the conflict: Passkey removal did not converge path even though both records are logically revoked, making removal appear to fail to the caller.

Evidence: records.ts:451/506 decode allows retireAt null for revoked for backwards compatibility; passkeys.ts:905-940 repair writes retireAt from index to mirror, and sweep logic uses ?? after(...) fallback for null, but removePasskey verification uses strict === without fallback. Checked callers: removePasskey is the only place that demands exact equality; sweep uses fallback correctly.

Counter-check: repair should eventually materialise retireAt, but the retry loop in removePasskey does not apply the same fallback, so a first-attempt success can be mis-classified as conflict.

🟠 Issue 4 — Slot merge retains stale reserved instead of newer revoked/active mirror

packages/identity/src/passkeys.ts:471 · risk · identified by meta/muse-spark-1.2

Concrete failure: mergedPrincipalSlots (passkeys.ts:445-500) intentionally keeps a reserved slot when the mirror has a different registrationId (if (current?.state !== "reserved") slots[pos]=next). If a registration succeeded and wrote an active mirror but the principal slot is still reserved due to a crash before setPrincipalSlot, the merge will not adopt the newer active mirror; ensurePrincipalState will keep the stale reserved slot and beginRegistration will count it as active, incorrectly rejecting a legitimate next enrollment with limit_exceeded until the next principals sweep repairs it.

Evidence: the if (current?.state !== "reserved") guard is the only branch that skips replacement for reserved → active/revoked mismatch. The intended repair path is the later principals sweep reserved && exactIndex => repair but that runs minutes later, not inline.

Checked: setPrincipalSlot and repair do update the slot to active, but ensurePrincipalState can be invoked concurrently before that update and will persist the stale reserved snapshot for up to a full sweep interval.

🔵 Issue 5 — Release test shell flag differs by platform, masking Windows invocation failure

scripts/release-package.test.mjs:192 · nit · identified by meta/muse-spark-1.2

Concrete failure: scripts/release-package.test.mjs:192-204 now invokes spawnSync(npmCommand, ..., shell: process.platform===\"win32\"). On POSIX shell becomes false (explicit), while scripts/release-package.mjs:20-32 run defaults shell to false when undefined. The test therefore does not exercise the same code path as production runNpm, which on Windows passes shell:true to allow npm.cmd execution. A regression where runNpm stops using shell:true on Windows would still pass on Linux CI but fail during a Windows-based trusted-publisher publish.

Evidence: release-package.mjs:24-32 and runNpm:33-36 both set shell: process.platform===\"win32\"; the test mirrors that but also sets shell: process.platform===\"win32\" for the reference spawnSync("npm"...) baseline, so both sides use the same platform branch and never assert that npm.cmd actually requires a shell.

Checked: existing publish.yml runs on ubuntu-latest only, so Windows publish path has no CI coverage; proof gap: no Windows runner verifies runNpm invocation.

🔵 Issue 6 — Threat model version bump references @​pegma/mail@​0.1.1 without lockfile evidence in diff

docs/THREAT_MODEL.md:25 · nit · identified by meta/muse-spark-1.2

Concrete failure: docs/THREAT_MODEL.md:25 changes the prose from @​pegma/mail@​0.1.0 to @​pegma/mail@​0.1.1 to match the new retention wording, but the diff does not show a corresponding packages/identity/package.json or pnpm-lock.yaml change in this PR. If the dependency remains pinned at 0.1.0, the documented at-least-once delivery guarantee wording diverges from the actually reviewed dependency, weakening the threat-model audit trail.

Evidence: REQUIRED_DEPENDENCIES in scripts/release-package.mjs:13 already expects @​pegma/mail: "0.1.1", matching the doc change, but that file is not in the embedded diff; the review could not confirm the lockfile or manifest were updated atomically with the doc.

Checked: grep for @​pegma/mail shows only docs/THREAT_MODEL.md and scripts/release-package.mjs mention 0.1.1; pnpm-lock.yaml was not listed among changed paths, leaving a proof gap.

🔵 Issue 7 — README lifecycle bounds wording omits retained vs active distinction for sweep

README.md:40 · nit · identified by meta/muse-spark-1.2

Concrete failure: README.md:40-52 states "Completed registration proofs become eligible for collection after 24 hours; revoked credential records remain for 30 days before collection." A host reading only the top-level README may infer proofs are only for completed registrations, while packages/identity/README.md:249 and docs/THREAT_MODEL.md:96-102 clarify that proofs are also collected for registrations that never obtained a credential reservation, and that sweepPasskeys also releases expired reservations. The top-level summary omits the reservation-release behavior, risking operators not scheduling sweeps frequently enough to reclaim quota after failed registrations.

Evidence: README.md:48-53 lists sweepPasskeys() as collecting proofs, expired revoked records, and abandoned reservations, but the preceding paragraph does not mention reservations.

Checked: packages/identity/README.md:242-256 documents the full behavior; top-level README is shorter.

🟠 Issue 8 — Critical transactional atomicity violation in finishRegistration

packages/identity/src/passkeys.ts:1303 · risk · identified by z-ai/glm-5.3-flash

If the challenge claim consumption fails immediately after the credential persistence step, the system enters a non-idempotent state, leaving the credential stored without the claim being marked as consumed, which can result in retries failing with conflict errors.

Mechanism: The function sequence persists the credential first, then attempts to consume the claim. If consumeClaim throws (e.g., due to a transient database failure or a race condition), the credential is already committed to the storage, but the challenge claim remains unconsumed.

Evidence: packages/identity/src/passkeys.ts:1303 shows that the catch block wraps both persistCredential and consumeClaim, suggesting the author was aware of potential failures in this block, but the logic does not handle partial success (persistence success + consumption failure).

Verification: I checked the sequence of operations in the finishRegistration method and confirmed that the persistCredential and consumeClaim calls are not wrapped in a single transaction.

🟠 Issue 9 — State inconsistency in repair leaves orphaned active mirror

packages/identity/src/passkeys.ts:1155 · risk · identified by z-ai/glm-5.3-flash

If the passkey mirror update succeeds (marking the mirror as active) but the subsequent credential index update (activation) fails, the system is left with an inconsistent state where the mirror is active but the index is still in a reserved state.

Mechanism: In the repair sequence, the mirror is updated to active before the credential index is updated. If the index update fails, the mirror remains active without a corresponding index entry, leading to state corruption.

Evidence: The repair function updates the passkey mirror before activating the credential index, and there is no rollback mechanism if the second step fails.

Verification: I checked the repair function logic and confirmed that the mirror update and index activation are separate operations without a compensating transaction.

🟠 Issue 10 — Critical error masking during challenge sweep

packages/identity/src/challenges.ts:523 · risk · identified by z-ai/glm-5.3-flash

If a storage error occurs during the challenge sweep, the system silently masks the error as a 'rejected' record instead of surfacing the underlying infrastructure failure.

Mechanism: The sweep function iterates through records and attempts to decode/process each one. If an unexpected exception (e.g., a storage timeout, network error, or database corruption) occurs, it is caught and counted as a rejected record, hiding the root cause.

Evidence: packages/identity/src/challenges.ts:523 shows a bare catch block that increments the rejected counter without logging or re-throwing the error.

Verification: I checked the sweep logic and confirmed that all exceptions during record processing are swallowed, which is a significant risk for storage integrity.

🔵 Issue 11 — Documentation lacks configuration clarity

README.md · nit · identified by z-ai/glm-5.3-flash

The README documentation does not clearly specify how to configure the passkey limits or what the maximum bounds are, which can lead to configuration errors for users.

Mechanism: The documentation defines default settings but lacks clear instructions on how to override them or what the enforced limits are.

Evidence: README.md mentions '10 active or in-flight credentials and 20 retained credential records per principal' but does not provide the code configuration snippets or explicit bounds.

Verification: I reviewed the README.md and confirmed the missing details on configuration and bounds.

Workflow run

Comment thread packages/identity/src/passkeys.ts Resolved
existing: readonly PasskeySlot[],
): Promise<readonly PasskeySlot[]> {
const slots = [...existing];
const mirrors = await passkeys.list(passkeyPartition(principalDigest));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 Principal capacity check depends on complete list enumeration which may paginate (risk)

Concrete failure: reservePrincipalSlot and ensurePrincipalState call passkeys.list(partition) to merge mirrors into mergedPrincipalSlots. If the underlying adapter implements list as a bounded page (or truncates after e.g. 100 items), the merge undercounts existing credentials, allowing concurrent registrations to bypass both maxActiveCredentials (10 default, 64 max) and maxRetainedCredentials (20 default, 128 max) and exceed the documented limits.

Evidence: passkeys.ts:429-460 (mergedPrincipalSlots) and passkeys.ts:1190-1210 (beginRegistration active-count check) rely on await passkeys.list(passkeyPartition(digest)) returning the complete set. storage-core also exposes authoritative bounded scan for this reason; challenges.ts switched to scan for sweeping to avoid list limits. No limit or pagination handling is present for the passkey list path.

Checked: grep for list\( shows all principal-size checks use list; the test store is createMemoryStore which returns all, but createAzureTablesStore scan/list behavior for large partitions was not verified in this review, leaving a proof gap on adapter pagination guarantees.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No code change: storage-core 0.4.0 defines CollectionStore.list as returning every record in one partition. scan is the bounded cross-partition maintenance API. Both configured adapters conform to that contract, so pagination here is not permitted adapter behavior.

) {
return { action: "keep" };
}
return {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Removal success requires exact retireAt equality, breaking legacy tombstones (bug)

Concrete failure: removePasskey only returns true after verifying mirror.retireAt === confirmed.retireAt and mirror.retireAt === index.retireAt (passkeys.ts:1567-1585). Existing rows written before this PR have retireAt = null and rely on computed after(updatedAt, tombstoneRetentionMs) fallback elsewhere (records.ts allows retireAt: null for revoked). After the code change, a removal that creates a new retireAt timestamp will still compare against a legacy mirror/index that still has null (until repair synchronises), causing the conflict: Passkey removal did not converge path even though both records are logically revoked, making removal appear to fail to the caller.

Evidence: records.ts:451/506 decode allows retireAt null for revoked for backwards compatibility; passkeys.ts:905-940 repair writes retireAt from index to mirror, and sweep logic uses ?? after(...) fallback for null, but removePasskey verification uses strict === without fallback. Checked callers: removePasskey is the only place that demands exact equality; sweep uses fallback correctly.

Counter-check: repair should eventually materialise retireAt, but the retry loop in removePasskey does not apply the same fallback, so a first-attempt success can be mis-classified as conflict.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No code change: removal awaits repair before the strict equality check, and that repair copies the index retireAt into the active mirror. Older missing fields decode to null on both records. abc4566 adds memory and Azurite coverage that removes an active credential after both stored retention fields are omitted.

Comment thread packages/identity/src/passkeys.ts Resolved
@@ -190,8 +190,10 @@ test("trusted publishing rejects npm older than 11.5.1", () => {
});

test("runNpm invokes npm even when npm_execpath points at pnpm", () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Release test shell flag differs by platform, masking Windows invocation failure (nit)

Concrete failure: scripts/release-package.test.mjs:192-204 now invokes spawnSync(npmCommand, ..., shell: process.platform===\"win32\"). On POSIX shell becomes false (explicit), while scripts/release-package.mjs:20-32 run defaults shell to false when undefined. The test therefore does not exercise the same code path as production runNpm, which on Windows passes shell:true to allow npm.cmd execution. A regression where runNpm stops using shell:true on Windows would still pass on Linux CI but fail during a Windows-based trusted-publisher publish.

Evidence: release-package.mjs:24-32 and runNpm:33-36 both set shell: process.platform===\"win32\"; the test mirrors that but also sets shell: process.platform===\"win32\" for the reference spawnSync("npm"...) baseline, so both sides use the same platform branch and never assert that npm.cmd actually requires a shell.

Checked: existing publish.yml runs on ubuntu-latest only, so Windows publish path has no CI coverage; proof gap: no Windows runner verifies runNpm invocation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No code change: the reference invocation intentionally mirrors production platform dispatch. Windows uses npm.cmd with shell: true on both sides, and the local Windows gate executes that path; POSIX uses npm with shell: false on both sides. A Linux process cannot assert Windows command-shim behavior.

Comment thread docs/THREAT_MODEL.md
Mailbox control is the account-recovery security floor. The component cannot
make a compromised mailbox safe; hosts must communicate that limit and should
encourage passkey enrollment. `@pegma/mail@0.1.0` provides durable
encourage passkey enrollment. `@pegma/mail@0.1.1` provides durable

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Threat model version bump references @​pegma/mail@​0.1.1 without lockfile evidence in diff (nit)

Concrete failure: docs/THREAT_MODEL.md:25 changes the prose from @​pegma/mail@​0.1.0 to @​pegma/mail@​0.1.1 to match the new retention wording, but the diff does not show a corresponding packages/identity/package.json or pnpm-lock.yaml change in this PR. If the dependency remains pinned at 0.1.0, the documented at-least-once delivery guarantee wording diverges from the actually reviewed dependency, weakening the threat-model audit trail.

Evidence: REQUIRED_DEPENDENCIES in scripts/release-package.mjs:13 already expects @​pegma/mail: "0.1.1", matching the doc change, but that file is not in the embedded diff; the review could not confirm the lockfile or manifest were updated atomically with the doc.

Checked: grep for @​pegma/mail shows only docs/THREAT_MODEL.md and scripts/release-package.mjs mention 0.1.1; pnpm-lock.yaml was not listed among changed paths, leaving a proof gap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No code change: packages/identity/package.json already pins @pegma/mail to 0.1.1, and pnpm-lock.yaml already contains the matching importer and package entries. This corrects stale prose without changing the dependency.

Comment thread README.md Resolved
@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

OpenRouter ledger follow-up for abc4566:

  • Items 1, 4, 7, and 11 are addressed in this commit with memory/Azurite coverage where applicable.
  • Item 8: the challenge is already single-flight in verifying, and storage-core does not offer a cross-collection transaction. Persisting the durable credential before consuming the claim avoids consuming a verified ceremony before its credential is durable; the verifying claim cannot be claimed again and remains eligible for bounded collection.
  • Item 9: a reserved index with an active mirror is the intentional repair checkpoint. repair validates the immutable proof and exact mirror before activating the index; the existing memory/Azurite interruption test covers this sequence.
  • Item 10: the catch in challenge maintenance contains row-shape validation and codec decoding only. The scan call and conditional deletion are outside it, so storage-operation failures propagate.

The remaining inline items have replies with repository-contract or stored-state evidence and remain open for maintainer visibility.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OpenRouter pull-request review

Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: abc45666b21f441be29ec88aa61ee82633729dc5
Judge: openai/gpt-5.6-luna
Cost: $0.2521 (lanes $0.2520 + judge $0.0001)

Lanes

  • meta/muse-spark-1.2: ok (0 finding(s), 39.5s, 198064+5551 tokens (93222 cached), 6 tool round(s), via Meta, $0.17)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 316.2s, 1618558+30062 tokens (1381376 cached), 30 tool round(s), via InferenceNet, $0.0834)

Round 2 resolution

  • ✅ r1-3 fixed correctly — Removal success requires exact retireAt equality, breaking legacy tombstones: Legacy-tombstone removal now converges: removePasskey creates a new retireAt and repair copies it to the mirror, then verifies mirror.retireAt === confirmed.retireAt on the newly written values. Verification added by test removes an active credential whose stored records predate retention fields which strips retireAt from both credentialIndexesCollection and passkeysCollection befo…
  • ✅ r1-1 fixed correctly — Passkey sweep aborts on malformed storage rows instead of isolating them: sweepPasskeys() no longer aborts on a single corrupt row. Diff introduces passkeyScanCollection/passkeyScanPage/decodePasskeyScanRecord safe wrappers and per-row try/catch { rejected+=1; continue } in all four stages (proofs 1952-1978, indexes 2031-2053, mirrors 2124, principals 2176), returning rejected and nextCursor so callers can advance. Covered by test `retains malforme…
  • 🤝 r1-2 disputed — Principal capacity check depends on complete list enumeration which may paginate: Disputed as relying on a contract violation rather than a defect in this PR. @​pegma/storage-core exposes scan as the bounded, cursor-paginated read (the threat model calls it the 'authoritative adapter-bounded collection scan', and this PR uses it for sweeps); list(partition) is the complete-partition read that the pre-existing public listPasskeys and beginRegistration's `excludeCredenti…
  • ✅ r1-4 fixed correctly — Slot merge retains stale reserved instead of newer revoked/active mirror: Stale reserved vs newer active/revoked reconciliation fixed. mergedPrincipalSlots now loads the credentialIndex for a mismatched registrationId and, if the mirror's registrationId matches an active/non-reserved index for the same principal, adopts the mirror (slots[pos]=next), and if the current slot's index is still reserved keeps it; otherwise throws storage_corrupt. Verified…
  • ❌ r1-8 not fixed — Critical transactional atomicity violation in finishRegistration: No change to finishRegistration atomicity. passkeys.ts:1363-1384 still does stored = await persistCredential(...); await challengeService.consumeClaim(claim) inside the same try. If consumeClaim throws (transient DB failure, race), the credential/index/mirror/principal slot remains committed while the challenge claim stays unconsumed, leaving a non-idempotent state and retries failing with…
  • 🤝 r1-9 disputed — State inconsistency in repair leaves orphaned active mirror: Disputed as the documented crash-forward design, not corruption. The threat model states 'Cross-collection crashes are expected, so intermediate states are durable and repairable rather than treated as exceptional' and, for the counter path specifically, 'A crash on either side of the mirror write is replayable without weakening owner, generation, or counter-regression checks.' Re-running repair…
  • 🤝 r1-10 disputed — Critical error masking during challenge sweep: Disputed — the claimed mechanism does not exist. The catch at challenges.ts:~523 wraps only scanRecord(rawRow) and challengesCollection.codec.decode(...) (synchronous, in-memory validation of an already-fetched row) plus the key-agreement check; it contains no storage operations. Failures from scanCollection.scan (before the loop) and from collection.deleteIfUnchanged (outside the try) p…
  • 4 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is risk).
  • Open findings after this round: 1 (0 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

Fixed in 142ae80: once the exact credential, index, mirror, and principal slot are durable, final challenge consumption is best-effort. An interrupted final write leaves the claim in single-flight verifying state for expiry collection while returning the durable registration. Memory and Azurite coverage forces this interruption, rejects a second submission, and confirms later collection.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OpenRouter pull-request review

Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: 142ae80060191df07433b024913abdffd2da6022
Judge: openai/gpt-5.6-luna
Cost: $0.1480 (lanes $0.1479 + judge $0.0001)

Lanes

  • meta/muse-spark-1.2: ok (0 finding(s), 34.6s, 105523+3318 tokens (4947 cached), 4 tool round(s), via Meta, $0.14)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 192.3s, 138642+15960 tokens (97312 cached), 7 tool round(s), via OpenInference, $0.0074)

Round 3 resolution

  • ✅ r1-8 fixed correctly — Critical transactional atomicity violation in finishRegistration: Commit 142ae80 moves consumeClaim outside the credential-persistence try and makes it best-effort with try{consume} catch{}; credential is returned as durable if persist succeeds. Threat model updated to document verifying remains single-flight and is expiry-collected. New test returns a durable registration when final challenge cleanup is interrupted forces a consumed-write failure vi…
  • Open findings after this round: 0 (0 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OpenRouter pull-request review

Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: 9811af400a8a910f8166c9ae6820a29e46eb0b9b
Judge: openai/gpt-5.6-luna
Cost: $0.1129 (lanes $0.1116 + judge $0.0013)

Lanes

  • meta/muse-spark-1.2: ok (0 finding(s), 16.1s, 34054+1669 tokens (14901 cached), 4 tool round(s), via Meta, $0.0333)
  • z-ai/glm-5.3-flash: ok (1 finding(s), 542.9s, 1532366+47532 tokens (1369344 cached), 30 tool round(s), via InferenceNet, $0.0783)

Round 4 resolution

  • No prior findings were open.
  • Open findings after this round: 1 (0 bug-severity).

Findings

🟠 Issue 1 — setPrincipalSlot writes a codec-invalid revoked slot for revoked credentials that predate retireAt

packages/identity/src/passkeys.ts:1201 · risk · identified by z-ai/glm-5.3-flash

A revoked credential-index record whose retireAt is absent (the pre-retention shape that 0.1.0's revocation wrote) reaches repair's revoked branch, which calls await setPrincipalSlot(index, "revoked", index.retireAt) with expiresAt = null (packages/identity/src/passkeys.ts:1201). That writes a principal slot { state: "revoked", expiresAt: null }.

That slot violates the principal codec: decodePasskeySlots enforces (state === "active") !== (expiresAt === null), so any later read of the principal record throws storage_corrupt. Because the collection codec only validates on decode, the write succeeds and then bricks the record: beginPasskeyRegistration, removePasskey, and every ensurePrincipalState caller for that principal fail permanently, and the sweep's principals stage can never repair it — the scan row is decode-rejected into rejected forever. That is the threat model's "malformed records causing a fail-closed outage in one partition" class, self-inflicted.

The second facet: when the pre-retention revoked index has no mirror at all (the old removal flow revokes the global lookup and removes the user copy) and no slot, setPrincipalSlot finds no matching slot, returns keep, and its post-check throws storage_corrupt. So repairPasskey on such a credential throws instead of returning null, and removePasskey on an already-revoked legacy credential throws instead of returning false.

The codebase elsewhere treats null-retireAt revoked records as representable: the codecs deliberately allow them (records.ts:438 for mirrors, :486 for indexes; optionalTimestamp returns null for a property Azure omits), and every other consumer defends with the same fallback — slotFromPasskey (passkeys.ts:625), the indexes stage for both index and mirror (:2065, :2077), and the mirrors stage (:2136). Only setPrincipalSlot passes index.retireAt through raw, so applying the same retireAt ?? after(Date.parse(index.updatedAt), options.tombstoneRetentionMs) fallback (and treating a missing slot as a no-op keep rather than corruption) would align it.

What I checked: all current-code writers of revoked indexes set a non-null retireAt (the only writers are removePasskey's revocation and repair's mirror propagation), so this is not reachable from freshly written records — the trigger is pre-retention data. Evidence that such data is anticipated: 0.1.0 shipped "revocation" without the retention field, the PR's own test strips retireAt from stored records to simulate rows that "predate retention fields", and the four fallback sites above exist for exactly this shape. Proof gap: I could not inspect pre-PR history or a production store to confirm revoked pre-retention rows actually exist; the finding stands on the codec's explicit leniency plus the code's own asymmetry, and the PR's legacy-record test only covers the active shape, not the revoked one.

Workflow run

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

Fixed in 6fa28b5: revoked ledger slots now derive a retention fence when an older stored record has no explicit timestamp, and repair reconstructs a missing revoked slot from the credential index. An already-retired record with no mirror remains an idempotent false removal result. Memory and Azurite coverage exercises both retained-record shapes.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OpenRouter pull-request review

Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: 6fa28b569f4ee29e1cc2f8fa808b6592ed15d31a
Judge: openai/gpt-5.6-luna
Cost: $0.1273 (lanes $0.1272 + judge $0.0001)

Lanes

  • meta/muse-spark-1.2: ok (0 finding(s), 30.5s, 114799+3680 tokens (39673 cached), 8 tool round(s), via Meta, $0.12)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 301.8s, 281570+7398 tokens (153472 cached), 18 tool round(s), via Wafer, $0.0117)

Round 5 resolution

  • ✅ r4-1 fixed correctly — setPrincipalSlot writes a codec-invalid revoked slot for revoked credentials that predate retireAt: Fixed in passkeys.ts: setPrincipalSlot now normalizes revoked expiresAt as expiresAt ?? after(Date.parse(index.updatedAt), tombstoneRetentionMs) (line 880-886), writes normalizedExpiresAt to the slot and verifies against it, satisfying decodePasskeySlots invariant (state==="active") !== (expiresAt===null) and expiresAt > updatedAt. Added insertion path for position<0 when `state==="rev…
  • Open findings after this round: 0 (0 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@FlyOverCoderKY
FlyOverCoderKY merged commit 36a0329 into main Nov 6, 2026
5 checks passed
@FlyOverCoderKY
FlyOverCoderKY deleted the claude/passkey-quotas-and-revocation branch November 6, 2026 21:03
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.

1 participant