Skip to content

fix: node robustness — streaming overflow DoS, spammer panics, metrics accuracy#161

Open
PrazwalR wants to merge 6 commits into
circlefin:mainfrom
PrazwalR:fix/node-robustness-fixes
Open

fix: node robustness — streaming overflow DoS, spammer panics, metrics accuracy#161
PrazwalR wants to merge 6 commits into
circlefin:mainfrom
PrazwalR:fix/node-robustness-fixes

Conversation

@PrazwalR

Copy link
Copy Markdown

Fixes a batch of self-contained correctness bugs. One commit per issue; all changes build, test, clippy -D warnings, and rustfmt clean.

Fixes

Tests

Closes #144, #137, #142, #134, #131, #128

PrazwalR and others added 6 commits June 17, 2026 12:06
A gossiped Fin proposal part carries an unauthenticated `sequence` wire field that StreamState::insert used directly as `expected_messages = sequence as usize + 1`. A peer sending sequence = u64::MAX overflowed the +1: a panic in overflow-checked/debug builds (one message crashes the node) and a silent wrap in release that leaves the stream permanently incomplete, squatting a per-peer slot until the 60s age sweep.

Reject any Fin whose sequence is outside [0, MAX_MESSAGES_PER_STREAM - 1] via a new FinSequenceOutOfRange result that evicts the stream. Adds a regression test (u64::MAX and at-cap) and a boundary test (max in-range sequence still completes).

Fixes circlefin#144

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
partition_exponential's guard computed `1 << (num_generators - 1)`, which overflows its own shift once the exponent reaches the platform word size: a panic in debug, and in release a wrapped shift that slips past the guard and builds non-monotonic, overlapping account ranges. Check the shift width first (shift >= usize::BITS) so the case returns the intended graceful error. Adds a regression test.

Fixes circlefin#137

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
insert_decided_block's timer spanned insert_certificate, which records its own write time, so the certificate insert was counted twice in the aggregated write_time metric. Scope the block-write timer around the certificate call and attribute the shared commit once.

Fixes circlefin#142

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The versioned codec attempted a full protobuf decode before falling back to the versioned path, but every current message carries the 0x01 version prefix and always fails that first attempt. Add a first-byte version pre-check: 0x01 can never begin a valid protobuf message (min field tag is 0x08), so a leading version byte unambiguously selects the versioned path.

Fixes circlefin#131

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
record_proposal performed a warn! side effect on equivocation. Return #[must_use] bool (true = recorded, false = equivocation) instead and log at the two call sites with their own context. Updates the unit test to assert on the return value.

Fixes circlefin#134

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
catch_up_scan propagated one received_at (the reconnect moment) to every missed block, collapsing their latencies onto a single instant. Timestamp each block with timestamp_now() as it is fetched.

Fixes circlefin#128

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 17, 2026 06:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: unvalidated Fin proposal-part sequence overflows expected_messages (panics in overflow-checked node builds, wedges the stream in release)

2 participants