psbt: fix a (harmless) off-by-one assert check
What changed, and why it matters
This commit fixes a boundary check in code that walks through parts of a Bitcoin transaction (PSBT). The old check allowed an index equal to the number of items, which is one too high. The commit message calls it 'harmless,' meaning it should not cause a real security problem in practice. It is a defensive correction to an assert that guards internal iteration.
Accept the patch as a hardening fix; no urgent security response is required based on the diff and commit message. If PSBT parsing is exposed to untrusted data, review callers to ensure index is never computed from attacker-controlled values without prior validation.
Security signals we found
off-by-one in bounds assertion
assert-only failure path (abort on violation)
vendor self-described as harmless
Evidence from the diff
In main/utils/psbt.c, key_iter_init() validates an index before iterating PSBT inputs or outputs. The original assertion used <=, allowing index to equal num_inputs/num_outputs, which is an out-of-range value for array-style access. The patch changes it to <. Because this is an assertion, a bad index would abort the process rather than be exploited, and the commit author labels it harmless. No memory corruption path is visible in the diff.
Changed components
main/utils/psbt.ckey_iter_init()PSBT input/output iterationInspect captured patch +1 / −1
diff --git a/main/utils/psbt.c b/main/utils/psbt.c
index 19f18a7..5c0addf 100644
--- a/main/utils/psbt.c
+++ b/main/utils/psbt.c
@@ -37,7 +37,7 @@ static bool key_iter_init(
const struct wally_psbt* psbt, const size_t index, const bool is_input, const bool is_private, key_iter* iter)
{
JADE_ASSERT(psbt);
- JADE_ASSERT(index <= (is_input ? psbt->num_inputs : psbt->num_outputs));
+ JADE_ASSERT(index < (is_input ? psbt->num_inputs : psbt->num_outputs));
JADE_ASSERT(iter);
iter->psbt = psbt;
iter->index = index;
Why this scored 18/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.