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

Correct EOF handling in stream read in `ChaChaDualPolyReadAdapter`

Public commit record

What the developer wrote

Authored by Matt Corallo

91/100 · Strong
Correct EOF handling in stream read in `ChaChaDualPolyReadAdapter`

When `ChaChaDualPolyReadAdapter` encounters an EOF (`Read::read`
returns `Ok(0)`) while trying to drain the stream (even though the
`FixedLengthReader` thinks it has available space) we'll end up
infinite-looping trying to drain the stream looking for
`Read::read` to return an `Err` (which it won't).

The fix is, of course, simple, to detect the EOF signal.

Found by the `onion_message_target` fuzzer which @dergoegge ran.
Thanks to @morehouse for digging deeper on the specific fuzz test
case and thoroughly reporting the underlying causes.

Fixes #4139.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a bug in rust-lightning's encrypted stream reader where reaching the end of a data stream could cause the program to get stuck in an endless loop instead of stopping cleanly. The fix makes the reader recognize the end-of-stream signal and return a 'short read' error. The bug was found by a fuzz tester, not reported as an active attack.

Recommended action

Upgrade to a rust-lightning release containing this commit. If running a node that processes untrusted onion messages or encrypted streams, prioritize the patch to avoid CPU exhaustion from maliciously truncated inputs.

Security signals we found

01

Infinite loop / denial-of-service condition on malformed or truncated encrypted input

02

Missing EOF handling in a stream-draining loop

03

Discovered by fuzzing (`onion_message_target`)

04

Fix returns explicit `DecodeError::ShortRead` rather than hanging

Risk score

Why this scored 60/100

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