Repository navigation
fix: allow every advertised app origin in the dashboard frame-src - #31744
ethanndickson wants to merge 3 commits into
Conversation
|
@codex review |
|
@codex security review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
🛡️ Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 4066443dc5
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
The primary region advertises the wildcard app host with the access URL port, but the dashboard frame-src used the raw wildcard without it. When the access URL has a non-default port, Chrome blocks every subdomain app frame. Derive both values from one helper. Also admit each region's own host in frame-src, for proxy path-based apps and the access URL app auth redirect.
A workspace proxy can register an access URL or wildcard hostname with ';', ',', whitespace or non-ASCII characters. Written into the CSP header, these start a new directive or policy, add sources, or make browsers drop the whole directive. Skip each proxy host value that is not a single CSP token.
bfc553c to
0bf38ac
Compare
There was a problem hiding this comment.
This PR builds the primary frame-src app host and the advertised wildcard from one helper, adds each region's host to frame-src, and skips proxy values that are not single CSP tokens. Findings: 1 P1, 4 P3, 6 P4, 1 Nit.
Out of scope (needs a ticket or explicit acceptance by a human):
coderd/workspaceapps/request.go:75:AppBaseURLbuilds subdomain app URLs from the rawAppHostnameand drops the access URL port, so the app sign-in redirect lands on port 443 when the access URL has another port and the wildcard has none, framed or not.coderd/workspaceapps/apptest/setup.go:176:SubdomainAppURLbuilds the same portless URL, so apptest redirect assertions agree with theAppBaseURLport loss instead of catching it.enterprise/coderd/workspaceproxy.go:400:validateProxyURLaccepts hosts that are not hostnames (;,,, non-ASCII,data:,https:,*, quotes), and every consumer of the proxy URL receives them unchecked.coderd/workspaceapps/appurl/appurl.go:266:CompileHostnamePatterndiscards the port without validating it, so*.a.com:1;script-src xregisters and is advertised in/api/v2/regions.enterprise/coderd/proxyhealth/proxyhealth.go:356: a proxy with an empty wildcard gets its raw host asAppHost, so hosts likedata:or*already reachedframe-srcbefore this PR.enterprise/coderd/workspaceproxy.go:986: proxy regions advertise the rawWildcardHostnamewithout the proxy access URL port, so a proxy on a non-default port with a portless wildcard sends subdomain apps to the default port.coderd/httpmw/csp.go:123:r.Hostgoes intoconnect-srcunfiltered, so a request with;or,in its Host header changes the policy of its own response.coderd/httpmw/csp.go:138: theHost == "*"branch (theAllowAllCorssentinel) has no test coverage, and a proxy registered ashttps://*produces the same policy asCODER_DANGEROUS_ALLOW_ALL_CORS.coderd/coderd.go:2264andenterprise/coderd/coderd.go:817: comments still say proxy hosts are limited to healthy proxies, which contradicts the correctedProxyHostsdoc.enterprise/coderd/proxyhealth/proxyhealth.go:347: whenurl.Parse(proxy.Url)fails,uis nil andu.Hostpanics the health-check goroutine.coderd/proxyhealth/proxyhealth.go:6: theProxyHost.AppHostfield doc says "wildcard host", but every producer stores theConvertAppHostForCSPoutput.coderd/httpmw/csp.go:131:extraConnectnames a list that also feedsframe-src.
Notes:
coderd/workspaceapps/appurl/appurl_test.go:577: theAsteriskWithPortandFirstPrefixWithPortcases pass on the base commit; they pin existing converter behavior, and the other changed tests are the ones that fail on base.coderd/agentapi/manifest.go:187still callsappurl.SubdomainAppHostdirectly with its own options; the call is correct.
🤖 This review was automatically generated with Coder Agents.
Describe what ProxyHosts and ProxyHost.AppHost hold, drop the stale 'healthy proxies' wording, and say why the request host is skipped. The primary region test now asserts the literal frame-src source instead of computing it with the production converter.
Relates to CODAGT-1455
If
CODER_ACCESS_URLhas a non-default port (e.g.https://coder.example.com:8443) and the wildcard access URL has no port, Coder's own CSP blocks every subdomain app the dashboard tries to frame, and Chrome shows "This content is blocked. Contact the site owner". That's the page reported in the Coder Agents side panel in the linked issue, though I'm not sure this is the cause there, as we don't know that deployment's access URL port.The primary region tells the frontend to frame apps on the wildcard with the access URL port appended, but
frame-srcis built from the raw wildcard. From acoderdtestserver onmain:GET /api/v2/regions, primarywildcard_hostname*.test.coder.com:41633GET /login,frame-srcinContent-Security-Policy'self' *.test.coder.comA CSP source without a port only matches the scheme's default port (spec), so the frame is blocked. #11657 started appending the port to the advertised wildcard, and #18374 later built
frame-srcfrom the raw value, so the two have never agreed.To fix, we'll derive both from one
subdomainAppHost()helper. This is strictly an improvement:frame-srcnow admits exactly the origin the frontend frames. The raw entry I've dropped only matched the default port, and onmaina frame was already blocked before it could reach anything on that port. I checked this with a real coderd and headless Chrome: onmainthe frame gets aframe-srcviolation from Coder's own policy, and on this branch it reaches coderd's app proxy.This PR also adds each region's own host to
frame-src, skipping it when it's the request host ('self'covers that). This covers path-based apps on workspace proxies, and the app auth redirect through the access URL when the dashboard is opened on another hostname. I found these reading the code and haven't reproduced them. Both hosts are Coder's own origins and were already inconnect-src, so no new origins are trusted.Known gaps
IssueTokenRequest.AppBaseURLbuilds the app auth redirect from the raw wildcard, so the last hop goes to the default port, whichframe-srcdoesn't admit. This bug predates this PR and breaks the same apps outside a frame too, so I've left it out of scope.;,,or non-ASCII characters, are now skipped inframe-srcandconnect-src. Onmainthey went into the header as-is, where a;could inject a directive and a non-ASCII character makes the browser drop the whole directive. Nothing logs the skip, but I don't think anyone will hit it: a real hostname can't contain any of these except non-ASCII characters, and DNS and TLS certificates already use punycode for internationalised names, so I'd expect admins to configure them that way too.