Skip to content

fix(security): never send raw exception text from the Responses WebSocket proxy (Hard Rule #12) - #15073

Merged
diegosouzapw merged 1 commit into
release/v3.8.51from
fix/ws-proxy-sanitized-error
Sep 29, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.51from
fix/ws-proxy-sanitized-error

Conversation

@diegosouzapw

Copy link
Copy Markdown
Owner

⚠️ base-red inherited: #15032

Resolves CodeQL alerts #1021 (js/xss-through-exception) and #1022 (js/stack-trace-exposure), both on scripts/dev/responses-ws-proxy.mjs:333.

That file is not dev-only: it ships as dist/responses-ws-proxy.mjs, a dependency of the standalone server-ws.mjs. Hard Rule #12 therefore applies.

Two leaks, one class

  1. The flagged path. When the WebSocket upgrade failed, the 500 body carried error.message, which can include filesystem paths and stack frames.
  2. The upstream connect failure, not flagged by CodeQL. The response.failed frame sent to the client carried error.message from the upstream connect. That text can include the configured upstream proxy URL with its credentials and internal addresses. The new test shows http://user:s3cret@10.0.0.9:3128 reaching the client before the fix.

Both now return a fixed message: "Responses WebSocket proxy failed" and "Upstream WebSocket connection failed". The error code does not change. The raw detail stays server-side, in the server log for the upgrade path and in the request history for the connect path.

Validation

  • New tests/unit/responses-ws-proxy-error-sanitization.test.mjs (2 cases). Both fail on the old code.
  • The existing responses-ws-proxy* suites pass locally. The full set runs on 192.168.0.113; results are in a comment below.

…cket proxy (Hard Rule #12)

responses-ws-proxy.mjs ships as dist/responses-ws-proxy.mjs (a server-ws.mjs
dependency). Two paths wrote raw exception text to the client:

- a failed upgrade returned error.message in the 500 body (CodeQL
  js/stack-trace-exposure + js/xss-through-exception) — paths and stack frames;
- an upstream connect failure sent error.message in the response.failed
  frame — which can carry the configured upstream proxy URL with its
  credentials, or internal addresses.

Both now return a fixed message; the detail stays in the server log and in the
server-side request history. Tests reproduce both leaks (the second shows
user:s3cret@10.0.0.9 reaching the client) and fail on the old code.
@diegosouzapw

Copy link
Copy Markdown
Owner Author

Validation on 192.168.0.113 (5fba0e6): responses-ws-proxy-error-sanitization 2/2, responses-ws-proxy 6/6, responses-ws-proxy-headers 2/2, responses-ws-proxy-turn-timing 1/1, responses-ws-proxy-multi-turn-history 1/1, responses-ws-proxy-compression-parity 1/1. typecheck:core 0 errors. File-size, complexity and stryker coverage are OK.

@diegosouzapw
diegosouzapw merged commit d573d40 into release/v3.8.51 Sep 29, 2026
16 of 21 checks passed
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.

1 participant