℈Scruple Docs v0.1.0-alpha.1

Security

Security

A practical threat model and hardening checklist for nodes, wallets, miners, and multisig cosigners.

Alpha software

Scruple is mainnet-candidate software. Treat it as alpha: review the code, run the test suite, start with small amounts, and never commit funds you cannot afford to lose. This page describes the current implementation, not a guarantee of safety.

Threat model at a glance

AssetPrimary threatsMain controls
24-word recovery phraseTheft, loss, accidental disclosure, cloud or screenshot copiesOffline paper or metal backup, split from passphrase, regular restore tests
Wallet fileDisk theft, malware, concurrent writers, corruptionEncryption at rest, 0600 permissions, OS lockfile, atomic writes
Node RPCRemote command execution, cookie theft, denial of serviceLocalhost bind, firewall, cookie secrecy, TLS reverse proxy if remote
Peer connectionsEclipse, spoofed heights, malformed frames, traffic analysisSubnet diversity, PoW validation, ban scoring, Dandelion++
Mining payoutsWrong address, lost keys, pool or node compromisePer-block address rotation, wallet-backed payout, encrypted wallet
Multisig vaultCosigner compromise, blind signing, key lossThreshold design, offline signing, independent transaction verification
Chain dataCorruption, deep reorg, insufficient prune depthBackups where needed, conservative prune depth, multiple nodes

RPC hardening

The JSON-RPC listener is plaintext HTTP with a bearer-style cookie. Anyone who can reach the port and read the cookie can query the node, submit transactions, add peers, and start mining. Treat it as an administrative interface.

Bind and firewall

  • Keep --rpc 127.0.0.1:18332 (or the testnet equivalent) on servers and desktops. Do not bind 0.0.0.0 on an untrusted network.
  • If a remote client needs access, terminate TLS in a reverse proxy on the same host and expose only the proxy. Add authentication at the proxy as well; the cookie is not a substitute for network access control.
  • Firewall the RPC port even on a LAN. A compromised laptop on the same network should not reach a node's RPC.
  • The node warns when RPC is bound to a non-loopback address. Do not ignore that warning.
  • <data-dir>/.cookie is created with mode 0600 and contains a fresh 32-byte random token on every node start.
  • Never commit the cookie, paste it into chat, or include it in screenshots. It rotates on restart, but a leaked live token is valid until then.
  • Prefer letting clients read <data-dir>/.cookie over passing a token with --cookie; command-line arguments can appear in shell history and process listings.
  • Do not cache the token across restarts. Re-read the file when a request returns 401.
  • Backups of the data directory should not include the cookie. It is ephemeral and grants live administrative access.

Limit exposure

  • Use a dedicated OS user for the node. Do not run it as root.
  • Keep the host patched and use full-disk encryption where practical.
  • Do not expose the P2P port and the RPC port on the same interface without a firewall rule; P2P is public by design, RPC is not.
  • Monitor info for unexpected peers, bans, or mempool growth. A sudden flood of connections can be a denial-of-service attempt.

Wallet secrecy and backups

The recovery phrase is the wallet

A 24-word BIP-39 phrase deterministically regenerates every receive and change key. Anyone with the phrase can spend every coin at every derived index. The wallet file is a convenience, not the ultimate backup.

  • Write the phrase on paper or metal before receiving or mining coins.
  • Store it offline, in a location you control. Do not use cloud notes, email drafts, password managers synced to the cloud, clipboard history, or screenshots.
  • Do not store the phrase and the wallet passphrase in the same place. Two factors in one location are one factor.
  • Test recovery on a separate machine before you rely on the backup. A backup you have never restored is a hope, not a backup.
  • If you suspect disclosure, create a new wallet and sweep the funds. Changing the passphrase does not change the derived keys.

Encryption at rest

Use --encrypt when creating a wallet, or set SCRUPLE_PASSPHRASE for non-interactive runs. The encrypted envelope uses Argon2id with m=19,456 KiB, t=2, p=1, a 16-byte salt, and ChaCha20-Poly1305 with a 12-byte nonce. Secret material is zeroized on drop.

  • Argon2id slows guessing, but it cannot rescue a weak passphrase. Use a long, unique passphrase or a diceware-style phrase.
  • Avoid --passphrase on the command line: shell history, process listings, and terminal scrollback can capture it. Prefer the interactive prompt or SCRUPLE_PASSPHRASE.
  • Encryption protects a stolen disk or backup file. It does not protect against malware running as your user while the wallet is unlocked.
  • The wallet file is written atomically with mode 0600. Keep it on a filesystem with sensible permissions and backups.

