Skip to content

security: remove crypto-browser.js (broken Schnorr leaks private key)#10

Merged
melvincarvalho merged 1 commit into
JavaScriptSolidServer:mainfrom
jjohare:security/remove-crypto-browser-fallback
May 12, 2026
Merged

security: remove crypto-browser.js (broken Schnorr leaks private key)#10
melvincarvalho merged 1 commit into
JavaScriptSolidServer:mainfrom
jjohare:security/remove-crypto-browser-fallback

Conversation

@jjohare
Copy link
Copy Markdown

@jjohare jjohare commented May 12, 2026

Summary

  • Delete src/crypto-browser.js which contains a completely broken cryptographic implementation that leaks private key material through signatures

Security Impact (CRITICAL)

crypto-browser.js implements a fake "Schnorr" signature scheme that is catastrophically broken:

  1. Public key derivation: Uses SHA-256(private_key) instead of secp256k1 elliptic curve scalar multiplication. This means the public key is a simple hash of the private key rather than a computationally irreversible EC point.

  2. Signature construction: Creates signatures as SHA-256(private_key || event_id) duplicated to fill 128 hex characters. Since event IDs are public knowledge, an attacker observing any signature has SHA-256(private_key || known_value) -- this is a known-plaintext scenario that enables offline brute-force recovery of the private key.

  3. No actual Schnorr: Despite the filename, there is no elliptic curve operation anywhere in the file. It is pure SHA-256 hashing.

Current Risk

The file is not imported in the current bundled build -- src/background.js imports from src/crypto.js which correctly uses @noble/secp256k1. However, the file's presence in the source tree is an active hazard:

  • A future package.json "browser" field mapping could silently redirect crypto.js imports to crypto-browser.js
  • A build tool misconfiguration could pick up the wrong file
  • A developer unfamiliar with the codebase could import it directly

Deleting the file eliminates this risk entirely with zero impact on current functionality.

Test plan

  • Verify src/background.js imports from ./crypto.js (not ./crypto-browser.js) -- confirmed
  • Verify no other file references crypto-browser.js -- confirmed via grep
  • Verify package.json has no "browser" field mapping -- confirmed
  • Run npm run build to confirm bundle still works
  • Load extension and verify key generation + signing still work

…rial

crypto-browser.js contained a completely broken "Schnorr" implementation that:
- Derived public keys via SHA-256(private_key) instead of secp256k1 scalar multiplication
- Created "signatures" as SHA-256(private_key || event_id) duplicated to 128 hex chars
- This means signatures contained material directly derived from the private key,
  enabling private key recovery through known-plaintext analysis

While the file is not imported in the current bundled build (background.js imports
from crypto.js which uses @noble/secp256k1), its presence in the source tree is an
active hazard: any future refactor, build configuration change, or browser field
mapping in package.json could silently activate this broken implementation.

The correct implementation lives in src/crypto.js using @noble/secp256k1 with
proper Schnorr signatures per BIP-340 / NIP-01.

Co-Authored-By: claude-flow <ruv@ruv.net>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes an unused browser-side cryptography implementation (src/crypto-browser.js) that is insecure and could be accidentally picked up by future build/bundler configuration, ensuring the extension only relies on the established @noble/secp256k1-based implementation.

Changes:

  • Deleted src/crypto-browser.js to eliminate a hazardous, non-standard “Schnorr” signing implementation.
  • Confirmed no remaining references/imports to crypto-browser.js in the repository (per search).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@melvincarvalho melvincarvalho merged commit cf38142 into JavaScriptSolidServer:main May 12, 2026
4 checks passed
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.

3 participants