Repository navigation
fix(coderd/x/plugins): strip Coder credentials before plugin webhook forwarding - #186
Conversation
…forwarding The plugin webhook route is unauthenticated, and runner.webhook forwarded the request headers and URI as received. A signed-in caller opening the webhook URL on the Coder origin leaked its session cookie, Coder-Session-Token header, Authorization header or session-token query parameter to the plugin. Strip those credentials from the forwarded request without mutating the incoming one, reusing httpapi.StripCoderCookies and the workspaceapps proxy query-strip approach. Part of #172 (thread 2). Add the echo testdata plugin and an internal runner test that proves none of the four vectors reaches the plugin while unrelated cookies, headers, query parameters, method and body arrive intact.
…pers Drop the redundant Cookie-count guard and the avoidable strip branch in webhookRequestURI and webhookRequestHeaders, and trim the helper doc comments to the parts the code does not already show.
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 190c69e4e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
…ward Authorization may be how a webhook provider authenticates its senders (Bearer or Basic), and browsers never attach it implicitly, so a value there belongs to the caller, not to Coder; deleting it unconditionally rejects every legitimate webhook. Forward it like the workspaceapps proxy does, and strip only the three vectors Coder itself sets: the session cookie and app cookies, the Coder-Session-Token header, and the coder_session_token query parameter. Part of #172 (thread 2).
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |
…dline plugintest.BuildWasm shells out to go build and does not observe the context; a cold build on CI can outlast WaitSuperLong, so Load received an already-expired deadline. Build first, then start the clock.
|
@codex review
|
|
Codex Review: Didn't find any major issues. Hooray! 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". |
Merged as a squash of head
|
The plugin webhook route (
POST /api/experimental/plugins/{plugin}/webhook) is unauthenticated: the plugin checks its own secret, and the route sits outside the API-key middleware.runner.webhookforwarded the caller's request URI and headers to the plugin as received, so a signed-in person who opens a webhook URL on the Coder origin leaked their session cookie,Coder-Session-Tokenheader, or session-token query parameter to the plugin.Strip those credentials from the forwarded request in
runner.webhook: drop the session-token cookies via the existinghttpapi.StripCoderCookies, drop theCoder-Session-Tokenheader, and remove thecoder_session_tokenquery parameter the same way the workspaceapps proxy does.Authorizationis forwarded on purpose: browsers never attach it implicitly, so a value there belongs to the webhook sender and may be how the plugin authenticates the caller, the same reason the workspaceapps proxy forwards it (db20062, Codex P1). Everything else (method, path, body, other headers and query parameters) is forwarded unchanged, and the incoming request is not mutated.A new internal test drives the real in-process plugin host with an echo test plugin and asserts the plugin receives none of the three Coder-set vectors while the plugin-owned
Authorizationheader and unrelated cookies, headers, query parameters, method and body arrive intact. The test fails on the pre-fix code (verified by revert).Part of #172 (thread 2). Dev-build UAT against this head is running separately.