ingress-nginx: strict-validate-path-type does not allow period/dot/. in Exact or Prefix path
What happened:
The documentation mentions the following text:
When pathType is configured as Exact or Prefix, there should be a more strict validation, allowing only paths starting with “/” and containing only alphanumeric characters and “-”, “_” and additional “/”.
However the term alphanumeric characters is not specified and the term does not seem to be universally specified either. Some sources for example include special characters in alphanumeric characters, which seems to defeat the purpose of the strict checking.
The current text, depending on the definition of alphanumeric characters, seems to suggest that for example the period . character is not allowed when using Exact or Prefix. This would mean that a path of https://example.com/index.html, https://example.com/.well-known/openid-configuration or https://example.com/.well-known/acme-challenge/3857265 would be invalid for path type Exact and Prefix. I cannot imagine that it’s intentional that all these super common url’s would be unsupported by Exact or Prefix.
What you expected to happen:
Define the term alphanumeric characters as used by this project and allow . in Exact and Prefix path types.
/kind documentation /remove-kind bug
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 21
- Comments: 30 (13 by maintainers)
Commits related to this issue
- disable path validation for nginx for now until https://github.com/kubernetes/ingress-nginx/issues/11176 is addressed — committed to halkeye/home-k8s by halkeye 2 years ago
- fix: disable strict path validation Until https://github.com/kubernetes/ingress-nginx/issues/11176 is addressed. Solution taken from https://github.com/halkeye/home-k8s/commit/a17d48a. — committed to robinelfrink/kube by robinelfrink 2 years ago
- fix: disable strict path validation Until https://github.com/kubernetes/ingress-nginx/issues/11176 is addressed. Solution taken from https://github.com/halkeye/home-k8s/commit/a17d48a. — committed to robinelfrink/kube by robinelfrink 2 years ago
- Switch some Gafaelfawr routes to another path type The new ingress-nginx doesn't allow `.` in paths of `pathType` `Exact`. The workaround is to use `ImplementationSpecific`. Do this for `/.well-known... — committed to lsst-sqre/phalanx by rra 2 years ago
- Workaround '.' being forbidden in paths Ref https://github.com/kubernetes/ingress-nginx/issues/11176 — committed to Zash/snikket-chart by Zash 2 years ago
- Workaround '.' being forbidden in paths Ref https://github.com/kubernetes/ingress-nginx/issues/11176 — committed to Zash/snikket-chart by Zash 2 years ago
- fix(argocd): change path type to handle dots There is currently a CVE that doesn't allow the use of '.' (dots) in some path resolution methods proposed by ingress-nginx. However, they are not IETF co... — committed to Pyrrha/home-cluster by Pyrrha a year ago
- fix: OFO demo workaround for nginx change(bug) (#1240) The OFO client-side demo is broken due to a breaking change (bug?) in the NGINX controller. This provides a workaround. See: https://github.com... — committed to open-feature/openfeature.dev by toddbaert a year ago
- [CertManager] Disable the use of Exact PathType in Ingress resources By default, disable the use of Exact PathType in Ingress resources, to work around a bug in ingress-nginx [1]. [1] https://git... — committed to azimuth-cloud/ansible-collection-azimuth-ops by m-bull a year ago
- [CertManager] Disable the use of Exact PathType in Ingress resources (#898) By default, disable the use of Exact PathType in Ingress resources, to work around a bug in ingress-nginx [1]. [1] http... — committed to azimuth-cloud/ansible-collection-azimuth-ops by m-bull a year ago
- [CertManager] Disable the use of Exact PathType in Ingress resources (#898) By default, disable the use of Exact PathType in Ingress resources, to work around a bug in ingress-nginx [1]. [1] http... — committed to azimuth-cloud/ansible-collection-azimuth-ops by m-bull a year ago
- Disable buggy strict path validation Ref1: https://cert-manager.io/docs/releases/release-notes/release-notes-1.18/ Ref2: https://github.com/kubernetes/ingress-nginx/issues/11176 — committed to pacroy/microk8s-azure-vm by pacroy a year ago
- Disable buggy strict path validation (#30) Ref1: https://cert-manager.io/docs/releases/release-notes/release-notes-1.18/ Ref2: https://github.com/kubernetes/ingress-nginx/issues/11176 — committed to pacroy/microk8s-azure-vm by pacroy a year ago
Instead of fixing the validation regex so that it properly validates URL Paths (and
.is definitely a valid char in URL paths) – we are instead telling everyone to useImplementationSpecificto bypass the controllers new strict URL path validations – and this will somehow lead to better security?https://www.ietf.org/rfc/rfc3986.txt
It seems to me the original issue (CVE) is that the controller is treating the
pathas a regex string? I am not seeing in the docs where controllers are supposed to do that. If people want to use regex defined paths, they should use ImplementationSpecific (and its great ingress-nginx provides that capability for people who want it).However, Prefix/Exact pathTypes should be treated as literal (not regex) strings, and its validation should conform to the published RFCs.
same. all my gRPC ingresses broke in the same fashion, and was forced to move to
ImplementationSpecificpathType (just for this one ingress controller, the other cloud-vendor specific controllers I use are staying on Exact or Prefix).What bugs me is that the reported CVE-2022-4886 (that drove this change) is not clearly documented, what the attack vectors are/were, and whether everyone moving to
ImplementationSpecificis safe or not. From my perspective, everyone being forced to move toImplementationSpecificis just a workaround to bypass the stricter path validation checks that were implemented to resolve that CVE.I get the sense that the “do not allow
.in paths” may have been a quick hack to resolve that high-impacting Critical CVE in a very short amount of time (to prevent a../../etc/passwdtype of thing) – but it feels like it is a bandaid on a deeper unresolved flaw that may still exist in the code – and might still exist on theImplementationSpecificpathTypes because that bypasses the stricter path validation checks.Ultimately, I just want confirmation that workaround (
ImplementationSpecificpathType) is safe to use.I would like to add some subjective commentary to this discussion.
What is the authority of standardisation in heterogenous computer networks like the internet and how do we implement these standards to make networking software interoperable in the internet?
Request for Comments(RFC) by theInternet Engineering Task Force(IETF). A RFC that is put intoStandardis a document that has been reviewed and reworked by experts worldwide. ARFC Standardis the authority of how computer systems must communicate with each other.Common Vulnerabilities and Exposures(CVE) to announce important security problems in computer systems, mostly software. Insofar in the internet, a CVE mostly is a problem of an insecure implementation in a software of a RFC Standard. The software should change it’s implementation so it adheres to RFC Standards securely.When we apply these principles to the specific problem in this issue, we can make the following conclusions:
ingress-nginxhas to implement the RFC Standards to be interoperable with the internet. A relevant list in this context, but not finalized: 1.1. RFC 3986:Uniform Resource Identifier (URI): Generic Syntax1.2. RFC 8615:Well-Known Uniform Resource Identifiers (URIs)ingress-nginxhas to fix it’s CVEs.Which can be further simplified and concluded into;
ingress-nginxhas to support URI paths that include dots.while not being security vulnerable by that. Refusing the handling of paths with dots is not a fix of a CVE, but a wrongful implementation of the internet standards in theingress-nginxsoftware, rendering it partly or fully in-operable with the rest of the internet.As an additional and final remark: Neither Kubernetes, Kubernetes SIGs, ingress-nginx, the Linux Foundation or others are authoritative of internet standards. Solely the IETF is accepted as that.
So
.is not allowed inpathType: Exactingress rules?My ingress rule:
Gives me the error:
and the workaround is
And this bug has been open for a year and nobody is fixing it?
Please, correct me where I’m wrong here?
I agree, which is why I reported this issue.
Ingress-nginx implements it’s own regex for the path validation, which is not actually exactly the same as the docs you linked. The ingress-nginx docs also do not link to this other documentation, so while one can make the assumption that this is a term shared within the k8s sig-network, it would be an improvement to the docs if it actually mentions this if this is in fact the case. As it stands there is no reason to assume both usages of the term are the same, since the ingress-nginx docs are also not hosted in the same location. You are more familiar with the kubernetes project so for you it makes sense that they are related. For me as an outsider it is not as obvious, so I turned to Google to tell me what alphanumerical characters means, and there I did not find one consistent definition. Some did include
.and some did not.ImplementationSpecificallows special characters that are dangerous. A user is forced to choose a more dangerous, non-validated path type, to be able to use a non-dangerous character in the path. It is my opinion that this decreases security, because a user is more often forced to choose a less-secure method.I disagree with you that the
.is an uncommon character in the path of a url. Sure, these days it is also common to no longer include the file name and extension in paths, but there are many sites that still serve content where the file extension is in the path (index.html, index.php etc). File names an extensions are an integral part to serving web content.On top of that the
/.well-known/construct is also used a lot, for example in oidc and in the HTTP01 ACME TLS certificate challenge protocol: https://letsencrypt.org/docs/challenge-types/In this case I believe the actual change is very minor, it would only involve changing the validating regex I linked above and adding a test case.
That said I believe this discussion is currently highly relevant because
strict-validate-path-typewill be turned on by default in the next release, and I believe that many users will be caught off-guard by.being an invalid character since it’s so integral to how webservers work. Bug reports from these users will also eat up valuable developer time, so imo either fixing this or alternatively explicitly mentioning in the docs that the.character is invalid for these path types will save a lot of time in the future.Period is unfortunately not going to be allowed so you will have to change the path type to ImplementationSpecific.
so as the default changed, the synapse chart I was using has failed trying to add a path for /.well-known/matrix https://gitlab.com/ananace/charts/-/blob/master/charts/matrix-synapse/templates/ingress.yaml?ref_type=heads#L180-191
It sounds like from this thread I should submit a PR that updates them to implementation specific, which disables validation right? Or is there still debate if periods are going to be allowed?
Thank you for pointing this out; many recent changes were due to security issues with path validation and annotations. They were made quickly to prevent these issues. Please feel free to update the documentation to remind folks that they should be Implementation Specific if they have dots in their paths.
/kind documentation /good-first-issue
@longwuyuan here is an ingress from my existing homelab:
Log message:
I would say that since
/is required in the path andperiod/dot/.is not a special character when in the path that there is no increased security risk in allowing this character inExactandPrefix.I would say that allowing the commonly used
period/dot/.inExactandPrefixinstead of only inImplementationSpecificincreases security becauseImplementationSpecificis not validated but a user is now forced to use it.@longwuyuan You’re linking documentation in the context of Kubernetes objects, but these requirements are not the same as used by ingress-nginx for path validation. This documentation does indeed mention that alphanumeric means
[a-z0-9A-Z]in this context, but ingress-nginx does not define what alphanumeric means. If alphanumeric in the context of ingress-nginx means the same as the definition as defined in the documents you linked, then I think this should be mentioned in the docs for strict-validate-path-type.I looked up the validation of the path as used by ingress-nginx here: https://github.com/kubernetes/ingress-nginx/blob/e44cab7245ad0e0c31cb6d0c947fa1aa51cff1ba/internal/ingress/inspector/rules.go#L37
Be that as it may, this is not supported by the path validation in ingress-nginx so you can’t even host static files with a file extenstion (index.html for example) using Exact or Prefix paths when
strict-validate-path-typeis enabled.See: https://regex101.com/r/WjwI0c/1
I think this is an oversight and that
.should be supported in Exact and Prefix path types. So actually perhaps this is not only a documentation issue but also either a bug or a feature request.