← Policy catalog
</> ValidatingAdmissionPolicy · Apache-2.0

Permits Egress to 0.0.0.0/0

egressfirewall-allow-all

severityModerate resourceEgressFirewalls productOVN-Kubernetes bundles1

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.

Rejects unless

!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.

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.

Applies to

  • egressfirewalls · k8s.ovn.org/v1 · CREATE, UPDATE

Manifest

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.

Validate with kubeapt

Check a workload against this one policy, before anything is installed on a cluster.

$ kubeapt validate -p ./egressfirewall-allow-all.yaml -r ./workload.yaml

Or without the file, from the published policy set — -r takes a directory too:

$ kubeapt policies download && kubeapt validate --policy-name egressfirewall-allow-all -r ./manifests

Or against every namespace in the cluster your kubeconfig points at:

$ kubeapt validate --policy-name egressfirewall-allow-all -A