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

Replace the wallet policy AST relative pointers with native pointers

Public commit record

What the developer wrote

Authored by Salvatore Ingala

73/100 · Adequate
Replace the wallet policy AST relative pointers with native pointers

Relative pointers saved some RAM, but added a significant amount of code
complexity - which is no longer a good tradeoff for devices post Nano S.

The "N bytes" comments on the node structures were wrong even before this
change: policy_node_s::flags is a struct of unsigned int bitfields, hence
4 bytes rather than 1, which made every node 6 bytes larger than
advertised. They are now the measured sizes for the 32-bit devices.

src/common/cleartext_match.c is generated, so the accessors are rewritten
in specs/bip388/gen.py and the file regenerated.

Also adds an assertion for an implicitly used invariant: multi() and
friends allocate their key expressions one at a time but index them as an
array, which only works if sizeof(policy_node_keyexpr_t) is a multiple of
the alignment buffer_alloc() pads to.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit is a code cleanup in Ledger's Bitcoin app. It replaces a memory-saving 'relative pointer' scheme with ordinary C pointers in the wallet-policy data structures. The change removes several hundred lines of pointer-conversion code and adds one compile-time check to make sure key-expression structures stay properly aligned when allocated back-to-back. There is no direct evidence in the commit that it fixes an active security bug; it reads as a maintainability/refactoring change to reduce complexity on newer Ledger devices that have more RAM.

Recommended action

Treat as a normal refactoring commit. Run the existing unit tests and on-device fuzzing/validation suite to confirm that parsing, script generation, taptree hashing, and signing still behave identically. Review the new _Static_assert and confirm that buffer_alloc alignment is indeed 4 bytes on all supported targets. No urgent security response is indicated by the diff itself.

Security signals we found

01

Large-scale pointer model change in security-critical parsing/rendering/signing code

02

Removal of a 16-bit relative-pointer encoding that previously limited offsets to 65535 bytes

03

Addition of a static assertion enforcing alignment of policy_node_keyexpr_t

04

No explicit security relevance, CVE, or bug-fix framing in commit message

Risk score

Why this scored 30/100

Our methodology →
Potential impact 5/30
Exploitability 5/25
Stealth signal 5/15
Affected reach 5/15
Confidence 7/10
Evidence quality 3/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.