Skip to content

fix(coderd/x/plugins): strip Coder credentials before plugin webhook forwarding - #186

Merged
ibetitsmike merged 5 commits into
mainfrom
mike/plugins-followups-webhook-creds
Nov 11, 2026
Merged

ibetitsmike merged 5 commits into
mainfrom
mike/plugins-followups-webhook-creds

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

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.webhook forwarded 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-Token header, 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 existing httpapi.StripCoderCookies, drop the Coder-Session-Token header, and remove the coder_session_token query parameter the same way the workspaceapps proxy does. Authorization is 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 Authorization header 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.

Xum opened this PR on behalf of @ibetitsmike.

…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.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T11:47:43.674261Z 4699448 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread coderd/x/plugins/runner.go Resolved
Comment thread coderd/x/plugins/runner.go Resolved
…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).
@ibetitsmike
ibetitsmike marked this pull request as ready for review November 11, 2026 10:10
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: db20062cd8

ℹ️ 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".

…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.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 4699448cca

ℹ️ 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".

@ibetitsmike
ibetitsmike merged commit e27d825 into main Nov 11, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/plugins-followups-webhook-creds branch November 11, 2026 13:25
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum merged this PR on behalf of @ibetitsmike.

Merged as a squash of head b3e0b19972 on main b3c4911b16, which produced e27d8255d7.

  • CI: fork-ci run 43026476515 passed on the exact head, which contains main b3c4911b16. The lead merged main into the branch with update-branch; this PR's changed lines match 4699448cca exactly.
  • Codex: clean receipt 6794977082 on 4699448cca, which has the same diff. 0 unresolved threads.
  • UAT: F1's f1-uat round on daily passed (A, webhook credential stripping, 11/11 assertions). Ops confirmed the cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant