Repository navigation
fix(api): trust proxy headers over local socket TLS state in websocket origin check - #868
Conversation
…t origin check With trust proxy enabled but X-Forwarded-Proto absent on a websocket upgrade, isOriginAllowed fell back to the local socket's encrypted flag. Behind a TLS-terminating proxy that socket is plain HTTP, so a browser's https:// Origin never matched and every upgrade got a hard 403 while REST worked fine. The protocol is now treated as unknown and skipped from the comparison instead, matching Express's own trust-proxy semantics; host validation keeps its teeth. Adds a debug log on rejection with the origin/host/protocol details for diagnosing future mismatches. Closes #867.
|
@coderabbitai review |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe WebSocket origin check now treats the protocol as unknown when a trusted proxy omits Suggested labels: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Full details: Linked Issues checkExplanation The changes address issue Full details: Out of Scope Changes checkExplanation All reviewed changes support the linked issue. The logger and rejection diagnostics improve origin-validation troubleshooting, and the added tests verify the proxy behavior and host validation. No unrelated code changes are shown. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@greptileai Review exact head |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…t origin check (v1.6 backport) (#872) fix(api): trust proxy headers over local socket TLS state in websocket origin check (#868) With trust proxy enabled but X-Forwarded-Proto absent on a websocket upgrade, isOriginAllowed fell back to the local socket's encrypted flag. Behind a TLS-terminating proxy that socket is plain HTTP, so a browser's https:// Origin never matched and every upgrade got a hard 403 while REST worked fine. The protocol is now treated as unknown and skipped from the comparison instead, matching Express's own trust-proxy semantics; host validation keeps its teeth. Adds a debug log on rejection with the origin/host/protocol details for diagnosing future mismatches. Closes #867.
Rolls the Unreleased changelog content into a dated 1.7.0-rc.4 section (adding a new demo-headers Security entry for #878 alongside the existing OpenSSL/WebSocket-proxy/bare-integer-tag entries) and stamps the rc.4 identity across README.md and its six translations, the website's site-config/site-content, the current docs quickstart tag matrix and API examples, and the demo mock fixtures. Updates the release-identity/docs-identity/changelog-links/readme-translations test fixtures and highlight excerpts to match. Four highlight areas: the WebSocket log-stream TLS-proxy 403 fix (#867/#868), the bare-integer-tag ranking fix (#859/#871), the six-CVE OpenSSL base-image bump (#881), and the demo site's missing security headers (#878).
Fixes #867.
With DD_SERVER_TRUSTPROXY enabled but X-Forwarded-Proto absent on a websocket upgrade,
isOriginAllowedfell back to the local socket'sencryptedflag. Behind a TLS-terminating proxy (Traefik in the report) the backend socket is plain HTTP, so a browser's https:// Origin never matched and every upgrade got a hard 403 while REST kept working (Express's own trust-proxy machinery resolvesreq.protocolthere). Not auth-specific; the reporter's OIDC-only setup just made it look that way. The trust-proxy-enabled test block never exercised a realistic socket, so the branch was untested.Fix: when trust proxy is on and the forwarded protocol header is absent, treat the protocol as unknown and skip that comparison (matching Express trust-proxy semantics); host validation keeps its teeth, trust-proxy-off behavior is untouched. Also adds a debug log on every rejection with the origin/host/protocol and raw forwarded-header values so the next 403 explains itself.
Verified: six new tests including the reporter's exact deployment shape (TDD, new tests confirmed red against the unfixed code), full app suite 412 files / 13,092 tests green at 100% coverage, biome clean, full pre-push gate green.
Changelog
DD_SERVER_TRUSTPROXYis enabled andX-Forwarded-Protois absent.