egressfirewall-allow-all
An Allow entry for 0.0.0.0/0 leaves the OVN-Kubernetes egress firewall with no restriction at all, so any pod in the namespace can open connections to arbitrary internet hosts for command-and-control and data theft.
!object.spec.?egress.orValue([]).exists(e,
e.?type.orValue('') == 'Allow' &&
e.?to.cidrSelector.orValue('') == '0.0.0.0/0'
)
OVN-Kubernetes EgressFirewalls must not Allow egress to 0.0.0.0/0.
Replace 0.0.0.0/0 with the specific destination CIDRs the namespace needs and keep a trailing Deny rule for everything else. Field: spec.egress[*].to.cidrSelector.
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
name: egressfirewall-allow-all
annotations:
kubeapt.io/uuid: "c4eec6b4-7132-4295-9672-ca1573bd0189"
security.kubeapt.io/displayName: "Permits Egress to 0.0.0.0/0"
security.kubeapt.io/description: "An Allow entry for 0.0.0.0/0 leaves the OVN-Kubernetes egress firewall with no restriction at all, so any pod in the namespace can open connections to arbitrary internet hosts for command-and-control and data theft."
security.kubeapt.io/resource: "EgressFirewalls"
security.kubeapt.io/severity: "Moderate"
security.kubeapt.io/remediation: "Replace 0.0.0.0/0 with the specific destination CIDRs the namespace needs and keep a trailing Deny rule for everything else. Field: spec.egress[*].to.cidrSelector."
security.kubeapt.io/product: "OVN-Kubernetes"
spec:
failurePolicy: Fail
matchConstraints:
resourceRules:
- apiGroups:
- k8s.ovn.org
apiVersions:
- v1
operations:
- CREATE
- UPDATE
resources:
- egressfirewalls
validations:
- expression: |
!object.spec.?egress.orValue([]).exists(e,
e.?type.orValue('') == 'Allow' &&
e.?to.cidrSelector.orValue('') == '0.0.0.0/0'
)
message: |
OVN-Kubernetes EgressFirewalls must not Allow egress to 0.0.0.0/0.Save it as egressfirewall-allow-all.yaml — the commands below assume that name.
Check a workload against this one policy, before anything is installed on a cluster.
$ kubeapt validate -p ./egressfirewall-allow-all.yaml -r ./workload.yamlOr without the file, from the published policy set — -r takes a directory too:
$ kubeapt policies download && kubeapt validate --policy-name egressfirewall-allow-all -r ./manifestsOr against every namespace in the cluster your kubeconfig points at:
$ kubeapt validate --policy-name egressfirewall-allow-all -A