Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent X-Forwareded-For header passing from untrusted upstreams #1974

Open
SilverFire opened this issue Apr 26, 2022 · 4 comments
Open

Prevent X-Forwareded-For header passing from untrusted upstreams #1974

SilverFire opened this issue Apr 26, 2022 · 4 comments

Comments

@SilverFire
Copy link
Contributor

Incoming HTTP requests may contain X-Forwarded-For header, sent by a client to bypass the client application IP restrictions or rate limiters and fake the client IP address. Currently, nginx-proxy trusts this header and passes it to the downstream.

This is a pretty serious flaw that requires a CVE registration, as it happened in other OpenSource projects: CVE-2020-28483 for go/gin, CVE-2020-35590 for WordPress, CVE-2020-13485 for CraftCMS.

The application developers usually specify trusted proxy server IP addresses explicitly and frameworks and proxies provide properties for this kind of configuration. For example, Symfony – PHP framework, Express – JS framework, Gin – Go framework, Traefik Proxy

I suggest introducing a TRUST_FORWARDED_HEADERS, which takes a comma-separated list of IP networks, that are trusted. X-Forwarded headers from these networks should be passed to the downstream only if the request address is trusted.

@SilverFire
Copy link
Contributor Author

Discussion has started in #1927

@rhansen
Copy link
Collaborator

rhansen commented Apr 27, 2022

You have upstream and downstream backwards: The client is downstream of the reverse proxy, and the backend server is upstream of the NGINX reverse proxy.

@SilverFire
Copy link
Contributor Author

Never thought about it this way, and it depends, as I see https://stackoverflow.com/a/32365658

If you prefer calling them vise-versa in this project – let me know, I'm OK with that.

@rhansen
Copy link
Collaborator

rhansen commented Apr 30, 2022

I think it's important to be consistent with NGINX, and NGINX uses "upstream" to refer to the backend server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants