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

Security: Kong allows remote clients to forge remote IP #1661

Closed
kylegato opened this issue Sep 20, 2016 · 3 comments
Closed

Security: Kong allows remote clients to forge remote IP #1661

kylegato opened this issue Sep 20, 2016 · 3 comments
Labels
task/feature Requests for new features in Kong

Comments

@kylegato
Copy link

Summary

We use a Layer 3 load balancer (relayD) to route requests to Kong. Currently with the way kong is setup, the default nginx LUA template includes the following entry:

set_real_ip_from 0.0.0.0/0;

Per the NGINX Documentation: http://nginx.org/en/docs/http/ngx_http_realip_module.html#set_real_ip_from

Defines trusted addresses that are known to send correct replacement addresses. If the special value unix: is specified, all UNIX-domain sockets will be trusted.

It would probably be more ideal if we could supply range(s) of trusted internal IPs instead in the kong configuration, which would be inserted into the LUA config automatically.

Here is a full example:

Command:
kyle$ curl -H "X-Real-IP: 222.222.222.222" -H "X-Forwarded-For: 222.222.222.222" -X GET https://api.kong.qa/kyle

Log Entry on Kong Server:
222.222.222.222 - - [20/Sep/2016:12:34:04 -0700] "GET /kyle HTTP/1.1" 404 249 "-" "curl/7.43.0"

Steps To Reproduce

  1. curl -H "X-Real-IP: 222.222.222.222" -H "X-Forwarded-For: 222.222.222.222" -X GET https://YOUR_KONG_INSTANCE_OR_LOAD_BALANCER
  2. Check your access log files (/usr/local/kong/logs/access.log)

Additional Details & Logs

  • Kong version 0.9.1
  • Operating System CentOS Linux release 7.2.1511 (Core) - Kernel: 3.10.0-327.28.2.el7.x86_64
@thibaultcha
Copy link
Member

Note: somehow related to #1615 (asking for a better configurable behavior of the ngx_http_realip module.

@thibaultcha thibaultcha added the task/feature Requests for new features in Kong label Sep 20, 2016
kylegato pushed a commit to kylegato/kong that referenced this issue Sep 20, 2016
@kylegato
Copy link
Author

@thibaultcha I submitted a PR ^

@thibaultcha
Copy link
Member

thibaultcha commented Mar 14, 2017

Moved to #2202. Thanks!

thibaultcha added a commit that referenced this issue Mar 14, 2017
* Add real_ip_recursive and set_real_ip_from Kong configuration fields to
configure ngx_http_realip_module directives.
* Move the real_ip directives to the Kong proxy location block.
* Add configuration building unit tests for those 2 new directives.

Fix #1661
Deprecates #1662
bungle pushed a commit that referenced this issue Mar 22, 2017
* Add real_ip_recursive and set_real_ip_from Kong configuration fields to
configure ngx_http_realip_module directives.
* Move the real_ip directives to the Kong proxy location block.
* Add configuration building unit tests for those 2 new directives.

Fix #1661
Deprecates #1662
thibaultcha added a commit that referenced this issue Apr 15, 2017
* Add real_ip_recursive and set_real_ip_from Kong configuration fields to
configure ngx_http_realip_module directives.
* Move the real_ip directives to the Kong proxy location block.
* Add configuration building unit tests for those 2 new directives.

Fix #1661
Deprecates #1662
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task/feature Requests for new features in Kong
Projects
None yet
Development

No branches or pull requests

2 participants