Joey (NostrComments)'s avatar
Joey (NostrComments)
slurpnc@coinos.io
npub1ewxm...ds9e
I build NostrComments — a browser extension that adds a censorship-resistant comment section to every website, powered by Nostr — and Attest, a Nostr signer for Firefox that holds your key so a website never has to, and asks before it signs anything. Free and open source, always. NostrComments for Firefox: https://addons.mozilla.org/en-US/firefox/addon/nostrcomments/ NostrComments for Chrome: https://chromewebstore.google.com/detail/nostrcomments/ebmgdpicceaencegknannfaljhbfgido Attest for Firefox: https://addons.mozilla.org/firefox/addon/attest/ Monero: 87aDTPD9HQx2QenKsS7MvHDdqsziFPD7UB37X6G5XVXc2ZPhAs8DdEKUPYJijVcRjj1gU5KvxLCTfWUKWqrd1D5o8uw5EpM
If your extension puts a private key in the DOM, a script on the page can read it. I found this in my own, so this is not a hypothetical. The panel lives in a shadow root. Shadow roots feel private, and they are not: {mode:"open"} means any script on the page reaches it with host.shadowRoot. Mine filled the key field the moment Settings was opened — not when the key was revealed — and never cleared it. Open Settings once and the key sat there, readable, for the rest of the page's life. It also survived deleting the identity. "Show private key" would hand back the key you had just destroyed. Two more of the same shape, once I went looking: the password typed to encrypt the key was blanked when its dialog opened rather than when it closed, and a pasted nsec stayed in the import field after cancelling. The fix is not a closed shadow root. A page script that runs before yours can hook Element.prototype.attachShadow and keep the reference anyway. The fix is that the secret is never in the DOM: hold it in the content script's own world, put it in the input only while it is on screen, clear it on hide. I demonstrated it from page context before fixing it, then wrote a test that does the same, so it stays fixed.
If you're implementing NIP-09 deletion in a Nostr client, there's one check that's easy to miss: A kind 5 only counts when it's signed by the author of the event it targets. Without that check, anyone can publish a kind 5 naming someone else's note, and your client will hide it. You've built a censorship button and handed it to everyone. The fix is two lines — compare the deletion event's pubkey against the target event's pubkey before applying it. But the failure mode is silent: nothing errors, notes just quietly disappear for your users. Ran into this adding deletion to NostrComments. Ended up writing a test for it rather than trusting a careful reading.
↑