#8121: fix(gateway): remove query parameter token support for hooks
gateway
stale
Cluster:
Security Enhancements and Guardrails
## Summary
Remove support for hook authentication tokens in URL query parameters to prevent credential leakage (CWE-598).
## The Problem
The hook endpoint accepted authentication tokens via URL query parameters (`?token=...`). Tokens in URLs leak through multiple vectors:
- Server access logs
- Browser history
- HTTP Referer headers when linking to external sites
- Reverse proxy logs (nginx, cloudflare, etc.)
- CDN logs
- Monitoring and debugging tools
While a deprecation warning was logged, the feature remained functional.
## Changes
- `src/gateway/hooks.ts`: Removed query parameter token extraction from `extractHookToken()`
- `src/gateway/server-http.ts`: Removed the deprecation warning (now dead code)
- `src/gateway/hooks.test.ts`: Updated test to verify query tokens are rejected
## Test Plan
- [x] `pnpm build && pnpm test` passes
- [x] Test `extractHookToken prefers bearer > header, rejects query params` validates fix
- [x] Gateway tests pass (208 tests)
Hook authentication now only accepts tokens via:
- `Authorization: Bearer <token>` header
- `X-OpenClaw-Token` header
## Related
- [CWE-598: Use of GET Request Method with Sensitive Query Strings](https://cwe.mitre.org/data/definitions/598.html)
---
Internal reference: VULN-007
This PR was generated with the following prompt:
> Remove query parameter token support from hook authentication to prevent credential leakage (CWE-598)
🤖 Discovered by [bitsec.ai](https://bitsec.ai)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR removes hook authentication via `token` URL query parameters and updates the gateway handler/tests accordingly, leaving hook auth to `Authorization: Bearer …` or `X-OpenClaw-Token` headers only. This reduces credential leakage via URL logging/referrers and simplifies the hook request handler by removing the now-dead deprecation warning branch.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with low risk; it’s a targeted security hardening change with aligned tests.
- Diff is small and behavior change is intentional (rejecting query tokens). Unit test updates cover the main auth precedence and the removal of query-param acceptance; no other callers of `extractHookToken` exist beyond the gateway handler and tests.
- src/gateway/hooks.ts (API shape: `fromQuery` now constant false)
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19785: fix(gateway): support query parameter tokens for webhooks
by cfdude · 2026-02-18
84.6%
#14197: fix(security): harden browser API auth, token comparisons, and hook...
by leecarollyn-gif · 2026-02-11
77.9%
#6405: feat(security): Add HTTP API security hooks for plugin scanning
by masterfung · 2026-02-01
77.3%
#23410: Gateway: require prefixes for hook request session-key overrides
by bmendonca3 · 2026-02-22
77.1%
#19885: test(gateway,browser): isolate tests from ambient OPENCLAW_GATEWAY_...
by NewdlDewdl · 2026-02-18
77.0%
#10679: fix(hooks): invoke gateway_start and gateway_stop in lifecycle
by yassinebkr · 2026-02-06
76.5%
#13144: harden archive extraction, auth tokens, hook transforms, and queue ...
by qxlsz · 2026-02-10
76.2%
#23447: Gateway: harden hook ingress content-type validation
by bmendonca3 · 2026-02-22
75.9%
#23765: Gateway hooks: enforce JSON content type and strict payload keys
by bmendonca3 · 2026-02-22
75.7%
#22766: fix(security): enable gateway auth rate limiting by default (CWE-307)
by brandonwise · 2026-02-21
75.7%