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

API Key with IP address restriction block all IP including whitelisted #72

Closed
volodymyrd opened this issue Jun 15, 2020 · 3 comments
Closed
Assignees

Comments

@volodymyrd
Copy link

I've created ESPv2 Cloud Endpoint for my API, everything works fine except when I enabling IP address restriction in API Key, I get a message "PERMISSION_DENIED: IP address blocked." for all requests including whitelisted IP addresses.

What you expected to happen:
Block all requests except whitelisted.

Steps to reproduce:
Create IP restriction for API Key for Endpoint base on ESPv2.

I've checked the endpoint logs and see the internal google IP address instead of my IP address from which I send a request, a corresponding screenshot is attached.
Screenshot 2020-06-13 at 14 41 40

@nareddyt nareddyt self-assigned this Jun 15, 2020
@nareddyt
Copy link

nareddyt commented Jun 15, 2020

Thanks for reporting. We are aware of this issue and have a workaround, but I agree it's not the best solution.

Background: ESPv2 uses the standard X-Forwarded-For header to determine the client IP. This contains the client IP address and also a list of any proxies the request was forwarded through (Google Front End, Cloud Run's, etc). It's difficult for ESPv2 to know which index to use in the list; different platforms / deployments have a different number of proxies. ESPv2 doesn't blindly just take the first index because it can be spoofed.

We have a ESPv2 flag that tells ESP which index to use. By default, it uses the 2nd index from the end of the list. If you're seeing a Google internal IP, then you can increase the value of the --envoy_xff_num_trusted_hops ESPv2 flag. Maybe 3 or 4 would work to use an earlier index? I never tested this out.

Reference: https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/headers#config-http-conn-man-headers-x-forwarded-for

@qiwzhang
Copy link
Contributor

qiwzhang commented Jun 15, 2020 via email

@volodymyrd
Copy link
Author

Thanks, for me, works:
--envoy_xff_num_trusted_hops=1
--envoy_use_remote_address

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

No branches or pull requests

3 participants