#23763: Hooks: require session key prefixes for request override
gateway
size: XS
trusted-contributor
Cluster:
Gateway and Hooks Enhancements
## Summary
- fail closed when `hooks.allowRequestSessionKey=true` but `hooks.allowedSessionKeyPrefixes` is unset/empty
- preserve existing prefix/default-session validation logic
- add tests for new startup validation and explicit allow path
## Testing
- pnpm lint
- pnpm vitest run src/gateway/hooks.test.ts
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds startup validation to fail closed when request session key override is enabled but allowed session key prefixes are unset or empty. This prevents a security misconfiguration where external hook requests could provide arbitrary session keys without prefix restrictions. The change preserves all existing validation logic for prefix matching and default session keys.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The change adds critical security validation with comprehensive test coverage, follows the repository's existing patterns, and has no breaking changes to correct configurations
- No files require special attention
<sub>Last reviewed commit: eda343b</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#23410: Gateway: require prefixes for hook request session-key overrides
by bmendonca3 · 2026-02-22
86.0%
#23525: fix: include sessionKey in session_start/session_end hook context
by p697 · 2026-02-22
77.5%
#9782: feat(hooks): implement session:start and session:end lifecycle events
by kentaro · 2026-02-05
77.2%
#8431: Hooks: add session-graphiti memory feed
by JorgeAlan · 2026-02-04
76.4%
#23765: Gateway hooks: enforce JSON content type and strict payload keys
by bmendonca3 · 2026-02-22
75.8%
#10679: fix(hooks): invoke gateway_start and gateway_stop in lifecycle
by yassinebkr · 2026-02-06
74.6%
#3392: fix(hooks): remove debug console.log statements from session-memory...
by WinJayX · 2026-01-28
74.5%
#11794: fix(gateway): validate session key ownership against authenticated ...
by coygeek · 2026-02-08
74.4%
#15571: feat: infrastructure foundation — hooks, model failover, sessions, ...
by tangcruz · 2026-02-13
74.4%
#6405: feat(security): Add HTTP API security hooks for plugin scanning
by masterfung · 2026-02-01
74.2%