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

p2p: Saturate LocalServiceInfo::nScore updates at INT_MAX

Public commit record

What the developer wrote

Authored by codeabysss

88/100 · Strong
p2p: Saturate LocalServiceInfo::nScore updates at INT_MAX

Signed overflow on nScore updates is undefined behavior. Use
SaturatingAdd in AddLocal() and SeenLocal() so increments saturate at
INT_MAX instead of overflowing.

Add unit test coverage for saturation in both code paths.
✓ 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 subtle programming bug in Bitcoin Core's peer-to-peer networking code. A local network address score counter could, in theory, overflow when repeatedly incremented, which is 'undefined behavior' in C++ and could potentially cause the program to misbehave or crash. The fix makes the counter stop increasing once it reaches the maximum integer value, and adds tests to confirm that behavior.

Recommended action

Treat as a low-to-moderate hardening fix. Review whether any other signed counters in the p2p layer use plain increment/addition and could overflow. No immediate emergency response is indicated, but the fix should be included in routine maintenance/backports.

Security signals we found

01

Fixes undefined behavior (signed integer overflow)

02

Uses saturating arithmetic helper (SaturatingAdd)

03

Adds unit tests for overflow/saturation behavior

04

Touches local address advertisement scoring (p2p network self-advertisement)

Risk score

Why this scored 37/100

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