[High][Security/DoS] Message receiver allows unbounded allocation and retention from untrusted input #30

Open
opened 2026-03-19 22:43:21 +00:00 by thabeta · 0 comments
Owner

Summary

The message subsystem currently lets remote peers drive memory growth in several ways:

  • INIT can force allocation based on an untrusted declared message length.
  • Pending inbound messages do not appear to have expiry/cleanup if transmission never completes.
  • Completed inbound messages are queued in an unbounded VecDeque.

Why this matters

This creates a practical denial-of-service surface on any node that accepts messages.

An attacker does not need to complete valid messages to cause damage. They can repeatedly send large INIT metadata, incomplete streams, or just generate completed messages faster than the application drains them.

Evidence

Untrusted allocation based on declared message length:

  • mycelium/src/message.rs:420-421

Pending inbound state is inserted here:

  • mycelium/src/message.rs:432

Pending state is only removed on DONE / ABORT handling here:

  • mycelium/src/message.rs:654
  • mycelium/src/message.rs:675

Completed messages are retained in an unbounded queue defined here:

  • mycelium/src/message.rs:127-135

Completed messages are appended in multiple paths, for example:

  • mycelium/src/message.rs:631-633
  • mycelium/src/message.rs:649-651

Expected behavior

The subsystem should enforce bounded memory usage for hostile or slow-consumer scenarios.

Actual behavior

The implementation has no obvious hard cap or expiry for inbound message state.

Suggested fix

  • Put an upper bound on accepted message length.
  • Add expiry for pending inbound messages that never reach DONE.
  • Bound complete_msges and choose a policy for overflow.
  • Consider per-peer/per-topic quotas.
  • Add adversarial tests for incomplete transmissions and large declared lengths.

Risk

High. This is a classic remote memory pressure / DoS vector in a network-facing subsystem.

## Summary The message subsystem currently lets remote peers drive memory growth in several ways: - `INIT` can force allocation based on an untrusted declared message length. - Pending inbound messages do not appear to have expiry/cleanup if transmission never completes. - Completed inbound messages are queued in an unbounded `VecDeque`. ## Why this matters This creates a practical denial-of-service surface on any node that accepts messages. An attacker does not need to complete valid messages to cause damage. They can repeatedly send large `INIT` metadata, incomplete streams, or just generate completed messages faster than the application drains them. ## Evidence Untrusted allocation based on declared message length: - `mycelium/src/message.rs:420-421` Pending inbound state is inserted here: - `mycelium/src/message.rs:432` Pending state is only removed on `DONE` / `ABORT` handling here: - `mycelium/src/message.rs:654` - `mycelium/src/message.rs:675` Completed messages are retained in an unbounded queue defined here: - `mycelium/src/message.rs:127-135` Completed messages are appended in multiple paths, for example: - `mycelium/src/message.rs:631-633` - `mycelium/src/message.rs:649-651` ## Expected behavior The subsystem should enforce bounded memory usage for hostile or slow-consumer scenarios. ## Actual behavior The implementation has no obvious hard cap or expiry for inbound message state. ## Suggested fix - Put an upper bound on accepted message length. - Add expiry for pending inbound messages that never reach DONE. - Bound `complete_msges` and choose a policy for overflow. - Consider per-peer/per-topic quotas. - Add adversarial tests for incomplete transmissions and large declared lengths. ## Risk High. This is a classic remote memory pressure / DoS vector in a network-facing subsystem.
Sign in to join this conversation.
No labels
Urgent
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
geomind_code/mycelium_network#30
No description provided.