Bring-your-own entropy

BYOE modes let you mix dice rolls, coin flips, hex, or text into seed generation. By default, 32 bytes of OS randomness are mixed in as well. --no-mix-os-rng requires a strong input: at least 99 dice rolls or 256 coin flips. Weak or biased entropy can silently reduce the search space.

HD gap limit and rescans

Receive addresses use even indices and change addresses use odd indices. The default gap limit is 20. A rescan checks both the UTXO set and the ever-seen address index, so spent addresses are still discovered. On a pruned node, the ever-seen index survives pruning, but confirmed history for old blocks may not be reconstructible.

Lockfiles and concurrent access

Mutating or signing commands and the GUI take an exclusive OS advisory lock on <wallet>.lock (mode 0600). The lock is released automatically on normal exit or crash, so a leftover lock file does not mean the wallet is still open.

  • If you see wallet file ... is already open in another process, close the GUI or the other CLI process. Do not delete the lock file while a process is running.
  • The lock prevents two processes from reusing the same HD index or overwriting each other's changes. It is not a consensus lock and does not protect against copying the wallet file to another machine and using both copies.
  • Do not run the same wallet from two machines at once. Index reuse and conflicting spends are still possible across copies.

Pending outgoing locks

When the wallet broadcasts a transaction, it records the spent outpoints as pending and excludes them from future coin selection until confirmation. wallet clear-pending removes those locks and pending raw transactions. Only use it when you are certain the original transaction is dead; clearing a live transaction can lead to a double-spend attempt and confusing wallet state.

Pruning, reorgs, and storage

  • --prune <N> keeps the most recent N full blocks (minimum 288) plus all headers, the active UTXO set, and the ever-seen address index. It discards older block bodies and undo logs.
  • A pruned node cannot reorg deeper than its prune window. For production mining or wallet nodes, use N >= 1000 or archive mode.
  • --txindex maintains a persistent txid index for confirmed lookups. It is mutually exclusive with pruning because pruned nodes discard the historical block bodies needed to build the index.
  • Chain data is reproducible from the network. Wallet files, recovery phrases, and multisig key shares are not. Back up the wallet, not the chain.
  • If the database is corrupted, stop the node before deleting anything. Rebuilding from peers is possible but may take time; a wallet rescan is separate from chain sync.

Peer privacy and network attacks

P2P is unauthenticated and unencrypted

Peer frames are plaintext TCP. A network observer can see peer IPs, block and transaction propagation, and traffic volume. Dandelion++ reduces the link between the originating IP and a transaction, but it is not anonymity software.

  • Use a VPN or Tor at the network layer if peer-IP privacy matters. Scruple does not include a built-in anonymity network.
  • fast_fluff bypasses the stem phase and makes the origin easier to correlate. Use it only when 0-conf latency matters more than privacy.
  • Transaction contents are public once broadcast. Addresses and amounts are visible on-chain; there are no confidential amounts.

Eclipse and spoofing

  • Outbound subnet diversity limits how many peers an attacker can occupy from one /16 or /32. Explicit peers bypass diversity, so only add peers you trust.
  • Headers are validated for PoW, difficulty, timestamps, and version before blocks are fetched. A peer cannot make an invalid chain valid by claiming a higher height.
  • Compare tips across independent nodes or the block explorer if you suspect an eclipse. A node with zero peers cannot learn the network tip.
  • Bans are local and expire after one hour. They are a DoS mitigation, not a global reputation system.

External address advertisement

--external-addr must be a numeric IP:port. Peer gossip rejects non-numeric hostnames to prevent SSRF and DNS amplification. Advertising a DNS name is not supported. The advertised address is also treated as self during dial checks, which prevents a VPS from connecting to itself.

DNS seeds

Built-in DNS seeds are convenient bootstrap points, not trust anchors. If DNS is poisoned or the seeds are unavailable, the node may start isolated. Use explicit --seed or --peer entries you trust, and verify the chain tip independently. --no-dns-seeds is appropriate for private LANs and air-gapped test setups.

