#4275·actix-web

ws: unbounded memory growth in WebsocketContext outbound message queue (RFC 6455 §10.5 DoS / lack of backpressure)

Author: Sruhvx-jpgCreated Sep 27, 2026Updated Sep 27, 2026

Summary

During an AI-assisted systems audit of actix-web-actors/src/ws.rs, an unbounded memory growth vulnerability (lack of flow control / backpressure) was identified in the outbound WebSocket message buffering mechanism.


Specification Context (RFC 6455 §10.5)

RFC 6455 has no application-level windowing and delegates flow control directly to underlying TCP backpressure. RFC 6455 §10.5 (Denial of Service) explicitly states:

"An implementation SHOULD place limits on the amount of memory allocated for unacknowledged or queued data."


Description

In actix-web-actors/src/ws.rs:608:

rust
#[inline]
pub fn write_raw(&mut self, msg: Message) {
    self.messages.push_back(Some(msg));
}

The outbound message queue self.messages is backed by an unconstrained VecDeque<Option<Message>>.

Problem

  1. Decoupled TCP Backpressure: Calling synchronous helper methods (ctx.text(), ctx.binary(), ctx.ping(), etc.) directly appends into the heap queue. If a client stalls TCP ACKs or reads slowly, self.messages grows without limit until OOM.
  2. Actor Mailbox Disconnect: While actor Mailbox capacity defaults to 16, messages written directly on the context bypass mailbox bounds entirely.

Suggested Mitigation

  • Introduce a configurable high-water mark / max buffer size or capacity limit on WebsocketContext.
  • Provide a backpressure mechanism or drop the connection with close code 1008 Policy Violation (or 1009 Message Too Big) when buffer limits are exceeded under DoS / stalled peers.

Note: This issue was identified via an AI-assisted systems audit suite.