Repository navigation
feat(coderd/x/chatd/chatwebhook): add bearer, github and standard_webhooks verifiers - #32062
Conversation
…hooks verifiers Pure Go verifiers for the automation webhook route. No database, no HTTP route.
…d in the bearer verifier The empty-token check already rejects an empty secret. A mutation of the guard left every test green.
|
@codex review |
|
@codex security 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. |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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. |
CI revive unhandled-error flags mac.Write. Use the repo idiom _, _ = mac.Write.
RFC 6750 section 2.1 defines credentials as "Bearer" 1*SP b64token, and the API key middleware accepts it. Trailing whitespace, tabs, an empty token and other schemes stay rejected.
…e received timestamp text
…ify and ValidateSecret The NewVerifier error names the unknown scheme.
|
@codex review |
|
@codex security review |
🛡️ 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. |
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
ethanndickson
left a comment
There was a problem hiding this comment.
my only complaint is the ratio of test to product code
Why
An automation webhook must prove that a request comes from the holder of the automation's secret before Coder parses the JSON body. The approved RFC (Automations for Coder Agents, Webhooks section) puts that check behind one
WebhookVerifierinterface with three schemes. This PR adds those verifiers as a pure Go package. The webhook route that calls them comes in a later PR.Part of CODAGT-1135.
What changed
New leaf package
coderd/x/chatd/chatwebhook:WebhookVerifier, with the three methods exactly as the RFC writes them, and three verifiers:bearer(constant-time token compare, one or more spaces afterBeareras in RFC 6750 section 2.1),github(HMAC-SHA256 of the raw body inX-Hub-Signature-256) andstandard_webhooks(HMAC-SHA256 ofwebhook-id.webhook-timestamp.body,v1,entries inwebhook-signature, five-minute timestamp window,whsec_secret).Schemewith the three RFC enum strings, andNewVerifier(Scheme). The package does not importcoderd/database.Verifyfailure wrapsErrRejected, so the route can answer401. EveryVerifyandValidateSecreterror is built from a fixed string: it never holds the secret, the received token or a signature. The package does not log. Only theNewVerifiererror names the unknown scheme.GenerateSecretreads 32 bytes fromcrypto/randforbearerandgithub. Forstandard_webhooksit returnsok=false, andValidateSecretchecks the pastedwhsec_secret.Scope
mainbehaves as before with thechat-automationsexperiment off.NewVerifier(chatwebhook.Scheme(automation.WebhookAuth)). ANewVerifiererror is a server error, not a401.webhook-id, as in the RFC. The same valid request verifies every time.Tradeoffs
whsec_secret has no length bound. The spec describes sender secrets of 24 to 64 bytes, but it does not tell a receiver to reject others. A bound would lock out a sender that deviates, and it protects only the owner from the sender's own key.Bearerand the token, as RFC 6750 section 2.1 and the API key middleware do. It rejects a tab and an empty token. It also rejects trailing whitespace after the token when it receives it, but an HTTP request cannot deliver that:net/httpstrips trailing whitespace from the header value before the verifier runs, so such a request is accepted with the right token.webhook-timestamptext as received. The reference Go library signs the reformatted number instead. The two differ only for a timestamp with leading zeros, which a conforming sender does not send.webhook-idthat contains.is rejected. The spec asks senders to avoid it, because it makesid.timestamp.bodyambiguous. A repeatedAuthorization,X-Hub-Signature-256,webhook-idorwebhook-timestampline is rejected for the same reason. Severalwebhook-signaturelines are read as one list.TestSecretComparisonsAreConstantTimereads the package source and fails on==,bytes.Equaland similar on secrets. A correct early-exit compare gives the same answers as a constant-time one, so a request-level test cannot tell them apart. The scan is a guard against the likely mistake, not a proof.Verification
TestWebhookSignin the Standard Webhooks Go library. The tests cite the URL beside each vector.Generated with
xum• Model:anthropic:claude-sonnet-5-5• Thinking:xhigh