Skip to content

fix(security): only skip evaluation for genuine WebSocket upgrades - #1

Draft
telmolivella2 wants to merge 1 commit into
mainfrom
security/websocket-upgrade-strict
Draft

telmolivella2 wants to merge 1 commit into
mainfrom
security/websocket-upgrade-strict

Conversation

@telmolivella2

Copy link
Copy Markdown

Summary

Vulnerability (High, ENG-3374): this customer-shipped MuleSoft flex policy treated any request with Connection: Upgrade plus any Upgrade header as a WebSocket upgrade and skipped both request and response evaluation (is_websocket_upgrade, src/lib.rs). A caller could add Connection: Upgrade + Upgrade: h2c to a normal POST and bypass the guardrail.

Fix (minimal): is_websocket_upgrade now requires the upgrade token in Connection, Upgrade: websocket (case-insensitive, trimmed) and a Sec-WebSocket-Key, as RFC 6455 does. Existing positive tests and the integration test request gain the sec-websocket-key header so they keep covering the real skip.

Base: main (no develop in this repo). Linear: ENG-3374

How tested

  • 3 new unit tests (forged Upgrade: h2c → not websocket; websocket without key → not websocket; Upgrade: WebSocket with key → websocket).
  • cargo test --lib with a local stable toolchain (no CI in this repo): base with the new tests 105 passed / 2 failed (the two negative cases); branch 107 passed / 0 failed.
  • cargo clippy --all-targets: the same 3 pre-existing warnings before and after.
  • Not run: the #[pdk_test] integration tests (need Docker, the Flex Gateway image and registration.yaml) and cargo fmt (rustfmt not installed). nt-pre-pr-check make test fails identically on main (needs anypoint-cli-v4 / cargo anypoint).

Type of Change

  • feat — New feature → minor bump
  • fix — Bug fix → patch bump
  • refactor — Code restructuring (no behavior change) → patch bump
  • docs — Documentation → patch bump
  • test — Tests → patch bump
  • ci — CI/CD changes → patch bump
  • chore — Maintenance → patch bump
  • Breaking change (!) → major bump

Checklist

  • Title follows type(scope): description format
  • Changes are focused on a single concern
  • Tests added/updated if applicable
  • No secrets or credentials committed

Merge Reminder

develop → main: Use "Create a merge commit" (not squash)
Feature → develop: Use "Squash and merge" (PR title becomes the commit message)

🤖 Generated with Claude Code

is_websocket_upgrade accepted any request with `Connection: Upgrade` and
any `Upgrade` value, letting a normal POST bypass request and response
evaluation. Require `Upgrade: websocket` (case-insensitive) and a
`Sec-WebSocket-Key` header, per RFC 6455. Adds unit tests for spoofed
upgrade headers and updates the existing upgrade tests accordingly.

Refs ENG-3374

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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