Repository navigation
Security scan: resolve findings (2026-07-29) - #6
Conversation
Re-read every 2026-07-28 scan finding against the implicated code. F-01, F-02, F-03, and F-06 were real operator-guidance gaps and are closed without touching runtime source or the public API: - the package README names claimsFor and repairUserByEmail as privileged alongside provisionVerifiedUser, and forbids reaching any of the three from unauthenticated traffic or user-supplied identifiers; - it states that finishAccountCreation authenticates existing accounts, so the creation endpoint needs sign-in-grade policy; - it requires hosts to authenticate the email-change endpoint for the named principal and to demand a fresh passkey assertion before beginEmailChange; - the threat model records the email-change freshness obligation and the deliberate absence of attestation verification as explicit invariants. F-04, F-05, and F-07 are disputed as non-findings with reasoning recorded on each item: a deliverable address cannot be hashed, HMAC-derived codes are PRF outputs over a random per-operation handle, and credential IDs are non-secret by the threat model. Also normalizes the pre-existing Prettier emphasis style in docs/securityscan.md so format:check passes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Documentation-only patch release. The packed dist/ output is unchanged from 0.1.0; the release exists so consumers receive the corrected package README with the host-obligation guidance from the security scan dispositions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
There was a problem hiding this comment.
Pull request overview
Updates security-scan dispositions and host-facing guidance for @pegma/identity, and prepares a documentation-only patch release (0.1.1) so consumers receive the corrected package README without changing runtime behavior or the public API.
Changes:
- Document privileged API surface and host obligations (creation-as-sign-in, email-change step-up, attestation posture) across the package README and threat model.
- Record scan dispositions in
docs/securityscan.mdand add0.1.1release notes. - Bump versions to
0.1.1in manifests/lockfile for the documentation-only patch release.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/identity/README.md | Adds explicit host guidance for privileged methods, creation-as-sign-in, and email-change step-up requirements. |
| packages/identity/package.json | Bumps @pegma/identity version to 0.1.1. |
| package.json | Bumps workspace version to 0.1.1. |
| package-lock.json | Updates lockfile versions to 0.1.1 for the workspace and identity package. |
| docs/THREAT_MODEL.md | Records attestation “none” and email-change freshness as explicit invariants/host obligations. |
| docs/securityscan.md | Updates scan log with resolutions/disputes and adds a disposition review section. |
| docs/RELEASE_NOTES.md | Adds 0.1.1 notes describing documentation-only security guidance changes. |
| docs/PROJECT_PLAN.md | Notes 0.1.1 as a documentation-only patch closing the security scan’s guidance findings. |
Comments suppressed due to low confidence (1)
docs/securityscan.md:31
- F-02 is marked "Status: Open" but then immediately marked as resolved by documentation and notes that the threat-model invariant was added. Updating the Status/Recommendation lines will keep the finding consistent with the disposition below.
- **Status:** Open — design tradeoff, partially mitigated
- **Evidence:** `begin("email_change", ...)` (`packages/identity/src/email-codes.ts:302-322`) requires only that the principal is active + email-verified. Proof of control of the **new** inbox (`finishEmailChange`) completes the change; the old address receives `old-address-notification` only after `effectState: "complete"` (`packages/identity/src/email-codes.ts:604-619`, `803-870`).
- **Exploitability:** An attacker holding a hijacked session (sessions are out of component scope) can redirect email-code sign-in and recovery to an inbox they control. Bounded by: passkeys remain bound to the principal (victim retains passkey sign-in and can revert), and the old-address notification is a detective control.
- **Recommendation:** Host guidance to require a fresh passkey assertion before `beginEmailChange`; confirm coverage in `docs/THREAT_MODEL.md`.
- ✅ Resolved 2026-07-29 — README now requires hosts to authenticate the change endpoint for the named principal and to demand a fresh passkey assertion before `beginEmailChange`; the freshness gap and its bound are recorded as an invariant in `docs/THREAT_MODEL.md`. No code change: the component owns no session, so freshness is not observable here.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot review: the F-01 status still cited pre-change README line numbers and a residual gap this PR closes, and F-02 still read "Open" directly above its resolution line. Each status now states the current disposition while keeping the scan-time observation as history; F-03 and F-06 get the same treatment for consistency. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Every finding in
docs/securityscan.mdwas re-read against the implicated code before disposition. No runtime source changed, so the public API and behavior of@pegma/identityare unchanged.Fixed
claimsForandrepairUserByEmailas privileged in exactly the same sense asprovisionVerifiedUser, and forbids reaching any of the three from unauthenticated traffic or from a request whoseprincipalId/email comes from user input. Confirmed in code:claimsForreturnsVerifiedIdentityClaimsfor anyprincipalIdresolving to an active verified user, with no proof of possession.begin("email_change", …)checks only that the named principal is active and email-verified, and the old address is notified only aftereffectState: "complete". The component owns no session, so freshness is not observable here — the correct fix is host guidance. The README now requires hosts to authenticate the change endpoint for the named principal and to require a fresh passkey assertion beforebeginEmailChange; the threat model records the gap, the host obligation, and the bound (retained passkeys).attestationType: "none"is the correct default for consumer passkeys, but the acceptance was unrecorded. It is now an explicit threat-model invariant, including that software passkeys are accepted and that hosts needing hardware-bound keys cannot get that assurance here.finishAccountCreationdoubles as email sign-inrepair()returns that user andfinishAccountCreationissues its claims. The README now states this and requires the creation endpoint to carry the same rate limiting, session policy, and anomaly detection asfinishEmailSignIn.Disputed
prepareMailrenders totargetEmail/oldEmailand the Mail job'srecipientRef, so a recoverable address is a functional requirement of asynchronous delivery. Lookup and uniqueness already run on domain-separated digests, the threat model treats email as attacker-knowable contact data, and at-rest confidentiality belongs to the storage adapter and operator (trust boundary 4).newId()(crypto.randomUUID()by default, 122 bits), so each code is a PRF output over a random input — uniformly distributed and unpredictable without the key, the same guarantee a CSPRNG code gives. Determinism is required so an async Mail worker can render a code that was never stored. The key-compromise dependency is inherent to any keyed scheme and is already an explicit invariant with a documented rotation procedure.beginPasskeyAuthenticationchallenge under the authentication limiter. Equalizing would require a synthetic signature verification against a fabricated public key on every unknown credential — attacker-triggerable CPU cost and a new failure mode to protect a value the threat model declares non-secret.Release preparation
0.1.0→0.1.1in the root manifest,packages/identity/package.json, andpackage-lock.json, plus release notes and the plan status line. The packeddist/output is unchanged; the patch release exists so consumers receive the corrected package README (README.mdis in the packed-file allowlist).Note
docs/securityscan.mdwas not Prettier-clean onmain(two emphasis markers), sonpm run format:checkcurrently fails there. Since this PR edits that file, the normalization is included here.Gate
npm ci,npm run format:check,npm run check,npm test(150 vitest + 2 node tests, real Azurite),npm audit --omit=dev --audit-level=high, andnpm run release:checkall pass locally on Node 24.18.0.🤖 Generated with Claude Code