-
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
Validation of URLs does not comply with RFCs (e.g. app-root annotation, ingress path) #12822
Comments
Check if you know the other config for risklevel and see current risk level. I think it needs to be higher. |
/remove-kind bug |
Hi @longwuyuan, Thanks for having a look. As already said, it's not really an "issue" for us (we have a workaround therefor). We also already increased the risk-level using But thats not my point of raising this Issue. My point was to discuss if this is correct spec-conform behavior or if a URL containing Please check the |
Maybe this issue should be more generic about "URL validation is not spec-conform" rather than the specific issues about specific annotations like The main validation of URLs in ingress-nginx seems to handcrafted (see validators.go for annotations and rules.go for ingress path). Using handcrafted regex for proper URL validation might not be the best choice, since I can already see many cases of validated Ingress paths (
All of the mentioned examples above MUST be allowed as valid paths within an Ingress resource. RFC 3986 clearly states that the following (unreserved) characters are valid:
Probably a proper library therefor like |
Please wait for @Gacko @strongjz @tao12345666333 to comment There is a flip side to this. I think its important to note that while making all good stuff possible, most parts of the controller code, that is not directly about the Ingress-API, does not use a framework or such resource with tons of developers behind it. Hence there is rampant misuse to say the least. Its so severe that we have had to deprecate fully functional and extremely useful, popular features, because there is not even developers to secure it and make stable reliable releases. |
That is exactly the point. Validating well defined (I'd even go as far to call them standardized) strings / values WITHOUT a library creates even more work (bugs). Excuse my french, but writing your own regexes to validate REALLY complicated, complex and still evolving data structures such as URL / URI / email addresses ... is like rolling your own crypto. |
I don't have a lot of time to go through the whole issue, but from what I read in a few seconds: Have you actually checked if everything including and behind the |
The problem itself is only the validation of this annotation (as well as other configs like ingress paths). Implementation works fine if validation is disabled. As stated above:
For ingress paths you are right @Gacko. Fragments/Anchors do not need to be valid for paths. The |
TL;DR: We have two different issues we are talking about (my bad that I mixed them into one GitHub issue, sorry). Both issues are related to handcrafted regex (kind of same cause). Issue
Issue Ingress path validation:
If you want me to, I could split them into distinct issues. But since they both rely on regex which do not comply to RFCs, maybe this could be a aligned fix for both. |
/triage accepted |
What happened:
An ingress containing an anchor within the
app-root
redirect annotation fails validation:nginx.ingress.kubernetes.io/app-root: /_dashboards/app/home#/
What you expected to happen:
After updating Ingress-Nginx to
1.12.0
release, we encountered the following issue withapp-root
annotation. The "issue" itself was not introduced within1.12.0
but was realized because of the new default enablement of--enable-annotation-validation
(see flags.go).So far so good, we are wondering why this specific annotation validation should fail in our case:
The Ingress itself is related to an OpenSearch installation which uses anchor/fragments for many aspects of client-side logic and deeplinking.
We totally aggree that this is an edge case and in our case we can solve the problem by adjusting the value to
/_dashboards/app/home
, since the fragment/anchor is appended properly on client side again.But we are wondering if the validation itself is spec conform about URL/URI pattern.
According to RFC 3986 Syntax the fragments part of the URI should be valid.
According to RFC 9110 about HTTP semantics a fragment seems to be a valid part of a HTTP 3xx Response.
Also RFC 9110 links to RFC 3986 for Relative reference URI format
So in our opinion, the fragment/anchor part of the redirect seems to be valid and might be worth to add to valid options?
Relevant lines of code:
Annotation Validation of URLs via regex:
Additional, specific validation to
app-route
annotation vianet/url
lib:NGINX Ingress controller version (exec into the pod and run
/nginx-ingress-controller --version
):Kubernetes version (use
kubectl version
):Server Version: v1.30.8-eks-2d5f260
(not related to the issue)Environment:
Since this issue is related to annotation validation within the nginx code (see above), it is not related to any infrastructure, kernel or hardware versions at all.
How to reproduce this issue:
Ingress which triggers this issue:
Ingress-Nginx config consists of at least
Medium
risk level according to the docs.Anything else we need to know:
The text was updated successfully, but these errors were encountered: