Web UI: every POST to /api/* returns 403 Forbidden (trust fence Origin/Host port mismatch) #2009
Replies: 4 comments
|
Confirmed at source level and implemented as a cherry-pick-ready branch - your diagnosis is exact. Source audit (master 47f9438)
Patch: fix/api-trust-origin-hostname-portlesshttps://github.com/zoahdev/deepseek-harness/tree/fix/api-trust-origin-hostname-portless
Verification
Thanks for the minimal repro - this one was breaking the entire UI on a specific browser, which is the worst kind of bug to find. |
|
Origin/Host 端口不匹配触发 trust fence——127.0.0.1:3080 的 origin 校验把页面请求全 403 了。和 #128/#755(局域网 403)是同一条线:trustedHosts/origin 匹配太严格。 临时:确认访问地址和 trustedHosts 完全一致(含端口)。第 12 章有记录:https://github.com/Electricitysheep/dsh-handbook/blob/main/docs/12-limitations.md |
|
Hi, we hit exactly the same issue: Chrome/Chromium strips the port from the Origin header for loopback URLs ( We filed a bug report with the root cause and a suggested fix (compare hostname only, ignore the port): We also maintain a green "double-click to run" launcher distribution that already fixes this with an idempotent patch (Origin check changed to hostname comparison; in LAN mode it also merges the machine's LAN IPs into trustedHosts). Feel free to reference the approach or use it directly:
你好,我们遇到了完全一样的问题:Chrome/Chromium 对回环地址( 同时我们维护的绿色整合版启动器已经解决该问题(自动打幂等补丁:Origin 校验改 hostname 比较,局域网模式自动并入本机局域网 IP),欢迎参考方案或直接使用:
本回复由 AI 辅助撰写 / This reply was drafted with AI assistance. |
|
Confirmed again against current upstream new URL(origin).host === hostUrl.hostIn the affected Chrome profile, CDP captured this actual POST shape: Host: 127.0.0.1:3080
Origin: http://127.0.0.1
Referer: http://127.0.0.1:3080/
Sec-Fetch-Site: same-originThe impact is broader than the directory picker: the shared I tested a narrower compatibility fallback than globally switching to hostname-only comparison. It accepts the port-less Origin only when all of these hold:
Cross-site, opaque ( Verification on the rc.8 checkout:
This confirms the bug is still present in rc.8 and that one helper-level fix restores the whole HTTP RPC surface, not only |
Uh oh!
There was an error while loading. Please reload this page.
What happens
pnpm dsh webathttp://127.0.0.1:3080, opened in Edge (Chromium 151). The page loadsand the WebSocket streams connect, but every POST to
/api/*returns403 forbidden,breaking the whole UI (workspace creation, settings, credentials,
host.describe...).Repro
pnpm install && pnpm run build && pnpm dsh webhttp://127.0.0.1:3080in Edge.POST /api/…→403.Cause
packages/client/connection/src/api-request-trust.ts, inisTrustedApiRequest:WHATWG
.hostdrops the default port, so a port-lessOriginfrom the browser nevermatches the Host header:
Edge sends
Origin: http://127.0.0.1(no port) onfetch(), butHost: 127.0.0.1:3080(with port) — WebSocket handshakes keep the port, which is why only POSTs fail.
Fix
Verified locally: with
Origin: http://127.0.0.1+Host: 127.0.0.1:3080, requests now return 200.All reactions