What changed, and why it matters
This commit fixes a missing safety check in the Ledger Bitcoin app's wallet policy parser. When reading a 'thresh(...)' policy (a multi-signature rule like '2 of 3 signatures needed'), the app now verifies that the required number of signatures (k) is not greater than the total number of available signers (n). Without this check, a malformed policy could ask for more signatures than keys exist, which could lead to an unusable or non-standard wallet policy being accepted by the device.
Treat as a low-to-moderate security hardening fix. Review whether other policy types have similar missing bounds checks, and ensure the change is included in the next firmware release. No immediate incident response is indicated unless an exploit path is demonstrated.
Security signals we found
Missing input validation on parsed threshold parameters
Potential acceptance of malformed or nonsensical wallet policies
Validation gap in a cryptographic policy parser
Evidence from the diff
In src/common/wallet.c, the parse_script function parses Miniscript-style ‘thresh(k, X1, …, Xn)’ wallet policies. Previously, after parsing k and the n sub-expressions, the code did not validate that k <= n. The patch adds an explicit check: if node->k > node->n, parsing fails with an error. This prevents internally inconsistent threshold policies from being processed further.
Changed components
src/common/wallet.cparse_script functionthresh policy parsingInspect captured patch +4 / −0
diff --git a/src/common/wallet.c b/src/common/wallet.c
index c8d005f..bb6b8f3 100644
--- a/src/common/wallet.c
+++ b/src/common/wallet.c
@@ -1477,6 +1477,10 @@ static int parse_script(buffer_t *in_buf,
}
}
+ if (node->k > node->n) {
+ return WITH_ERROR(-1, "thresh: k exceeds n");
+ }
+
// thresh(k, X1, ..., Xn)
// X1 is Bdu; others are Wdu
Why this scored 59/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.