AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
High 80 Bitcoin

Merge pull request #533 from LedgerHQ/psbt_refactor

Public commit record

What the developer wrote

Authored by Salvatore Ingala

58/100 · Thin
Merge pull request #533 from LedgerHQ/psbt_refactor

Harden and refactor PSBT accessor API
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Links an issue, advisory, or supporting reference! No meaningful explanatory body
The short version

What changed, and why it matters

This commit is a hardening and refactor of the code that reads PSBT (Partially Signed Bitcoin Transaction) fields from a host computer into a Ledger hardware wallet. The core security fix is that the device now clearly distinguishes between a field that is genuinely missing in a PSBT map and a field that is present but malformed or failed to verify. Previously, both cases could return the same error code, which could trick the wallet into silently using a default value (for example, default nSequence or default locktime) when the host had actually committed to something else. The commit also adds a guard that refuses to look up values by key unless the map's keys have already been proven to be sorted and unique, preventing a malicious host from supplying two different values for the same key.

Recommended action

Treat this commit as a security-hardening patch and include it in any release. Review all downstream callers of the new `psbt_fields.h` API to ensure `PSBT_FIELD_ABSENT` is only used for intentional defaults and `PSBT_FIELD_ERROR` always aborts signing. Run the new unit tests (`test_psbt_fields`, updated `test_get_merkleized_map_value`, `test_get_merkle_leaf_index`) in CI. Consider whether any other optional PSBT fields elsewhere in the app still use a simple negative-error check that could silently default.

Security signals we found

01

Refactor of security-critical PSBT parsing code with explicit hardening goal

02

Introduction of sorted-key precondition and assertion before by-key map reads

03

Separation of 'field absent' vs 'field malformed/proof failed' return codes

04

Zeroing of output buffers on failed/absent reads to prevent use of uninitialized data

05

Fixing of default-value substitution for optional PSBT fields (nSequence, fallback locktime)

06

Addition of unit tests specifically targeting regression scenarios where errors were misclassified as absence

Risk score

Why this scored 80/100

Our methodology →
Potential impact 24/30
Exploitability 18/25
Stealth signal 12/15
Affected reach 14/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.