Forged header let script bypass chat rate limit; fixed by trusting only nginx's X-Real-IP

A website's AI chat, used on an outsourcing page to produce project estimates and preview sites, relied on a per-IP rate limit. The server trusted the CF-Connecting-IP header, even though the site was not actually behind Cloudflare, so any client could forge it and appear as a new visitor on every request. The team found that eight requests from one client all succeeded before the fix, and that a global daily cap could then be exhausted by a single script, blocking real visitors. They changed the server to rely only on the X-Real-IP header set by nginx, which overwrites client-supplied values and is reachable only through a localhost-bound Node process. They added tests for rotating forged headers and verified the fix in production using harmless polling requests that returned 429 at the expected limit.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in