ingress-nginx: validatingwebhook doesn't work as expected when enableAnnotationValidations is set to true
What happened:
Create the below bad-ingress with proxy-next-upstream set to 300. It creates an ingress object even though the proxy-next-upstream value is in-correct.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: bad-ingress
namespace: default
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "0"
nginx.ingress.kubernetes.io/proxy-next-upstream: "300"
spec:
rules:
- host: bad-ingress.k8s.mydomain
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: bad-ingress-service
port:
number: 8888
This issue occurs only when enableAnnotationValidations is set to true.
What you expected to happen:
Ideally, the validating webhook should reject creating this ingress object. Looks like the additional annotation validation that’s introduced in v1.9.0 is not validating the errors as expected.
kubectl apply -f bad-ingress.yaml
Error from server (BadRequest): error when creating "bad-ingress.yaml": admission webhook "validate.nginx.ingress.kubernetes.io" denied the request:
-------------------------------------------------------------------------------
Error: exit status 1
2023/11/23 08:15:04 [emerg] 297#297: invalid value "300" in /tmp/nginx/nginx-cfg910596062:568
nginx: [emerg] invalid value "300" in /tmp/nginx/nginx-cfg910596062:568
nginx: configuration file /tmp/nginx/nginx-cfg910596062 test failed
-------------------------------------------------------------------------------
NGINX Ingress controller version (exec into the pod and run nginx-ingress-controller --version.):
NGINX Ingress controller Release: v1.9.4 Build: 846d251814a09d8a5d8d28e2e604bfc7749bcb49 Repository: https://github.com/kubernetes/ingress-nginx nginx version: nginx/1.21.6
Kubernetes version (use kubectl version):
kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short. Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.3", GitCommit:"25b4e43193bcda6c7328a6d147b1fb73a33f1598", GitTreeState:"clean", BuildDate:"2023-06-14T09:53:42Z", GoVersion:"go1.20.5", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.4", GitCommit:"fa3d7990104d7c1f16943a67f11b154b71f6a132", GitTreeState:"clean", BuildDate:"2023-07-19T12:14:49Z", GoVersion:"go1.20.6", Compiler:"gc", Platform:"linux/amd64"}
Environment: On-Prem installed via kubeadm
- How was the ingress-nginx-controller installed:
helm list -n ingress-nginx
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
test-ingress ingress-nginx 6 2023-11-23 01:47:48.101692406 +0530 IST deployed ingress-nginx-4.8.3 1.9.4
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (8 by maintainers)
Hello everyone look like i facing off with
enableAnnotationValidationstoo. please take a lookdepend on CVE-2021-25742 ( This issue has been rated High ) but when I edited
annotations-risk-level: Highand set –enable-annotation-validation=true , look like this wrong and cannot create ingress object. Im not sure CVE-2021-25742 was rated correctly. Here are detailsHere is the issue which use command line
kubectl describe kiali -n istioand ingress of Kiali wasn’t created.But when set to Critical or delete
annotations-risk-levelin configmap, the issue was gone and working fine. Just got stuck when set to High, Medium or Low. So please kindly for take a look. Thank you guys.@longwuyuan Sorry, I just saw the same error and came in.
About
admission webhook "validate.nginx.ingress.kubernetes.io" denied the request: annotation group ConfigurationSnippet contains risky annotation based on ingress configurationreported an error, I think it should be the configmap configuration, sorry ~. If you want to configure Configurationsnippet in Annotations,annotations-risk-levelshould beCriticalFor details, please refer to: https://kubernetes.github.io/ingress-nginx/usel-nginx- configuration/annotations-risk/
So my configmap is:
I also encountered the same problem, when I enabled allow-snippet-annotations in the ingress-nginx-controller configmap.
Create an ingress as follows:
Error when creating: