#16881: fix(gateway): enable auth rate limiting by default
gateway
stale
size: XS
Fixes #16876
## Problem
Auth rate limiting was opt-in only, leaving authentication endpoints vulnerable to brute-force attacks (CVSS 8.8).
## Solution
- Add sensible defaults to rateLimit schema (5 attempts, 60s window, 5min lockout)
- Default rateLimit to {} instead of undefined
- Allow explicit disable via rateLimit: false
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR enables auth rate limiting by default to protect authentication endpoints from brute-force attacks. The schema now provides sensible defaults (5 attempts, 60s window, 5min lockout) and automatically instantiates rate limiting unless explicitly disabled. Previous comments have already identified two critical issues: the schema doesn't support `rateLimit: false` for disabling (despite PR description claiming this), and the default `maxAttempts` changed from 10 to 5 making rate limiting 2x more restrictive than the constant in `auth-rate-limit.ts:75`.
<h3>Confidence Score: 2/5</h3>
- This PR has critical implementation issues that conflict with its own description
- The PR description claims users can disable rate limiting via `rateLimit: false`, but the Zod schema only accepts objects or undefined (not `false`), causing validation errors. Additionally, the schema defaults to 5 max attempts while the code constant specifies 10, creating a silent breaking change that makes rate limiting 2x more restrictive. The TypeScript types also don't support boolean `false` for the `rateLimit` field.
- `src/config/zod-schema.ts` needs the schema fixed to either support `false` or update the PR description, and `src/gateway/auth-rate-limit.ts` constants should match schema defaults
<sub>Last reviewed commit: 1ae4158</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#16963: fix: enable auth rate limiting by default
by StressTestor · 2026-02-15
81.2%
#22766: fix(security): enable gateway auth rate limiting by default (CWE-307)
by brandonwise · 2026-02-21
78.1%
#13686: Add opt-in rate limiting and token-based budgets for external API c...
by ShresthSamyak · 2026-02-10
71.2%
#20381: feat(gateway): make chat history byte limit configurable via `gatew...
by mgratch · 2026-02-18
71.2%
#12499: fix(config): add missing customBindHost to gateway Zod schema
by sfo2001 · 2026-02-09
71.0%
#11371: Auth: cap rate-limit cooldown at 5 minutes; add maxCooldownMinutes ...
by lailoo · 2026-02-07
70.7%
#19429: Fix/custom bind host validation
by frudas24 · 2026-02-17
69.6%
#21529: Gateway: allow node health and throttle repeated unauthorized role ...
by doomsday616 · 2026-02-20
69.3%
#9172: Fix: Add rate limiting to boot-md hook to prevent spam during rapid...
by vishaltandale00 · 2026-02-04
69.2%
#23688: fix(gateway): accept raw IP addresses in gateway.bind for backward ...
by arosstale · 2026-02-22
69.1%