Skip to content

[Phase 2 / Feature B / B-4] Extension content-world passkey shim + origin verification #48

@gynet

Description

@gynet

Parent: #9. Depends on #46 (B-2).

Scope

Two files, two worlds:

  • `packages/extension/src/content/passkey-shim.ts` — MAIN world (manifest: `world: "MAIN"`, `run_at: "document_start"`). Overrides `navigator.credentials.create` / `.get`. Saves originals before override for fallback.
  • `packages/extension/src/content/content-passkey.ts` — ISOLATED world. Relays between page and background. Reads `window.location.origin` itself (never from page-payload).

Security-critical: origin verification

  • Isolated world sends its own `origin` to background
  • Background cross-checks against `sender.url` from `chrome.runtime.onMessage`
  • Background verifies `rp.id` is a registrable-domain suffix of origin's effective domain (PSL rules — use `psl` npm package; small, audited, no transitive deps)
  • Mismatch → reject with `PASSKEY_RP_MISMATCH`, never forward to core

Fallback policy

Per design §3.2:

  • Vault locked → show "Unlock NeoKeeWeb to use passkey" overlay, wait for unlock, retry
  • No matching entry → ask user: "Use NeoKeeWeb to register new / Use native authenticator / Cancel"
  • User declines NeoKeeWeb path → call saved original method, return its Promise result
  • Spec-compliant timeout handling (respect `options.publicKey.timeout`)

Manifest change

`manifest.json`: register `passkey-shim.ts` as `"world": "MAIN"` content script for `<all_urls>`, `run_at: document_start`. Requires Chromium 111+ / Firefox 128+. Safari — shim is a no-op (by platform).

Acceptance

  • Shim successfully intercepts `navigator.credentials.create/get` on a test fixture page
  • Original methods restored and callable via fallback path
  • Origin verification unit-tested: 20 RP/origin pairs (10 valid, 10 malicious)
  • Timeout handling tested (WebAuthn default 60s, honored if options.timeout set)
  • Passes on Chrome + Firefox manifest versions in CI

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpasskeyPasskey / WebAuthn PRF worksecuritySecurity-related

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions