Skip to content

Prevent malformed exec WebSocket control frames from crashing the API #472

Done

Description

@samuelmbabhazi

Problem and impact

A valid container exec session can send a small text frame that makes the API throw an uncaught RangeError. The frame stays below the WebSocket's 64 KiB maxPayload: a deeply nested extra field is traversed recursively by plainToInstance before the DTO's primitive fields are validated.

The message listener does not catch the exception. This is a direct WebSocket upgrade path, outside Nest's HTTP exception handling. Under the current Node process configuration the exception can terminate the shared control-plane process, affecting other users of that process. This is an authenticated availability problem, not anonymous code execution.

Priority: P1, from the 2026-11-25 security audit. Affected snapshot: main 1295e534d7a1c3cd0a492449de8806aa532a4924, including merged #457. Related feature: #232.

Preconditions and evidence

The caller needs a valid sign-in, an accepted origin, container.exec permission and an open exec session for a running replica. An API token alone is not sufficient.

  • controlFrame transforms the entire object, including unexpected nested fields, before validation.
  • browserFrame catches JSON parsing errors only; the call to controlFrame is outside that catch.
  • The WebSocket listener has no exception boundary around browserFrame.

A bounded local regression probe invoked the actual parsing code with an unexpected nested field in an otherwise recognized control message and reproduced RangeError below the frame-size limit. The uncaught propagation was checked separately against the listener and process setup. No production service was crashed, and a live whole-server crash was not part of the proof.

Proposed correction

Validate the flat message shape and primitive fields directly before recursive transformation, or avoid recursive transformation for this closed message set. Add an exception boundary around message processing so one malformed frame cannot terminate the API. Whitelisting fields only after transformation would not fix the ordering problem.

Acceptance criteria

  • Recognized control messages with unexpected nested objects are rejected or safely ignored before recursive processing.
  • Malformed or deeply nested JSON below maxPayload cannot throw out of the listener.
  • A local isolated server test verifies that malformed input ends or rejects only the offending session; the API and a separate session remain responsive.
  • Existing resize, close, RBAC, origin, session ownership and audit behavior remain covered.
  • No arbitrary input or session credentials are written to logs.

Activity

  1. added
    bug
    priority:P1
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:P1securitytrack:control-plane

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions