Skip to content

Sweep: ship deterministic-nonce fix to master + make TLS verification fail closed #15

Description

@RobGanon

Issue draft — TruthMachine/ElectrumSVP

Title: Sweep: ship deterministic-nonce fix to master + make TLS verification fail closed

Context: Follow-up to closed PR #14 (sweep nonce non-determinism + TLS hostname verification). Two standalone, low-risk changes; neither is currently in a released build.

1. Sweep signing still uses a random nonce in the released build (v0.1.0)
electrumsv/gui/qt/sweep_helper.py signs sweep inputs with ecdsa.SigningKey.sign_digest(...), which falls back to an os.urandom-based nonce when no k is supplied. On a weak/broken RNG, nonce reuse across the multiple inputs a single key signs in a sweep can allow private-key recovery. Every other signing path in the wallet already uses RFC6979 (bitcoinx PrivateKey.sign → libsecp256k1); the sweep path is the only exception.

  • master still has this line today; v0.1.0 AppImage ships it.
  • Your dev branch reportedly already signs sweeps via bitcoinx/libsecp256k1 — please merge that to master and cut a (minor) release. Shipping it is what actually closes the hole for users.

2. ElectrumX fallback effectively disables server authentication
create_ssl_context() sets ctx.check_hostname = False while the socket's trust store includes the full certifi CA set. With hostname checks off and every public CA trusted, a MITM who obtains any public-CA-signed certificate can impersonate an ElectrumX server with no verification failure.

  • I understand the self-signed servers (e.g. CN=electrumr, no SAN for sv2.satoshi.io) fail check_hostname=True as-is — removing the flag alone would break them, as discussed in Fix sweep nonce non-determinism and disabled TLS hostname verification #14.
  • Proposed alternatives that keep current servers working and fail closed:
    1. Load only the server-specific <host>.pem (and skip certifi for these sockets) while keeping check_hostname = True; or
    2. Pin the exact server certificate/fingerprint (TOFU), failing on mismatch. Since this path is a direct TCP/TLS fallback, a dedicated pinned context is the safer design.
    3. Long-term: move servers to CA-issued certs with correct SAN.
  • Impact of the current state is bounded (a MITM can feed wrong/incomplete UTXO data → failed or partial sweeps; it cannot forge signatures or divert funds), but it's below the bar we'd set for a wallet, and worth closing.

What I'd love from you

  • Merge/release the deterministic-nonce sweep signing (item 1).
  • Pick the pinned/fail-closed TLS approach you prefer for item 2 and let us know if you want help validating it.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions