2019-11-11 17:17:09 -08:00
# Disallow changes to kernel parameters
2020-11-11 15:55:02 -05:00
The Sysctl interface allows modifications to kernel parameters at runtime. In a Kubernetes, pod these parameters can be specified under `securityContext.sysctls` . Kernel parameter modifications can be used for exploits and should be restricted.
2019-11-11 17:17:09 -08:00
## Additional Information
2020-11-11 15:55:02 -05:00
* [List of supported namespaced sysctl interfaces ](https://kubernetes.io/docs/tasks/administer-cluster/sysctl-cluster/ )
2019-11-11 17:17:09 -08:00
## Policy YAML
2019-11-11 18:51:21 -08:00
[disallow_sysctls.yaml ](best_practices/disallow_sysctls.yaml )
2019-11-11 17:17:09 -08:00
````yaml
2019-11-13 13:56:20 -08:00
apiVersion: kyverno.io/v1
2019-11-11 17:17:09 -08:00
kind: ClusterPolicy
metadata:
name: disallow-sysctls
spec:
2020-08-19 14:04:58 -07:00
validationFailureAction: audit
2019-11-11 17:17:09 -08:00
rules:
- name: validate-sysctls
match:
resources:
kinds:
- Pod
validate:
2020-11-17 12:01:01 -08:00
message: "Changes to kernel parameters are not allowed"
2019-11-11 17:17:09 -08:00
pattern:
spec:
securityContext:
X(sysctls): null
````