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

rust: don't silently eat overflow errors in --release

Public commit record

What the developer wrote

Authored by niftynei

88/100 · Strong
rust: don't silently eat overflow errors in --release

When running `nix build .#default -L` I came across two failures:

> failures:
>
> ---- primitives::test::test_amount_add_overflow stdout ----
> note: test did not panic as expected at cln-rpc/src/primitives.rs:1064:8
> ---- primitives::test::test_amount_sub_overflow stdout ----
> note: test did not panic as expected at cln-rpc/src/primitives.rs:1057:8
>
> failures:
> primitives::test::test_amount_add_overflow
> primitives::test::test_amount_sub_overflow
>
> test result: FAILED(B. 36 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s

Rather than wrapping silently, we now error.

Changelog-Fixed: rust: Amounts that overflow fail, don't silently ignore in release builds
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit fixes a bug in Core Lightning's Rust code where adding or subtracting monetary amounts would silently wrap around to incorrect values in release builds, instead of failing as intended. The fix makes overflow and underflow explicitly cause an error (panic), so bad calculations can't be quietly ignored. This is a security-relevant correctness issue because silently wrong amounts could lead to incorrect balances or payments.

Recommended action

Review all call sites using + and - on Amount types to ensure they can handle None from checked_add/checked_sub, or confirm that panicking is acceptable. Consider whether any existing release-build behavior relied on wrapping. No immediate exploit is evident, but the fix should be included in the next release.

Security signals we found

01

Integer overflow/underflow in monetary amount arithmetic

02

Silent wrapping behavior in release builds

03

Potential incorrect balance or payment amount computation

04

Fix changes silent wrap to explicit panic via checked arithmetic

Risk score

Why this scored 61/100

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