#4274·actix-web

ws: RFC 6455 protocol violations (control frame length morphing, 426 status code, handshake validation)

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

Summary

During an automated AI-assisted protocol audit of actix-http/src/ws/, multiple violations of RFC 6455 were identified across frame parsing and handshake validation.


1. Control Frame Oversize Morphing (RFC 6455 §5.5)

  • Location: actix-http/src/ws/frame.rs:141-144
  • Current Behavior: When receiving a Close frame with a payload length $> 125$ bytes, the parser morphs it into a valid empty close frame and continues:
    rust
    OpCode::Close if length > 125 => {
        debug!("Received close frame with payload length exceeding 125. Morphing to protocol close frame.");
        return Ok(Some((true, OpCode::Close, None)));
    }
  • RFC Mandate: RFC 6455 §5.5 states:

    "All control frames MUST have a payload length of 125 bytes or less and MUST NOT be fragmented." An oversized control frame must trigger a connection failure with protocol error (1002).


2. Status Code on Unsupported Version (RFC 6455 §4.4)

  • Location: actix-http/src/ws/mod.rs:134-138
  • Current Behavior: Handshake returns 400 Bad Request without version headers.
  • RFC Mandate: RFC 6455 §4.4 states:

    "the server MUST send an HTTP response with a status code 426 Upgrade Required that includes a Sec-WebSocket-Version header field indicating the version(s) the server is capable of understanding."


3. Missing Handshake Invariant Validations (RFC 6455 §4.2.1)

  • Location: actix-http/src/ws/mod.rs:170-210 (verify_handshake)
  • Issues:
    • Does not check req.version >= Version::HTTP_11 (RFC 6455 §4.2.1 clause 1).
    • Skips validating that Sec-WebSocket-Key is a valid 16-byte base64-encoded nonce before computing the accept hash (RFC 6455 §4.2.1 clause 5).

Note: This issue was identified via an AI-assisted systems audit suite and verified against the raw RFC 6455 specification.