Repository navigation
Bound passkey lifecycle storage - #10
Conversation
|
OpenRouter review posted ( |
Codex Review SummaryThis 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. |
There was a problem hiding this comment.
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.
| existing: readonly PasskeySlot[], | ||
| ): Promise<readonly PasskeySlot[]> { | ||
| const slots = [...existing]; | ||
| const mirrors = await passkeys.list(passkeyPartition(principalDigest)); |
There was a problem hiding this comment.
🟠 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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
🔴 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.
There was a problem hiding this comment.
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.
| @@ -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", () => { | |||
There was a problem hiding this comment.
🔵 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.
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
🔵 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.
There was a problem hiding this comment.
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.
|
OpenRouter ledger follow-up for
The remaining inline items have replies with repository-contract or stored-state evidence and remain open for maintainer visibility. |
There was a problem hiding this comment.
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-3fixed correctly — Removal success requires exactretireAtequality, breaking legacy tombstones: Legacy-tombstone removal now converges:removePasskeycreates a newretireAtandrepaircopies it to the mirror, then verifiesmirror.retireAt === confirmed.retireAton the newly written values. Verification added by testremoves an active credential whose stored records predate retention fieldswhich stripsretireAtfrom bothcredentialIndexesCollectionandpasskeysCollectionbefo… - ✅
r1-1fixed correctly — Passkey sweep aborts on malformed storage rows instead of isolating them:sweepPasskeys()no longer aborts on a single corrupt row. Diff introducespasskeyScanCollection/passkeyScanPage/decodePasskeyScanRecordsafe wrappers and per-rowtry/catch { rejected+=1; continue }in all four stages (proofs1952-1978,indexes2031-2053,mirrors2124,principals2176), returningrejectedandnextCursorso callers can advance. Covered by test `retains malforme… - 🤝
r1-2disputed — Principal capacity check depends on completelistenumeration which may paginate: Disputed as relying on a contract violation rather than a defect in this PR.@pegma/storage-coreexposesscanas 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 publiclistPasskeysandbeginRegistration's `excludeCredenti… - ✅
r1-4fixed correctly — Slot merge retains stalereservedinstead of newerrevoked/activemirror: Stalereservedvs neweractive/revokedreconciliation fixed.mergedPrincipalSlotsnow loads thecredentialIndexfor a mismatchedregistrationIdand, if the mirror'sregistrationIdmatches an active/non-reserved index for the same principal, adopts the mirror (slots[pos]=next), and if the current slot's index is stillreservedkeeps it; otherwise throwsstorage_corrupt. Verified… - ❌
r1-8not fixed — Critical transactional atomicity violation in finishRegistration: No change tofinishRegistrationatomicity.passkeys.ts:1363-1384still doesstored = await persistCredential(...); await challengeService.consumeClaim(claim)inside the same try. IfconsumeClaimthrows (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-9disputed — 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-runningrepair… - 🤝
r1-10disputed — Critical error masking during challenge sweep: Disputed — the claimed mechanism does not exist. Thecatchat challenges.ts:~523 wraps onlyscanRecord(rawRow)andchallengesCollection.codec.decode(...)(synchronous, in-memory validation of an already-fetched row) plus the key-agreement check; it contains no storage operations. Failures fromscanCollection.scan(before the loop) and fromcollection.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).
|
Fixed in |
There was a problem hiding this comment.
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-8fixed correctly — Critical transactional atomicity violation in finishRegistration: Commit 142ae80 movesconsumeClaimoutside the credential-persistencetryand makes it best-effort withtry{consume} catch{}; credential is returned as durable if persist succeeds. Threat model updated to documentverifyingremains single-flight and is expiry-collected. New testreturns a durable registration when final challenge cleanup is interruptedforces aconsumed-write failure vi… - Open findings after this round: 0 (0 bug-severity).
No structured findings from the successful lane(s).
There was a problem hiding this comment.
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.
|
Fixed in |
There was a problem hiding this comment.
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-1fixed correctly —setPrincipalSlotwrites a codec-invalid revoked slot for revoked credentials that predateretireAt: Fixed in passkeys.ts: setPrincipalSlot now normalizes revoked expiresAt asexpiresAt ?? after(Date.parse(index.updatedAt), tombstoneRetentionMs)(line 880-886), writesnormalizedExpiresAtto the slot and verifies against it, satisfyingdecodePasskeySlotsinvariant(state==="active") !== (expiresAt===null)andexpiresAt > updatedAt. Added insertion path forposition<0when `state==="rev… - Open findings after this round: 0 (0 bug-severity).
No structured findings from the successful lane(s).
Summary
Validation
CI=1 pnpm run format:checkCI=1 pnpm run checkCI=1 pnpm testCI=1 pnpm audit --prod --audit-level=high