Mining security

  • Mine to a wallet you control, not a raw address you cannot spend from. scruple mine --wallet rotates to the next unused receive address per block and labels the coin.
  • An encrypted wallet still needs the passphrase available to the miner. Run the miner on a dedicated, hardened host and limit who can read its environment and process memory.
  • Verify the payout address before starting a long mining session. A typo in a legacy hex address is unrecoverable; use Bech32m.
  • Mining to an xsl2: vault is supported, but spending the reward requires the multisig ceremony. Coinbase maturity still applies.
  • A stale template wastes hashpower. The continuous miner watches the tip every two seconds and cancels stale work; long synchronous RPC mine calls do not have the same responsiveness.

Multisig security

Native xsl2: vaults remove the script VM from the trust path, but the human process is still the weak point.

  • Choose a threshold that matches your failure model. 2-of-3 protects against one lost or compromised key; 3-of-5 may suit an organisation.
  • Generate cosigner keys on separate machines. Do not derive all cosigner keys from one seed or store all shares on one disk.
  • Back up each cosigner's recovery phrase independently. Losing more than N - M keys makes the vault unspendable.
  • Sign only after independently verifying the transaction: recipient, amount, fee, change address, and the exact PartialTx digest. A malicious coordinator can otherwise present a different spend.
  • Verify the vault address out-of-band. A swapped public key or address changes the vault and can redirect funds.
  • Finalisation verifies threshold signatures before assembling the transaction. Still inspect the final raw transaction or txid before broadcasting.
  • Offline signing is only as safe as the machine that builds the unsigned transaction and the machine that broadcasts it. Keep the signing host minimal and disconnected when not in use.

0-conf acceptance

Ownership-Proven FSS-RBF protects recipient outputs: a fee bump cannot reduce, redirect, or remove a merchant's output without a signature from that recipient. Double-spend proofs expose unauthorised conflicts to the network. These are strong mitigations, but 0-conf is still not finality.

  • For low-value retail, accept 0-conf with a double-spend proof check and a sensible fee policy.
  • For high-value payments, wait for confirmations. A miner can include a conflicting transaction, and a network partition can hide a proof.
  • Do not treat the absence of a proof as proof of honesty. It only means no conflicting spend has been observed by your node.
  • Use fast_fluff for point-of-sale so the transaction reaches the network immediately.

Supply chain and build integrity

  • Build from a reviewed commit and keep the toolchain and dependencies up to date.
  • Run cargo test --release --workspace before deploying a new binary.
  • Pin or audit dependencies where possible. A compromised crate can steal keys or alter transaction construction.
  • Verify release binaries against a known hash or build reproducibly where practical.
  • Do not run a GUI or CLI downloaded from an unofficial source with a funded wallet.

Operational checklist

AreaCheck
WalletRecovery phrase written offline; passphrase stored separately; restore tested; wallet file encrypted and 0600.
RPCBound to localhost; firewall closed; cookie not in shell history or screenshots; TLS proxy if remote.
NodeDedicated user; disk encryption; patched OS; data directory permissions reviewed; logs protected.
NetworkNumeric --external-addr; trusted explicit peers only; DNS seeds understood; tip verified independently.
StoragePrune depth at least 1,000 for production; no prune with --txindex; free space monitored.
MiningPayout wallet verified; encrypted wallet; dedicated host; stale-tip watcher enabled.
MultisigKeys on separate machines; independent transaction verification; threshold and backups documented.
Payments0-conf limits defined; confirmations required for high value; dsproof monitoring enabled.

What is not protected

  • Compromised endpoints. Malware with access to your user session can read an unlocked wallet, log keystrokes, or replace addresses in the clipboard.
  • Social engineering. No cryptographic control prevents you from sending coins to an attacker's address.
  • Chain-level privacy. Amounts and addresses are public. Dandelion++ is not a mixer.
  • Lost keys. There is no custodian, recovery service, or admin key. Lost recovery phrases mean lost funds.
  • Deep reorgs beyond the prune window. A pruned node may not be able to follow a very deep reorg; archive nodes are safer for high-value services.
  • Quantum attacks on the whole stack. SQIsign addresses the signature layer, but wallet software, operating systems, and RandomX implementations still need their own review.

Scruple Docs · v0.1.0-alpha.1 · Mainnet candidate

Scruple is alpha software. Verify commands against --help and the protocol specification before relying on them.