Skip to content

Security scan: resolve findings (2026-07-29) - #6

Merged
FlyOverCoderKY merged 3 commits into
mainfrom
claude/security-scan-fixes
Jul 30, 2026
Merged

FlyOverCoderKY merged 3 commits into
mainfrom
claude/security-scan-fixes

Conversation

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor

Every finding in docs/securityscan.md was re-read against the implicated code before disposition. No runtime source changed, so the public API and behavior of @pegma/identity are unchanged.

Fixed

Finding Disposition
F-01 — privileged claim-issuing primitives on the public API surface Fixed (docs). The package README now names claimsFor and repairUserByEmail as privileged in exactly the same sense as provisionVerifiedUser, and forbids reaching any of the three from unauthenticated traffic or from a request whose principalId/email comes from user input. Confirmed in code: claimsFor returns VerifiedIdentityClaims for any principalId resolving to an active verified user, with no proof of possession.
F-02 — email change requires no fresh authentication Fixed (docs). Confirmed in code: begin("email_change", …) checks only that the named principal is active and email-verified, and the old address is notified only after effectState: "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 before beginEmailChange; the threat model records the gap, the host obligation, and the bound (retained passkeys).
F-03 — WebAuthn attestation is not verified Fixed (docs). 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.
F-06 — finishAccountCreation doubles as email sign-in Fixed (docs). Confirmed in code: when the verified address already belongs to an active principal, repair() returns that user and finishAccountCreation issues its claims. The README now states this and requires the creation endpoint to carry the same rate limiting, session policy, and anomaly detection as finishEmailSignIn.

Disputed

Finding Reason
F-04 — plaintext email addresses at rest Not a valid finding. A deliverable address cannot be hashed: prepareMail renders to targetEmail/oldEmail and the Mail job's recipientRef, 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).
F-05 — codes are deterministic HMAC outputs, not random Not a valid finding. "Deterministic" describes the derivation, not the guessability. The HMAC input is the digest of a fresh per-operation handle from 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.
F-07 — timing side-channel distinguishes registered credential IDs Not a valid finding. The oracle only confirms a value the attacker already holds and discloses neither a principal nor an account's existence, putting it below the Low bar in this repository's severity calibration. Each probe also costs one beginPasskeyAuthentication challenge 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.1 in the root manifest, packages/identity/package.json, and package-lock.json, plus release notes and the plan status line. The packed dist/ output is unchanged; the patch release exists so consumers receive the corrected package README (README.md is in the packed-file allowlist).

Note

docs/securityscan.md was not Prettier-clean on main (two emphasis markers), so npm run format:check currently 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, and npm run release:check all pass locally on Node 24.18.0.

🤖 Generated with Claude Code

FlyOverCoderKY and others added 2 commits July 29, 2026 20:26
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>
Copilot AI review requested due to automatic review settings July 30, 2026 00:27
@cursor

cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown

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.

@github-actions

github-actions Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Grok Grok Build Review — no issues

Review complete. Nothing actionable to report.

This is a documentation-only patch release (0.1.1) that correctly closes the operator-guidance gaps identified in the 2026-07-28 scan without altering runtime behavior or the public API. Every fixed finding (F-01, F-02, F-03, F-06) is accurate against the implicated code paths, and the three disputes (F-04, F-05, F-07) are technically defensible. Version metadata, release notes, threat-model invariants, and the package README are consistent and ready for the signed-tag release path.

Reviewed commit 9a015c9 · workflow run

Copilot AI 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.

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.md and add 0.1.1 release notes.
  • Bump versions to 0.1.1 in 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.

Comment thread docs/securityscan.md Resolved
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>
@FlyOverCoderKY
FlyOverCoderKY merged commit e5b1766 into main Jul 30, 2026
5 checks passed
@FlyOverCoderKY
FlyOverCoderKY deleted the claude/security-scan-fixes branch July 30, 2026 00:35
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