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

Repair rate limiter's IP getter #8

Merged
merged 2 commits into from
Jan 14, 2022
Merged

Repair rate limiter's IP getter #8

merged 2 commits into from
Jan 14, 2022

Conversation

steveluscher
Copy link

@steveluscher steveluscher commented Jan 13, 2022

The rate limiter middleware's default key is req.ip but there doesn't appear to be a property called ip on the request that we pass to it here. The actual object we give it is an IncomingMessage and the IP is available as socket.remoteAddress or in the headers.

In this PR, we teach the rate limiter middleware to source the IP address from the x-real-ip header first, and the remoteAddress on the socket second.

@jordaaash
Copy link
Collaborator

source the IP address from the x-real-ip header first

Doesn't this mean a client could lie about its IP by passing this?

@steveluscher
Copy link
Author

I don't think so. Spoof protection is really up to the proxy. When Octane is launched on Vercel, for instance, Vercel itself protects against IP spoofing.

The public IP address of the client that made the request. If you are trying to use Vercel behind a proxy, we currently overwrite the X-Forwarded-For header and do not forward external IPs. This restriction is in place to prevent IP spoofing.

https://vercel.com/docs/concepts/edge-network/headers#x-forwarded-for

@jordaaash jordaaash merged commit fd05065 into anza-xyz:master Jan 14, 2022
@jordaaash
Copy link
Collaborator

Thanks!

@steveluscher steveluscher deleted the repair-ip-getter branch January 16, 2022 06:42
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

Successfully merging this pull request may close these issues.

2 participants