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

breaking change: by default do not trust any client #3333

Merged
merged 1 commit into from
Nov 27, 2018

Conversation

ElvinEfendi
Copy link
Member

What this PR does / why we need it:

Currently we configure Nginx in a way that it trusts any client to extract true client IP address from X-Forwarded-For header using realip module. This PR makes it so that by default it does not trust any client at all.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 31, 2018
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 31, 2018
@Dirbaio
Copy link
Contributor

Dirbaio commented Oct 31, 2018

This change makes nginx-ingress not trust the IP for the X-Forwarded-For header, but the client can still spoof X-Forwarded-Host, X-Forwarded-Port, X-Forwarded-Proto, X-Scheme

The correct change to the defaults would be UseForwardedHeaders: False (and leave ProxyRealIPCIDR as is)

I 100% support setting UseForwardedHeaders: False by default. I was also accidentally vulnerable to IP spoofing due to this. nginx-ingress should be secure by default.

@ElvinEfendi
Copy link
Member Author

but the client can still spoof X-Forwarded-Host, X-Forwarded-Port, X-Forwarded-Proto, X-Scheme

@Dirbaio is there any practical security implication with this?

I agree that modifying UseForwardedHeaders is better since not using them is a default Nginx behaviour.

@Dirbaio
Copy link
Contributor

Dirbaio commented Nov 11, 2018

They're more rare, but there are indeed vulnerabilities that can be caused by the other X-Forwarded-* headers spoofing.

For example: Software often uses X-Forwarded-Host, X-Forwarded-Scheme to build "links to itself" to use in emails and such. If you can mess with these, you can make these links go somewhere else, which can be bad for password reset emails, for example.

Aside from vulns, disabling all X-Forwarded-* headers is the best option for consistency. It would be strange that only the IP one is disabled.

@ElvinEfendi ElvinEfendi changed the title by default do not trust any client breaking change: by default do not trust any client Nov 13, 2018
@aledbf
Copy link
Member

aledbf commented Nov 27, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 27, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aledbf, ElvinEfendi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 710ea8c into kubernetes:master Nov 27, 2018
@ElvinEfendi ElvinEfendi deleted the dont-trust-by-default branch November 27, 2018 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants