psbt: check output amount presence before reading
What changed, and why it matters
This commit tightens how Blockstream Jade reads output amounts from a Partially Signed Bitcoin Transaction (PSBT). Before, the code tried to read the amount directly without first confirming it was actually present. Now it checks whether the amount exists before reading it. This is a defensive hardening change that could prevent incorrect handling of missing or malformed PSBT output data during transaction signing.
Treat as a low-to-moderate hardening fix. Review whether other PSBT fields (asset, blinding key, etc.) are similarly checked for presence before being read, and assess whether missing output amounts can reach downstream logic that depends on outinfo->value or the OUTPUT_FLAG_* flags. No immediate emergency response is indicated by the diff alone.
Security signals we found
Missing-field check added before sensitive value read
PSBT output amount parsing hardened
Defensive validation of libwally presence flags
Evidence from the diff
In main/process/sign_psbt.c, the psbt_update_outputs function previously called wally_psbt_get_output_amount unconditionally. The patch adds a preceding call to wally_psbt_has_output_amount, requiring it to return WALLY_OK and set written to a non-zero value before the amount is read. This prevents reading an absent output amount and avoids relying on the get call’s behavior when the field is missing. The change is small and localized, and appears to be a hardening fix rather than a complete mitigation for a known exploit chain.
Changed components
main/process/sign_psbt.cPSBT output processing pathTransaction signing flowInspect captured patch +2 / −1
### main/process/sign_psbt.c
@@ -527,7 +527,8 @@ static bool psbt_update_outputs(const network_t network_id, struct wally_psbt* p
outinfo->flags |= OUTPUT_FLAG_HAS_BLINDING_KEY;
}
- if (wally_psbt_get_output_amount(psbt, index, &outinfo->value) == WALLY_OK
+ if (wally_psbt_has_output_amount(psbt, index, &written) == WALLY_OK && written
+ && wally_psbt_get_output_amount(psbt, index, &outinfo->value) == WALLY_OK
&& wally_psbt_get_output_asset(psbt, index, outinfo->asset_id, sizeof(outinfo->asset_id), &written)
== WALLY_OK
&& written) {Why this scored 46/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.