Security: WebSocket Origin Check Bypass via Spoofed X-Forwarded-Proto Header - #333
Closed
tomaioo wants to merge 1 commit into
Closed
Conversation
The `OriginAllowed` function in `origin.go` determines the request's scheme by reading the `X-Forwarded-Proto` HTTP header. If an attacker can send requests directly to the gateway (bypassing a proxy) or if the proxy does not strip client-provided `X-Forwarded-Proto` headers, the attacker can spoof the scheme. By setting `X-Forwarded-Proto: https` on an HTTP request, the attacker forces the server to construct an `https` request URL, which could bypass same-origin checks or loopback allowances designed for secure connections. Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
Contributor
|
PR governance checks failed — this PR has been converted to draft.
Fix the items above, then click Ready for review to re-run the checks. |
5 tasks
ouoiouo
pushed a commit
to ouoiouo/LiveAgent
that referenced
this pull request
Aug 8, 2026
ouoiouo
pushed a commit
to ouoiouo/LiveAgent
that referenced
this pull request
Aug 8, 2026
…proxy SVG - agent/terminal WS 链路升级后立即设置读超时,读循环按 idleTimeout 续期(3×心跳周期+宽限,与浏览器链 wscore 一致):未鉴权静默连接 不再能永久占满连接槽(DoS) - /image-proxy 对 SVG 响应附加 sandbox CSP:<img> 加载不受影响, 顶层导航的恶意 SVG 无法执行脚本(防网关源 XSS/token 窃取) - origin 校验不再信任 X-Forwarded-Proto(同步上游 PR Stack-Cairn#333), 更新对应测试为忽略伪造头的新语义
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Security: WebSocket Origin Check Bypass via Spoofed X-Forwarded-Proto Header
Problem
Severity:
Medium| File:crates/agent-gateway/internal/protocol/shared/origin.go:L43The
OriginAllowedfunction inorigin.godetermines the request's scheme by reading theX-Forwarded-ProtoHTTP header. If an attacker can send requests directly to the gateway (bypassing a proxy) or if the proxy does not strip client-providedX-Forwarded-Protoheaders, the attacker can spoof the scheme. By settingX-Forwarded-Proto: httpson an HTTP request, the attacker forces the server to construct anhttpsrequest URL, which could bypass same-origin checks or loopback allowances designed for secure connections.Solution
Do not trust client-provided headers for origin security checks unless the gateway is explicitly configured to run behind a trusted reverse proxy. Rely on
r.TLSto determine the scheme, or introduce a configuration flag that explicitly enables trustingX-Forwarded-*headers only when behind a known proxy.Changes
crates/agent-gateway/internal/protocol/shared/origin.go(modified)