Skip to content

Consent hardening: take the origin from Chrome's sender, show what is being signed, scope approvals #39

Done

Description

@jjohare

From a re-audit of main at bd39ce8. Hardening items for the NIP-07 consent path, most useful first.

What holds: auto-sign defaults off; approval windows deny on timeout; the popup renders origins with no HTML injection; iframes get neither the provider nor the interceptor; there is no external messaging surface.

  • The service worker trusts message.origin (src/background.js:117, :127-157; stamped at src/injected.js:166). The sidestr path already takes it from sender (pageOrigin, src/background.js:215), though that helper still falls back to the claimed value. Fix: use sender.origin, require sender.frameId === 0, drop message.origin.
  • The signing prompt hides what is signed (src/background.js:362-367). It shows a tag count and the first 200 characters of content. For kind 27235 the meaning is entirely in the u and method tags; for kind 5 and kind 3 it is in which events are deleted or which follows are replaced. Fix: show the tags, scrollable; for 27235 make method and URL the headline.
  • One approval grants everything, with no expiry (src/background.js:316-328, :356-377, :410-417). Approving getPublicKey trusts the origin for every event kind and for NIP-44 encrypt and decrypt. Deliberate since 0.0.8 and disclosed in the prompt (popup/approve.html:151), but worth narrowing: separate scopes for public key, signing (optionally per kind) and decrypt.
  • The opaque origin "null" can be trusted (src/injected.js:166, src/storage.js:162). file:// pages and sandboxed documents all report it. Fix: refuse opaque origins.
  • Unlock is requested before consent (src/background.js:313, :343, :408). An untrusted page can keep opening the unlock window, and can tell "locked" from "no key" by the error text (:285 against :287). Fix: trust check and prompt first, unlock after.
  • No limit on approval windows (src/background.js:607-643). Fix: one pending prompt per origin, and a cool-down after a deny.
  • The key is read before the prompt (src/background.js:345), so locking Podkey while a prompt is open does not stop that signature. Fix: read it after approval.
  • Message classes are open by default. APPROVE_SIGNING has no sender check (src/background.js:53-60), and the unused NIP44_GET_CONVERSATION_KEY handler (src/background.js:156) returns a long-term per-peer key and is guarded only by the content script's allowlist. Fix: delete the dead handler; require an extension-page sender for APPROVE_SIGNING; make the page / extension-UI classification explicit and closed by default.
  • Closed approval windows are detected by beforeunload only (popup/approve.js:70); spends already use chrome.windows.onRemoved. Fails closed after 60 s today.
  • Long origins scroll inside an 84px badge (popup/approve.css:76-92), which can push the registrable domain out of view.

Activity

  1. added
    enhancement
    on Nov 28, 2026
  2. jjohare commented on Nov 28, 2026

    @jjohare
    CollaboratorAuthor

    Addressed in 0.0.12 and 0.0.13 (a2265b7): the asking site comes from Chrome's sender; message types are classified with anything else refused; only the tick-box trusts a site; prompts come one per site with a pause after a no; consent comes before unlock and an unapproved site hears one answer whether Podkey is locked or has no key; the key is read after approval; the approval window keeps the worker alive; long origins wrap; closing the window denies; events are previewed. Approval scopes are #44; what an unapproved site can still learn is in #47.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions