Skip to content

Commit 30e54ca

Browse files
committed
docs: Cover CLI restore identity gate
1 parent 3bc520a commit 30e54ca

3 files changed

Lines changed: 33 additions & 26 deletions

File tree

‎docs/security/audit-2026-09-22.md‎

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,37 @@ Tracking: [#22](https://github.com/BenWestgate/python-codex32/issues/22).
6262
and correction candidates.
6363
- Confidence: high.
6464

65-
### Medium — GUI verifies recovered wallet identity after mutation
66-
67-
Tracking: issue draft pending publication.
68-
69-
- Affected component: `src/codex32_gui/pages.py` recovery path and
70-
`wallet_setup.fill`/`initialize`.
71-
- Failure scenario: after recovery, `_record()` calls `wallet_setup.fill(...)`
72-
before it computes and displays the master fingerprint. The restore flow then
73-
asks the user to compare the fingerprint on the finished page. A wrong but
74-
checksum-valid recovered seed therefore imports private descriptors into the
75-
selected empty Bitcoin Core wallet before the operator is shown the identity
76-
check.
65+
### Medium — wallet restore verifies recovered identity after mutation
66+
67+
Tracking: GUI issue #26; CLI issue #30.
68+
69+
- Affected component: GUI recovery in `src/codex32_gui/pages.py`, CLI recovery
70+
in `src/codex32/cli.py`, and the shared mutating wallet initialization path.
71+
- Failure scenario: both supported restore front ends mutate Core before the
72+
recovered wallet identity is checked. The GUI calls `wallet_setup.fill(...)`
73+
before it computes and displays the identity. `ms32 wallet` calls
74+
`core.initialize(...)` before displaying the recovered fingerprint. A wrong
75+
but checksum-valid recovered seed can therefore import private descriptors
76+
into the selected empty Bitcoin Core wallet before the operator can detect
77+
the mismatch.
7778
- Property violated: recovery identity must be authenticated before recovered
7879
key material changes durable wallet state.
7980
- Exploitability: practical. It can be triggered by operator mixing of distinct
8081
share sets, malicious share substitution, or any other path yielding a valid
8182
but unintended seed.
82-
- Remediation: derive a recovery identity without importing descriptors, require
83-
the operator to verify it against an independent wallet record, and only then
84-
call the mutating wallet initialization path.
85-
- Confidence: high. Reconfirmed against both the Bails-pinned GUI commit and the
86-
current GUI descendant.
83+
- Remediation: on every restore path, derive a recovery identity without
84+
importing descriptors, require the operator to verify it against an
85+
independent wallet record, and only then call the mutating wallet
86+
initialization path.
87+
- Confidence: high. Reconfirmed against the Bails-pinned GUI commit, the current
88+
GUI descendant, and the supported `ms32 wallet` CLI path.
8789

8890
### Medium design concern — 32-bit fingerprint is too weak as an active recovery gate
8991

90-
Tracking: issue draft pending publication.
92+
Tracking: issue #27.
9193

92-
- Affected component: GUI wallet record/recovery identity design.
94+
- Affected component: wallet record/recovery identity design across restore
95+
front ends.
9396
- Failure scenario: even if the ordering above is fixed, the current wallet
9497
identity is only the four-byte BIP32 master fingerprint. An active adversary
9598
able to search candidate seeds can target a 32-bit value; accidental
@@ -147,7 +150,7 @@ and is not a security finding. It must not be cited or tracked as one.
147150

148151
## Required recovery invariant
149152

150-
For any wallet GUI built on python-codex32:
153+
For every wallet restore path built on python-codex32:
151154

152155
> Parsing, checksum validity, threshold reconstruction, and the BIP32
153156
> fingerprint are not authorization to mutate a wallet. A recovered seed must

‎docs/security/invariants.md‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@ and evidence.
2828
Private descriptors exist only in Python memory and child stdin.
2929
7. Bitcoin Core chains are discovered before entropy or recovery input. The
3030
operator confirms an eligible descriptor wallet by exact name.
31-
8. Wallet state is revalidated before import. Every import must succeed and the
31+
8. A recovered seed must match an independently stored public recovery
32+
commitment before any restore path mutates a wallet. The four-byte BIP32
33+
fingerprint is diagnostic metadata, not authorization.
34+
9. Wallet state is revalidated before import. Every import must succeed and the
3235
exact accepted public descriptor set must match.
33-
9. codex32 has no passphrase channel. An unlocked encrypted signer is relocked
36+
10. codex32 has no passphrase channel. An unlocked encrypted signer is relocked
3437
and verified on every exit path.
35-
10. External text, Core output, public wallet data, and PSBTs are untrusted.
36-
11. Only Bitcoin Core descriptor wallets sign with codex32-derived keys.
38+
11. External text, Core output, public wallet data, and PSBTs are untrusted.
39+
12. Only Bitcoin Core descriptor wallets sign with codex32-derived keys.
3740
Sensitive operations use only codex32 or Core on malware-free computers
3841
with trusted software.
39-
12. Offline hosts disable every network path, including Ethernet, internet,
42+
13. Offline hosts disable every network path, including Ethernet, internet,
4043
Tor, Wi-Fi, Bluetooth, and cellular. Online Core nodes synchronize before
4144
their balances or history are trusted.
4245

‎docs/security/model.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,10 @@ signing setup belong to Bitcoin Core's maintained v32 workflow.
226226
| Preflight | Before entropy or recovery input, explicit chain arguments probe the five standard local networks for Bitcoin Core 32 or newer. One response is selected automatically; multiple responses require operator selection. |
227227
| Process boundary | codex32 invokes the reviewed `bitcoin-cli` from `PATH` as a child without a shell, direct RPC socket, wallet database, or wallet-creation operation. Every call uses loopback and the selected chain. |
228228
| Destination | Only an empty descriptor wallet with private keys enabled, no external signer, transactions, descriptors, keypool entries, or active scan is eligible. One eligible wallet is offered directly; multiple wallets are selected by number. New wallets are detected by polling, and rejection returns to every eligible wallet. The escaped name is confirmed exactly. |
229+
| Recovery authorization | A restore must derive the recovered wallet's independent public recovery commitment without importing descriptors and require an exact match with the separately stored wallet record before any wallet mutation. The four-byte BIP32 fingerprint is diagnostic metadata, not authorization. |
229230
| Seed source | The original ceremony result or validated recovered master seed supplies root-xprv private descriptors for Core's reported chain. After import, Core v32's wallet HD-key RPCs derive the requested BIP44, BIP49, BIP84, and BIP86 account xpubs. |
230231
| Secret channel | Private descriptor JSON is sent only through the child's standard input. It is absent from arguments, ordinary output, and diagnostics. codex32 has no passphrase channel and suppresses raw Core errors. |
231-
| Revalidation | Every destination property is checked again immediately before import. Every private import must succeed before public verification begins. `gethdkeys` must expose one private wallet root; `derivehdkey` must return the requested hardened account paths with one consistent fingerprint and the correct network xpub/tpub version. `getdescriptorinfo` then validates and expands the fixed public templates, and the exact eight active descriptors must match Core's accepted set. |
232+
| Revalidation | Every destination property is checked again immediately before import. Every private import must succeed before post-import public verification begins. `gethdkeys` must expose one private wallet root; `derivehdkey` must return the requested hardened account paths with one consistent fingerprint and the correct network xpub/tpub version. `getdescriptorinfo` then validates and expands the fixed public templates, and the exact eight active descriptors must match Core's accepted set. |
232233
| Relocking | Once Core reports an encrypted private-key wallet unlocked, a `finally`-protected obligation requests `walletlock` and verifies the locked state after success, failure, state change, or interruption. |
233234

234235
The unlock command is entered in Bitcoin-Qt. Its

0 commit comments

Comments
 (0)