Commit 69d9088
fix(server): resilient rate-limit key + narrower trustProxy for reverse-proxy setups (#1303)
Two production fixes triggered by the fastify 5.8.5 security patch for
CVE-2026-33806 (trustProxy socketAddr null-check). Under the tightened
code path, `request.ip` can resolve to `undefined` when the raw TCP
socket lacks metadata, which collapses `@fastify/rate-limit`'s default
`keyGenerator` (which uses `request.ip`) to a single `undefined`
bucket — effectively shared across all unknown-IP callers.
Changes:
- `server/src/plugins/rateLimitPlugin.ts`: add explicit keyGenerator
that falls back through `request.ip` → first x-forwarded-for →
x-real-ip → literal "unknown". Unknown-IP requests are still
rate-limited (bucketed as "unknown") rather than silently shared.
- `server/src/app.ts`: pass `trustProxy: 1` (number of hops) instead
of boolean `true`. We sit behind exactly one reverse proxy in
production; the number-based path is the more precise and robust
semantic, and it's the code path explicitly restored/hardened in
5.8.5 per the CVE advisory.
Public `/api/config` still exposes `trustProxy` as boolean — the
external contract is unchanged. Only the Fastify constructor arg is
narrowed.
Unblocks PR #1215 (beta → main promotion) E2E Gates by fixing the
`proxy-setup.spec.ts:186` X-Forwarded-For regression.
Co-authored-by: Frank Steiler <frank@steiler.de>
Co-authored-by: Claude backend-developer (Haiku 4.5) <noreply@anthropic.com>1 parent 74c7191 commit 69d9088
3 files changed
Lines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
11 | 24 | | |
12 | 25 | | |
13 | 26 | | |
| |||
Submodule wiki updated from e31af42 to d372bdd
0 commit comments