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
CVE-2023-5043: Ingress nginx annotation injection causes arbitrary command execution #10571
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/test-infra repository. |
When setting |
Is there any way how to mitigate this for versions <1.9.0? We are using v1.8.X version and according to compatility matrix we can't upgrade to later versions, because we are using Kubernetes <1.25. |
sorry..to confirm we need to add |
@thiDucTran I suppose you are supposed to add |
@thiDucTran,
|
@phidlipus You can upgrade, there are no v1.25+ specific features in the new version of Ingress NGINX. But please also make sure to test before upgrading. |
thanks all..fyi..if you are not using helm...the equivalent is to add |
i tried to set nginx.ingress.kubernetes.io/enable-annotation-validations: "true" as an annotation or --enable-annotation-validation as an argument in my nginx controller deployment but im still able to set invalid values in my annotations. |
From k9s was able to add last line to ingress-controller template: |
If the ingress controller is configured with |
+1 |
done this but still able to create ingress objects with this kind of annotations : |
Invalid annotation will not be understood by controller, so will be ignored. |
@stromvirvel unfortunatelly not |
/assign @cpanato @rikatz @strongjz @tao12345666333 |
Hey folks, As this CVE has been opened for 1 week now, I'm closing the issue. The description of the issue contains all the required mitigations, and we plan in future releases to turn the validation on by default and also implement more safety measures. Thank you all for using the project, and for your continuous support for us. /close |
@rikatz: Closing this issue. In response to this:
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/test-infra repository. |
@rikatz Thanks for the reply. Can you please explain how the vulnerability can be exploited via |
Can someone suggest an invalid value for nginx.ingress.kubernetes.io/configuration-snippet one can use in order to validate that the remediation works and do a before and after test ? |
For all three these issues the exploitation is similar to what is described on this page: https://raesene.github.io/blog/2023/10/29/exploiting-CVE-2023-5044/ |
@pna-nca thanks for answering and providing that link as well. Are you saying that the remediation suggested of --enable-annotation-validation doesn't work for configuration-snippet and disabling the annotation with controller.allowSnippetAnnotations: false should be used instead ? Many people are using the remediation suggested by @cjcullen in their k8s cluster. If it is not effective, can we work and update the description to mention controller.allowSnippetAnnotations: false instead ? |
There are some checks here: https://github.com/kubernetes/ingress-nginx/blob/main/internal/ingress/inspector/rules.go#L25 but they are easily bypassable. As you can see here, configuration-snippet is not validated: https://github.com/kubernetes/ingress-nginx/blob/main/internal/ingress/annotations/snippet/main.go#L36 anyway.
I have a lot of questions why these stories were closed at all, as the product is still affected and suggested mitigations are "mitigations" at best (even if they would work), but not fixes. On the other hand, configuration snippet annotation is indeed now disabled by default, which is indeed the best way to tackle this particular finding. :) |
We take the same path here as other projects, ingress-nginx, nginx, even kubernetes can be deployed in an insecure way. We are trying to provide security and user flexibility. The annotations validation is a small step in that direction. Disabling snippets is a way for an administrator to mitigate the issue altogether as you pointed out. Any time you allow users to run untrusted code it could result in security flaws. We are actively trying to brake out the security model for data plane and the control plane to help increase the security of the controller. If you have other suggesti9ns @pna-nca please join our community meetings and we can discuss them. If there are serious security concerns still please disclose them by emailing secuirty@kubernetes.io |
Good to hear! I would suggest pinpointing that for this particular finding the mitigations are the following:
For vulnerability CVE-2023-5044 ( Vulnerability CVE-2022-4886 (
That is why we are relying on containerization. :) In this case, the controller provides functionality to adjust web server's configuration directly, without doing context-aware escape. It is similar to granting users a freedom of editing web page they are viewing: everything is fine, until there is an adversary (compromised user) which injects JavaScript to this page and benefit from others. |
Issue Details
A security issue was identified in ingress-nginx where the nginx.ingress.kubernetes.io/configuration-snippet annotation on an Ingress object (in the
networking.k8s.io
orextensions
API group) can be used to inject arbitrary commands, and obtain the credentials of the ingress-nginx controller. In the default configuration, that credential has access to all secrets in the cluster.This issue has been rated High (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L), and assigned CVE-2023-5043.
Affected Components and Configurations
This bug affects ingress-nginx. If you do not have ingress-nginx installed on your cluster, you are not affected. You can check this by running
kubectl get po -n ingress-nginx
.If you are running the “chrooted” ingress-nginx controller introduced in v1.2.0 (gcr.io/k8s-staging-ingress-nginx/controller-chroot), command execution is possible but credential extraction is not, so the High severity does not apply.
Multi-tenant environments where non-admin users have permissions to create Ingress objects are most affected by this issue.
Affected Versions
Versions allowing mitigation
Mitigation
Ingress Administrators should set the --enable-annotation-validation flag to enforce restrictions on the contents of ingress-nginx annotation fields.
Detection
If you find evidence that this vulnerability has been exploited, please contact security@kubernetes.io
Additional Details
See ingress-nginx Issue #10571 for more details.
Acknowledgements
This vulnerability was reported by suanve
Thank You,
CJ Cullen on behalf of the Kubernetes Security Response Committee
The text was updated successfully, but these errors were encountered: