Skip to content

fix: harden config UI, rate limiting, command execution and hook parsing - #208

Merged
soulteary merged 3 commits into
mainfrom
fix/security-hardening
Nov 13, 2026
Merged

soulteary merged 3 commits into
mainfrom
fix/security-hardening

Conversation

@soulteary

Copy link
Copy Markdown
Owner

Summary

Security and reliability fixes found in a code audit. Details per change are in the Unreleased section of CHANGELOG.md.

Security

  • Config UI save API (POST {config-ui-path}/api/save) was unauthenticated: anyone reaching the port could write a hook file and trigger it. It is now disabled unless -config-ui-token / CONFIG_UI_TOKEN is set, and requires the token in X-Config-UI-Token, a JSON content type and a same-origin request.
  • Rate limiting no longer trusts client-supplied X-Forwarded-For / X-Real-IP unless the peer is listed in the new -trusted-proxies. New -rate-limit-per-ip-rps / -rate-limit-per-ip-burst (default 0 = same as global).
  • HMAC rules now cover the raw body of multipart/form-data requests (previously an empty body was signed).
  • A value match rule with an empty configured value never matches.
  • Command allowlist matches by path component and resolves symlinks (/opt/hooks used to allow /opt/hooks-evil/run.sh).
  • Client X-Request-Id is discarded unless -x-request-id is on; -x-request-id-limit is enforced.
  • Command arguments in execution error logs are sanitized.

Reliability

  • Hook timeout kills the whole process group (Unix) and Wait is bounded, so the executor slot is always released.
  • Async hooks reserve an execution slot before responding; 503 + Retry-After when saturated instead of 200-then-drop.
  • pass-file-to-command temp files are removed when no working directory is set.
  • Fixed: ip-whitelist with mixed address families, panics in signature helpers and parse-parameters-as-json, body aliasing in the Scalr check, a data race in ExtractCommandArgumentsForFile.
  • Unknown hook-file keys log a warning in compatible mode.
  • Redis health check sends a real PING.
  • HTTP server shuts down before audit logging and tracing.
  • -max-header-bytes applies when set to a non-default value; -read-header-timeout-seconds logs a warning (cannot be applied on fasthttp).

Behaviour changes to review

  • Config UI "Save to directory" stops working until -config-ui-token is configured.
  • Rate-limited deployments behind a reverse proxy must set -trusted-proxies, otherwise all requests share the proxy's quota.
  • Async hook senders may now receive 503 under saturation.
  • An allowlisted directory containing symlinks to scripts outside it will now reject those scripts.

Testing

  • go test ./... passes (24 packages), go vet and gofmt clean, -race run on hook, server, security, middleware.
  • New regression tests for most fixes; several were confirmed to fail with the fix reverted.
  • Not covered by tests: Config UI frontend change (app.js, not exercised in a browser), Redis PING health check (no Redis available), unknown-key warning, shutdown ordering, -max-header-bytes mapping.
  • Process-group kill is a no-op on Windows.

🤖 Generated with Claude Code

Security
- Config UI save API requires -config-ui-token, JSON content type and a
  same-origin request; disabled when no token is configured
- Rate limiting ignores X-Forwarded-For / X-Real-IP unless the peer is
  listed in -trusted-proxies; add per-IP quota flags
- HMAC signature rules cover the raw multipart/form-data body
- Empty configured value in a `value` match rule never matches
- Command allowlist matches by path component and resolves symlinks
- Client X-Request-Id is discarded unless -x-request-id is set, and
  -x-request-id-limit is enforced
- Sanitize command arguments in execution error logs

Reliability
- Kill the whole process group on hook timeout (Unix) and bound Wait
- Async hooks reserve an execution slot before responding; 503 with
  Retry-After when saturated
- Remove pass-file-to-command temp files when no working directory is set
- Fix ip-whitelist with mixed address families, panics in signature
  helpers and parse-parameters-as-json, body aliasing in the Scalr check
  and a data race in ExtractCommandArgumentsForFile
- Warn about unknown hook file keys in compatible mode
- Redis health check sends a real PING
- Shut down the HTTP server before audit logging and tracing
- Apply -max-header-bytes when set to a non-default value

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 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-12T22:45:53.777537Z 4c87a51 PR opened
ℹ️ 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: 4c87a51792

ℹ️ 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 internal/middleware/ratelimit.go Resolved
Comment thread internal/configui/configui.go Fixed
Comment thread internal/flags/define.go Fixed
soulteary and others added 2 commits November 13, 2026 06:54
…ed-usr Linux

- Requests rejected by the per-IP quota no longer consume global capacity
  (in-memory and Redis paths), so one client over its limit cannot starve
  others.
- Allowlist tests no longer use /bin/sh as the "outside" path: on systems
  where /bin is a symlink to /usr/bin it really is inside /usr/bin.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The flagged constants are an HTTP header name and an environment
variable name, not credentials.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@soulteary
soulteary merged commit e00ac78 into main Nov 13, 2026
13 checks passed
@soulteary
soulteary deleted the fix/security-hardening branch November 13, 2026 15:38
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.

2 participants