1. Trust IPv4 proxies on a dual-stack socket. This bug affects current releases. The image listens on ::, where Node reports an IPv4 peer as ::ffff:10.0.0.5. No IPv4 range matches that form, so a proxy reaching the webmail over IPv4 was never trusted. Its X-Forwarded-For was ignored, and the proxy itself became the client. Behind Caddy, nginx or an ingress, that means:
In password mode, everyone shares one sign-in limit (LOGIN_RATE_LIMIT, 10 per 15 minutes by default). One person guessing locks everyone out.
The logs and the session list name the proxy instead of the user.
The peer is now read in its plain IPv4 form, as the forwarded chain already was. Verified in Node: before the fix, resolveClientIp("::ffff:10.244.1.5", {forwardedFor: "203.0.113.7"}) returned the proxy.
2. Tell the mail server who each request is for. Requests to the mail server now carry X-Forwarded-For with the client address the webmail resolved, replacing anything the browser sent. This goes through upstreamFetch in clientcontext.ts, using AsyncLocalStorage set by a middleware. Without it, the server's limits and bans count all of a replica's users as one address. Fetches for remote images and calendars use a separate path and never carry the header. Requests outside a browser request, such as push, carry none.
3. README: "Several replicas". The webmail's limits count per replica and are a first line only. The server's limits hold across replicas, and need the server to believe the header (INBUXA_HTTP_USE_FORWARDED, inbuxa-server PR).
Tested
4 new unit tests, including one through the real app with a stand-in server. Typecheck, the full suite (316) and the build pass.
On kind, two replicas behind port-forwards acting as the proxy (inbuxa-k8s-lab ratelimit-test.sh):
Replica A refuses one client at attempt 201.
Replica B still starts that client's sign-in.
Replica A still starts a second client's sign-in, which shows it counts the browser and not the proxy.
frontends-test.sh passes.
Should ship in 27.1-rc.7. Since part 1 affects running deployments, it might also be worth a note in the release, or an advisory if you want one.
K-W3 (#105), plus a bug it turned up.
**1. Trust IPv4 proxies on a dual-stack socket. This bug affects current releases.** The image listens on `::`, where Node reports an IPv4 peer as `::ffff:10.0.0.5`. No IPv4 range matches that form, so a proxy reaching the webmail over IPv4 was never trusted. Its `X-Forwarded-For` was ignored, and the proxy itself became the client. Behind Caddy, nginx or an ingress, that means:
- In password mode, everyone shares one sign-in limit (`LOGIN_RATE_LIMIT`, 10 per 15 minutes by default). One person guessing locks everyone out.
- The logs and the session list name the proxy instead of the user.
The peer is now read in its plain IPv4 form, as the forwarded chain already was. Verified in Node: before the fix, `resolveClientIp("::ffff:10.244.1.5", {forwardedFor: "203.0.113.7"})` returned the proxy.
**2. Tell the mail server who each request is for.** Requests to the mail server now carry `X-Forwarded-For` with the client address the webmail resolved, replacing anything the browser sent. This goes through `upstreamFetch` in `clientcontext.ts`, using AsyncLocalStorage set by a middleware. Without it, the server's limits and bans count all of a replica's users as one address. Fetches for remote images and calendars use a separate path and never carry the header. Requests outside a browser request, such as push, carry none.
**3. README: "Several replicas".** The webmail's limits count per replica and are a first line only. The server's limits hold across replicas, and need the server to believe the header (`INBUXA_HTTP_USE_FORWARDED`, inbuxa-server PR).
**Tested**
- 4 new unit tests, including one through the real app with a stand-in server. Typecheck, the full suite (316) and the build pass.
- On kind, two replicas behind port-forwards acting as the proxy (inbuxa-k8s-lab `ratelimit-test.sh`):
- Replica A refuses one client at attempt 201.
- Replica B still starts that client's sign-in.
- Replica A still starts a second client's sign-in, which shows it counts the browser and not the proxy.
- `frontends-test.sh` passes.
Should ship in 27.1-rc.7. Since part 1 affects running deployments, it might also be worth a note in the release, or an advisory if you want one.
Every request the webmail makes comes from the webmail's own address, so
the server's limits and bans counted all of a replica's users as one
client: a hundred wrong passwords in a day between them, or a hundred new
tokens in a minute, locked everyone on that replica out.
Requests to the mail server now carry X-Forwarded-For with the client
address the webmail resolved (TRUSTED_PROXIES), replacing any the browser
sent. Fetches for remote images and calendars never carry it.
README: how the limits behave with several replicas (K-W3).
The image listens on ::, where Node reports an IPv4 peer as
::ffff:10.0.0.5. No IPv4 range matches that form, so every proxy reaching
the webmail over IPv4 looked untrusted: its X-Forwarded-For was ignored and
the proxy itself became the client. Behind Caddy, nginx or an ingress, all
users then shared one sign-in limit and one address in the logs.
The peer is now read in its plain IPv4 form, as the forwarded chain
already was.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
K-W3 (#105), plus a bug it turned up.
1. Trust IPv4 proxies on a dual-stack socket. This bug affects current releases. The image listens on
::, where Node reports an IPv4 peer as::ffff:10.0.0.5. No IPv4 range matches that form, so a proxy reaching the webmail over IPv4 was never trusted. ItsX-Forwarded-Forwas ignored, and the proxy itself became the client. Behind Caddy, nginx or an ingress, that means:LOGIN_RATE_LIMIT, 10 per 15 minutes by default). One person guessing locks everyone out.The peer is now read in its plain IPv4 form, as the forwarded chain already was. Verified in Node: before the fix,
resolveClientIp("::ffff:10.244.1.5", {forwardedFor: "203.0.113.7"})returned the proxy.2. Tell the mail server who each request is for. Requests to the mail server now carry
X-Forwarded-Forwith the client address the webmail resolved, replacing anything the browser sent. This goes throughupstreamFetchinclientcontext.ts, using AsyncLocalStorage set by a middleware. Without it, the server's limits and bans count all of a replica's users as one address. Fetches for remote images and calendars use a separate path and never carry the header. Requests outside a browser request, such as push, carry none.3. README: "Several replicas". The webmail's limits count per replica and are a first line only. The server's limits hold across replicas, and need the server to believe the header (
INBUXA_HTTP_USE_FORWARDED, inbuxa-server PR).Tested
ratelimit-test.sh):frontends-test.shpasses.Should ship in 27.1-rc.7. Since part 1 affects running deployments, it might also be worth a note in the release, or an advisory if you want one.