-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
auth-signin annotation fails validation with encoded url characters #12764
Comments
This issue is currently awaiting triage. If Ingress contributors determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Is it safe to allow escape characters ? |
Assuming you mean url-encoded characters, I'd say it safe, yes, in fact almost required. In the instance above, I'm passing a redirect through to an oauth2-proxy, and this redirect will need to be escaped so it's not evaluated as part of the auth-signin value. If adding a % to the validation is allowing too much, we could adjust the validator for this annotation to decode the url encoded values before validating, but then pass the encoded values to the actual annotation? This could ensure the validator is strict on allowed characters whilst also allowing for these redirects? |
There is a history of CVEs related that is behind limiting characters. I understand it would help a lot but having to choose between a feature and security comes into picture here. |
It starts failing because we enabled annotation validation by default in v1.12.0. Apart from that I currently cannot help a lot nor take a deeper look into the issue. |
@Gacko , cause is the use of "%something" (encoded) chars which the code link pointed earlier shows as not allowed. I think that allowing that would cause a CVE potentially, on the lines that allowing those chars can potentially drop to shell or malware execution. |
I understand where you're coming from - would the decode-then-validate approach I mentioned earlier not reduce some of this risk? As it'll be checking the decoded value to inhibit malicious characters? Another way I'm looking at it is as url-encoded characters may be needed for some projects to redirect correctly, and as these are now going to stop working, the easiest solution for users here is just to manually re-disable annotation validation - which is going to make all these projects inherently less secure? This is, admittedly, then a risk the user is accepting by doing this themselves, and obviously security by default should be the way to go for the project - but I can see it forcing a subset of users to either having to lower their protection or having to spend time altering their projects to account for the inability to do url encoded characters. Maybe worth a thought at some extended URL annotation validation as other annotations could be affected. |
@jasday 100% agree with your comments. You are absolutely right on all 3 counts. So beyond this is the project's capability to allocate developer to it and unfortunately we don't have that option. All resources are dedicated to the making the project secure out of the box and acceptably stable, give tne circumstances. That is besides working on the Gatway-API implementation. If a PR comes in with the appropriate info in description and is admittedly bundled with tests that are a improvement to the e2e-tests, for the auth feature, at least a review would in the pipeline. My worry is the depth needed to allow characters and encoded URLs without re-introducing the CVE is talked about. No idea how this will be possible. |
That's understandable - I'll see if i can find some time to do a deeper investigation and get a PR up if it's feasible. For now, (for anyone else running into the same issue) I'll be disabling annotation validation. Happy to change this issue from bug to a feature request for updated URL validation |
What happened:
auth-signin
annotation validation does not allow url-encoded values. This causes an error when the annotation is being loaded:What you expected to happen:
This should pass validation and be accepted.
NGINX Ingress controller version:
Kubernetes version (use
kubectl version
):Environment:
Cloud provider or hardware configuration: AWS EKS Auto Mode
OS (e.g. from /etc/os-release): Linux
Install tools:
Basic cluster related info:
Others:
I believe https://github.com/kubernetes/ingress-nginx/blob/main/internal/ingress/annotations/parser/validators.go#L47 should be changed to:
urlEnabledChars = regexp.QuoteMeta(',:?&=%')
How to reproduce this issue:
Create an ingress with the nginx.ingress.kubernetes.io/auth-signin: annotation, add an encoded character within the value (e.g https:// -> https%3A%2F%2F).
Anything else we need to know:
This was working in
v1.11.3
and stopped working when upgrading tov1.12.0
Happy to make a pull request with the changes required, but wanted this to go up first in case there was a specific reason for disallowing the character.
The text was updated successfully, but these errors were encountered: