3 hours ago
Hello Railway Team,
I am currently conducting a security review of an application hosted on Railway. Our service uses Railway's public networking with a single replica and no external reverse proxy.
According to Railway's documentation, the X-Real-IP header identifies the client's remote IP address.
Before relying on this header for API rate limiting, I would like to clarify the following:
- Does Railway's Edge Proxy always overwrite any client-supplied
X-Real-IPheader? - Can an external client influence or spoof the
X-Real-IPvalue received by the application, including by sending duplicate headers? - Does Railway overwrite, append to, or preserve client-supplied
X-Forwarded-Forheaders? - Is
X-Real-IPthe recommended trusted source for application-level IP-based rate limiting when using Railway's public networking directly? - Are there any circumstances in which this header may be missing or untrustworthy?
We would appreciate confirmation of the security guarantees and recommended implementation practices.
Thank you for your assistance.
1 Reply
3 hours ago
For requests that come in through our public HTTP edge, we overwrite X-Real-IP, X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host. Any copies the client sends, duplicates included, are replaced. They are not kept or appended to. That means an external client can't pick its own X-Real-IP by sending a forged header through the edge.
X-Real-IP is the right header to use for IP-based rate limiting on public-edge traffic. Don't use the socket peer address: that belongs to our proxy, and we don't publish a stable range for it. Also, Express's req.ip is built from the socket peer and X-Forwarded-For according to trust proxy, so it won't read X-Real-IP on its own.
There are a few cases where the header can't be trusted. Requests over private networking (*.railway.internal) don't go through the edge, so any service in the same environment can reach your port directly and send whatever headers it likes. Any TCP proxy you expose also skips the edge's header handling. Keep in mind too that an IP isn't a lasting identity, since clients can change networks or use a VPN. You can find the header definitions in our public networking specs.
Status changed to Awaiting User Response Railway • about 3 hours ago