Title: Rate-limit keyGenerator uses request.ip — spoofable in non-proxied deployments · Issue #356 · JavaScriptSolidServer/JavaScriptSolidServer · GitHub
Open Graph Title: Rate-limit keyGenerator uses request.ip — spoofable in non-proxied deployments · Issue #356 · JavaScriptSolidServer/JavaScriptSolidServer
X Title: Rate-limit keyGenerator uses request.ip — spoofable in non-proxied deployments · Issue #356 · JavaScriptSolidServer/JavaScriptSolidServer
Description: Summary Rate-limited IDP routes use `(request) => request.ip` as the keyGenerator. Because the Fastify server is configured with `trustProxy: true`, `request.ip` is derived from `X-Forwarded-For` when present. In any deployment where JSS...
Open Graph Description: Summary Rate-limited IDP routes use `(request) => request.ip` as the keyGenerator. Because the Fastify server is configured with `trustProxy: true`, `request.ip` is derived from `X-Forwarded-For` w...
X Description: Summary Rate-limited IDP routes use `(request) => request.ip` as the keyGenerator. Because the Fastify server is configured with `trustProxy: true`, `request.ip` is derived from `X-Forwarded-For...
Opengraph URL: https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/356
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Rate-limit keyGenerator uses request.ip — spoofable in non-proxied deployments","articleBody":"## Summary\n\nRate-limited IDP routes use \\`(request) => request.ip\\` as the keyGenerator. Because the Fastify server is configured with \\`trustProxy: true\\`, \\`request.ip\\` is derived from \\`X-Forwarded-For\\` when present. In any deployment where JSS is **not** behind a proxy (or is misconfigured behind one that doesn't strip client-supplied \\`X-Forwarded-For\\`), an attacker can rotate that header to bypass the per-IP limit.\n\nAffected endpoints (today):\n\n- \\`POST /idp/credentials\\` — login brute-force protection\n- \\`POST /idp/interaction/:uid\\` — login form brute-force protection\n- \\`PUT /idp/credentials\\` — password-rotation brute-force (added in #351 / PR #355)\n\nAnywhere else that uses the same \\`config.rateLimit.keyGenerator: (request) => request.ip\\` pattern.\n\n## Why this matters\n\nBrute-force protection is the *only* thing standing between bcrypt and a credential-stuffing attacker. A spoofable key generator effectively neutralizes it.\n\n## Options\n\n### A. Trust the TCP-level address\n\\`\\`\\`js\nkeyGenerator: (request) => request.socket.remoteAddress\n\\`\\`\\`\n- Cannot be spoofed from a remote attacker\n- Breaks behind a real reverse proxy: every request appears to come from the proxy IP, so legit users share a single rate-limit bucket\n\n### B. Tighten \\`trustProxy\\` to known proxies\nConfigure \\`trustProxy\\` with a list of trusted IPs (e.g. \\`['127.0.0.1', '::1']\\`) instead of the boolean \\`true\\`. \\`request.ip\\` then only honors \\`X-Forwarded-For\\` from those addresses.\n- Correct under both deployment modes (proxied + non-proxied)\n- Requires the operator to configure proxy IPs explicitly\n\n### C. Document the deployment requirement\nAdd a deployment note: \"If running JSS without a reverse proxy, set \\`trustProxy: false\\`.\"\n- Cheapest fix, but easy to miss\n\n## Recommendation\n\n**B + C combined.** Default \\`trustProxy\\` to \\`'loopback'\\` (Fastify supports this string shorthand) so localhost proxies work out of the box but external \\`X-Forwarded-For\\` is ignored. Operators with non-loopback proxies set the list explicitly. Document in deployment notes.\n\n## Acceptance\n\n- [ ] Audit all \\`keyGenerator: (request) => request.ip\\` callsites\n- [ ] Decide on the trustProxy default (recommend \\`'loopback'\\` over \\`true\\`)\n- [ ] Update config schema + envMap to support a trust-proxy IP list\n- [ ] Tests: spoofed \\`X-Forwarded-For\\` does not bypass rate limit on default config\n- [ ] Document in deployment guide\n\n## Context\n\nSpotted by Copilot on PR #355. Predates that PR — same pattern is on existing \\`POST\\` routes. Filing for a server-wide fix rather than touching it just on the new \\`PUT\\`.","author":{"url":"https://github.com/melvincarvalho","@type":"Person","name":"melvincarvalho"},"datePublished":"2026-05-03T14:07:05Z","url":"https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/356"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0194128d-0c7f-80e9-7384-41edf441b726 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8384:1B316D:96504C:C77EE7:6B03A2B6 |
| html-safe-nonce | ccdebba63e47ae3156a1f35eb1ebc284a143cb9717c6346e67f34e219f1e2f94 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Mzg0OjFCMzE2RDo5NjUwNEM6Qzc3RUU3OjZCMDNBMkI2IiwidmlzaXRvcl9pZCI6IjQxODkyNTI0NTQ1MzUzNzM0OTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8359912a3536ff846e9f66194e41d2cf75f341dad5206b13d38f5d65cffa59d7 |
| hovercard-subject-tag | issue:4372006605 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JavaScriptSolidServer/JavaScriptSolidServer/356/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e3d15b5bca40340f57a853526e2e85fb8594c728a481e9997e30e6cb3cd1eaed/JavaScriptSolidServer/JavaScriptSolidServer/issues/356 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e3d15b5bca40340f57a853526e2e85fb8594c728a481e9997e30e6cb3cd1eaed/JavaScriptSolidServer/JavaScriptSolidServer/issues/356 |
| og:image:alt | Summary Rate-limited IDP routes use `(request) => request.ip` as the keyGenerator. Because the Fastify server is configured with `trustProxy: true`, `request.ip` is derived from `X-Forwarded-For` w... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | melvincarvalho |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/JavaScriptSolidServer/JavaScriptSolidServer git https://github.com/JavaScriptSolidServer/JavaScriptSolidServer.git |
| octolytics-dimension-user_id | 205442424 |
| octolytics-dimension-user_login | JavaScriptSolidServer |
| octolytics-dimension-repository_id | 958025407 |
| octolytics-dimension-repository_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 958025407 |
| octolytics-dimension-repository_network_root_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width