Skip to content
Security clarification — X-Real-IP and X-Forwarded-For trust behind Railway Edge
machado470
OP

4 hours ago

Hello Railway team,

We reviewed the previous discussion about X-Real-IP trust guarantees and would appreciate clarification from a Railway engineer regarding our observed production behavior.

Our publicly exposed web service consistently receives:

  • X-Forwarded-For with two public IPv4 entries.
  • X-Real-IP matching the first entry, not the second.
  • A private IPv4 immediate connection peer.

Railway HTTP Logs show a srcIp sharing the visible prefix of the first X-Forwarded-For entry. Exact equality and request-level correlation remain unconfirmed.

Our application currently enforces NO_TRUST for forwarded IP headers.

Could you please clarify:

  1. If Railway Edge overwrites X-Forwarded-For, why might two public IPv4 entries reach our service?
  2. Does another Railway-managed proxy append the second entry?
  3. Is there a supported way to authenticate traffic originating from Railway's public edge versus traffic from other services in the same environment?
  4. Can any forwarding header be safely trusted for security-sensitive rate limiting, and is that behavior covered by a stable documented guarantee?

We are not requesting configuration changes. We need to establish the supported security trust boundary.

Thank you.

Awaiting Railway Response

2 Replies

Railway
BOT

4 hours ago

Our edge replaces any incoming X-Forwarded-For and X-Real-IP values; it does not append to a chain the caller supplied. Replacing the header does not mean it will always have one entry or a fixed number of hops, so seeing two entries does not mean a caller's forged value got through. From here we can't tell you which hop added the second entry, so don't build logic around that two-entry layout staying the same.

There is no supported way to authenticate that traffic came through our public edge. We don't offer a signed forwarding header, an application-visible mTLS identity, or a setting that limits your listening port to edge traffic only. Other services in the same project and environment can reach that port directly over the private network and send any headers they like. The immediate peer address you see is not a published or stable range, so it can't be used as a trust anchor either.

For requests that come through the public edge, X-Real-IP is set by us, and a caller can't control it by sending a forged copy. That makes it the header to use for IP-based rate limiting on that path, as long as every other route to your listener (private-network callers, any TCP proxy) is either trusted or blocked. Our public networking specifications say X-Real-IP is the client's remote IP, and they also say those details can change at any time. Keep in mind that an IP address is not a stable user identity.


Status changed to Awaiting User Response Railway • about 4 hours ago


Railway

Our edge replaces any incoming `X-Forwarded-For` and `X-Real-IP` values; it does not append to a chain the caller supplied. Replacing the header does not mean it will always have one entry or a fixed number of hops, so seeing two entries does not mean a caller's forged value got through. From here we can't tell you which hop added the second entry, so don't build logic around that two-entry layout staying the same. There is no supported way to authenticate that traffic came through our public edge. We don't offer a signed forwarding header, an application-visible mTLS identity, or a setting that limits your listening port to edge traffic only. Other services in the same project and environment can reach that port directly over the private network and send any headers they like. The immediate peer address you see is not a published or stable range, so it can't be used as a trust anchor either. For requests that come through the public edge, `X-Real-IP` is set by us, and a caller can't control it by sending a forged copy. That makes it the header to use for IP-based rate limiting on that path, as long as every other route to your listener (private-network callers, any TCP proxy) is either trusted or blocked. Our [public networking specifications](https://docs.railway.com/networking/public-networking/specs-and-limits#technical-specifications) say `X-Real-IP` is the client's remote IP, and they also say those details can change at any time. Keep in mind that an IP address is not a stable user identity.

machado470
OP

4 hours ago

Thank you for the detailed explanation.

The automated response is helpful, but because this decision affects production security, we would appreciate confirmation from a Railway engineer.

Could a member of the Railway engineering team confirm:

  1. Whether the documented X-Real-IP behavior is a supported security guarantee for public edge traffic.
  2. Whether there is any supported way to distinguish public edge traffic from requests originating within the same environment.
  3. Whether the additional X-Forwarded-For entry can be explained by Railway-managed proxy behavior.

We will maintain our NO_TRUST policy until these trust boundaries are confirmed.

Thank you.


Status changed to Awaiting Railway Response Railway • about 4 hours ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...