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

Merge rust-bitcoin/rust-bitcoin#6886: units: preserve original err summing `NumOpResult`

Public commit record

What the developer wrote

Authored by Andrew Poelstra

100/100 · Strong
Merge rust-bitcoin/rust-bitcoin#6886: units: preserve original err summing `NumOpResult`

d0d2f2ee23959e0a970a90ed6ec3f8d9632af8b1 units: test that Sum keeps the error it was given (satsfy (Renato Britto))
ebbeb23687e5170cf847cd53f3d208acaffdcfc4 units: preserve original err summing NumOpResult (satsfy (Renato Britto))

Pull request description:

Closes https://github.com/project-loupe/audit-rust-bitcoin/issues/201

The Sum impls replaced any error in the iterator with an addition overflow, so, say, a division by zero came out labelled MathOp::Add.

Also need to put `*amount` because a binding must have the same type in all alternatives, amount was a ref not owned while acc was, the compiler complained.


ACKs for top commit:
apoelstra:
ACK d0d2f2ee23959e0a970a90ed6ec3f8d9632af8b1; successfully ran local tests
tcharding:
ACK d0d2f2ee23959e0a970a90ed6ec3f8d9632af8b1
Kixunil:
ACK d0d2f2ee23959e0a970a90ed6ec3f8d9632af8b1


Tree-SHA512: dc4189b3279f468e42b97a1c9fe694873121edda3623192d5684076ddda33df967f18af603b21ed0e90cdbe836e2f946017c42eff1a7592a81233730a465791b
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This patch fixes a bug in how rust-bitcoin adds up a list of numeric operation results. Previously, if any item in the list already carried an error (for example, dividing by zero), the summing code would overwrite that error and falsely report it as an addition overflow. The fix preserves the original error so callers see the true cause of the failure. It is a correctness fix rather than a direct exploit, but misreported errors can mislead downstream code or users about what went wrong.

Recommended action

Review any downstream code that inspects `NumOpError` after summing `NumOpResult` iterators; prior behavior may have masked non-overflow errors. The patch should be backported if the affected release series is supported, and the regression test should be kept in the test suite.

Security signals we found

01

Error-type confusion / misattribution in arithmetic result aggregation

02

Loss of original failure context across iterator fold

03

Potential for downstream logic to act on wrong `MathOp`/`MathErrorKind`

Risk score

Why this scored 38/100

Our methodology →
Potential impact 8/30
Exploitability 5/25
Stealth signal 7/15
Affected reach 6/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.