-
Notifications
You must be signed in to change notification settings - Fork 8.5k
modsecurity-snippet annotation is not validated in webhook validator #14604
Description
What happened:
The modsecurity-snippet annotation is not being validated at webhook admission time. This allows invalid ModSecurity rules to be deployed without any validation or error feedback.
What you expected to happen:
Invalid ModSecurity rules in the modsecurity-snippet annotation should be caught at admission time using the modsec-rules-check CLI tool. Users should receive clear feedback about validation failures, either as:
- A warning in non-strict mode (default): Invalid rules are logged as warnings but deployment proceeds
- A rejection in strict mode: Invalid rules cause the Ingress admission to be denied
NGINX Ingress controller version (exec into the pod and run /nginx-ingress-controller --version):
-------------------------------------------------------------------------------
NGINX Ingress controller
Release: v1.14.3
Build: b4ab41015421ae27f3a96d73f013183b7e166735
Repository: https://github.com/kubernetes/ingress-nginx
nginx version: nginx/1.27.1
-------------------------------------------------------------------------------
Kubernetes version (use kubectl version):
Client Version: v1.34.3
Kustomize Version: v5.7.1
Server Version: v1.33.6
Example Ingress with invalid modsecurity-snippet:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test-modsec
annotations:
modsecurity-snippet: |
SecRule INVALID SYNTAX HERE "id:100,phase:2,deny"
spec:
ingressClassName: nginx
rules:
- host: example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-service
port:
number: 80How to reproduce this issue:
- Deploy ingress-nginx controller with ModSecurity enabled
- Create an Ingress resource with an invalid
modsecurity-snippetannotation (as shown above) - The Ingress is accepted without any validation or warning
- No error message is provided to the user about the invalid rule syntax
Expected result: Admission webhook should validate the modsecurity-snippet and either:
- Emit a warning (in default mode), or
- Reject the Ingress (in strict mode)
Anything else we need to know:
This is a security and operational concern because:
- Invalid WAF rules may silently fail, leaving the application unprotected
- Debugging issues becomes harder when rules fail at runtime instead of deployment time
- Users don't receive any feedback about misconfigured security policies
Metadata
Metadata
Assignees
Labels
Type
Projects
Status