This policy mitigates CVE-2021-25745 by restricting `spec.rules[].http.paths[].path` to safe values. Additional paths can be added as required. This issue has been fixed in NGINX Ingress v1.2.0. Please refer to the CVE for details.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: restrict-ingress-pathsannotations:policies.kyverno.io/title: Restrict NGINX Ingress path valuespolicies.kyverno.io/category: Security, NGINX Ingresspolicies.kyverno.io/severity: highpolicies.kyverno.io/subject: Ingresspolicies.kyverno.io/minversion: 1.6.0kyverno.io/kyverno-version: 1.6.0kyverno.io/kubernetes-version: "1.23"policies.kyverno.io/description: This policy mitigates CVE-2021-25745 by restricting `spec.rules[].http.paths[].path` to safe values. Additional paths can be added as required. This issue has been fixed in NGINX Ingress v1.2.0. Please refer to the CVE for details.spec:validationFailureAction: Enforcerules:- name: check-pathsmatch:any:- resources:kinds:- networking.k8s.io/v1/Ingressvalidate:message: spec.rules[].http.paths[].path value is not alloweddeny:conditions:any:- key: "{{ request.object.spec.rules[].http.paths[].path.contains(@,'/etc') }}"operator: AnyInvalue:- true- key: "{{ request.object.spec.rules[].http.paths[].path.contains(@,'/var/run/secrets') }}"operator: AnyInvalue:- true- key: "{{ request.object.spec.rules[].http.paths[].path.contains(@,'/root') }}"operator: AnyInvalue:- true- key: "{{ request.object.spec.rules[].http.paths[].path.contains(@,'/var/run/kubernetes/serviceaccount') }}"operator: AnyInvalue:- true- key: "{{ request.object.spec.rules[].http.paths[].path.contains(@,'/etc/kubernetes/admin.conf') }}"operator: AnyInvalue:- true
This policy performs some best practices validation on Application fields. Path or chart must be specified but never both. And destination.name or destination.server must be specified but never both.
This policy prevents the use of the default project in an Application.
This policy prevents updates to the project field after an Application is created.