3 ms·
Probably a misconfiguration involving X-Forwarded-For. The frontend sticks the IP in there, you set your backend to trust X-Forwarded-For headers from, say, 10
by jrockway 7y ago
Probably a misconfiguration involving X-Forwarded-For. The frontend sticks the IP in there, you set your backend to trust X-Forwarded-For headers from, say, 10.0.0.0/8, but somehow your frontend and backend end up on the machine and the connection comes from 127.0.0.1 and fails the check for a connection from 10.0.0.0/8. So you distrust X-Forwarded-For and just log the IP address that the TCP connection came from, which was 127.0.0.1.
I have never been able to make sense of all the rules around X-Forwarded-For and neither have the various library implementers. I recently wrote an authentication plugin for Envoy that just extracts what Envoy thinks the remote address is, and puts it in the authentication header that goes to the backend. Then the backends can't get it wrong; if the signature on the message is right, you're getting the IP address that the frontend Envoy got. If something is misconfigured, the header probably won't have a valid signature, and so the request will be rejected outright. Less failsafe than what Wikipedia did... but easier to detect.
- dehrmann 7y ago> I have never been able to make sense of all the rules around X-Forwarded-For and neither have the various library implementers There are no rules. I only trust it for internal (LB->service) requests, and never have more than one address.
- leetrout 7y ago> and never have more than one address That’s important if you don’t control all the systems. Back to there being no rules some systems prepend addresses at each layer and some append them. And if you don’t know or don’t control the behavior at each layer it’s useless IP soup. I’ve not dealt with that in a long while but your comment brought back memories.
- pas 7y agoTo solve the append/prepend dilemma there's also X-Real-IP too. (At least the Nginx module does this.) So basically just log the x-f-f and use the other one as the real client IP. Of course, if you don't control the layers, then probably you should consider those headers invalid for an incoming request. (Though for email there's ARC to sign the added headers, maybe if someone really wants to provide at least marginally accountable HTTP proxies, they can use something like that.)