← Back to PRs

#16881: fix(gateway): enable auth rate limiting by default

by Limitless2023 open 2026-02-15 06:21 View on GitHub →
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