mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add --chat-hook-allow-insecure to allow plain HTTP chat hook URLs (#27896)
Adds a hidden `--chat-hook-allow-insecure` / `CODER_CHAT_HOOK_ALLOW_INSECURE` deployment option (default `false`) that allows the chat lifecycle hook URL to use plain HTTP for any host. The HTTPS requirement is enforced at two points, and the flag relaxes both: `DeploymentValues.Validate()` rejects `http` hook URLs at startup, and the hook dispatcher's `validateHookURL` allows `http` only for loopback hosts. With the flag set, any-host `http` is accepted; the host, fragment/userinfo, secret, and timeout checks are unchanged, and non-http(s) schemes still fail. This removes the need for an HTTPS reverse proxy when testing a hook consumer on a trusted network. Following security review feedback, the flag description and docs state that plain HTTP lets an on-path attacker forge hook responses (which control agent execution), and `coder server` logs a startup warning (with a redacted hook URL) when hooks run over plain HTTP. Docs, generated API types, and the server config golden are updated accordingly. > Mux acted on Mike's behalf to create this PR.
This commit is contained in:
@@ -894,10 +894,16 @@ func New(options *Options) *API {
|
||||
)
|
||||
}
|
||||
if hooksConfigured && hooksExperimentEnabled {
|
||||
if chatConfig.HookAllowInsecure.Value() && chatConfig.HookURL.Value().Scheme == "http" {
|
||||
options.Logger.Warn(ctx, "chat hooks use a plain HTTP URL; hook traffic is unencrypted and hook responses controlling agent execution can be forged on the network",
|
||||
slog.F("hook_url", mcpclient.RedactURL(chatConfig.HookURL.String())),
|
||||
)
|
||||
}
|
||||
hookDispatcher = dispatch.New(
|
||||
options.Logger,
|
||||
nil,
|
||||
chatConfig.HookURL.String(),
|
||||
chatConfig.HookAllowInsecure.Value(),
|
||||
chatConfig.HookSecret.Value(),
|
||||
chatConfig.HookTimeout.Value(),
|
||||
api.DeploymentID,
|
||||
|
||||
Reference in New Issue
Block a user