Day 13: Case Study CVE-2020-8554 – externalIPs MITM
Goal: You understand a CVE that no version “fixes”, and close it with an admission policy. · Duration: approx. 55 min · Prerequisite: Day 12
Briefing
CVE-2020-8554 is special because no patch in the code fixes it:
anyone allowed to create Services can use spec.externalIPs
(or the status IP of a LoadBalancer) to redirect arbitrary IP addresses
to themselves – including those of services outside the cluster. That is
a man-in-the-middle for cluster traffic. The official mitigation is
exactly what you learned on Day 11/12: an admission webhook that forbids
externalIPs.
Drill 1: Affected? – understanding the mechanics
The “vulnerability” is a legitimate API field. Create a Service with
externalIPs – it is accepted:
kubectl create namespace cve
kubectl -n cve apply -f - <<'EOF'
apiVersion: v1
kind: Service
metadata: {name: hijack, namespace: cve}
spec:
externalIPs: ["172.16.0.50"]
ports: [{port: 80, targetPort: 80}]
selector: {app: nothing}
EOF
kubectl -n cve get svc hijack -o jsonpath='{.spec.externalIPs[0]}'; echoExpected:
172.16.0.50
Why dangerous?
172.16.0.50can be the IP of someone else’s service. The kube-proxy on every node now pulls this traffic onto this Service – the attacker reads or modifies it. Anyone withcreate servicescan do this, cluster-wide.
Save your progress? Sign up for free
Drill 2: Mitigation – forbid externalIPs
kubectl apply -f - <<'EOF'
apiVersion: policies.kyverno.io/v1
kind: ValidatingPolicy
metadata: {name: no-external-ips}
spec:
validationActions: ["Deny"]
matchConstraints:
resourceRules:
- apiGroups: [""]
apiVersions: ["v1"]
operations: ["CREATE","UPDATE"]
resources: ["services"]
validations:
- expression: "!has(object.spec.externalIPs) || size(object.spec.externalIPs) == 0"
message: "Service.spec.externalIPs ist verboten (CVE-2020-8554)"
EOFSave your progress? Sign up for free
Drill 3: Proof – the redirecting Service is rejected
kubectl -n cve delete svc hijack
kubectl -n cve apply -f - <<'EOF'
apiVersion: v1
kind: Service
metadata: {name: hijack2, namespace: cve}
spec:
externalIPs: ["172.16.0.50"]
ports: [{port: 80, targetPort: 80}]
selector: {app: nothing}
EOFExpected:
Warning: spec.externalIPs is deprecated and may no longer be implemented in some clusters
Error from server: error when creating "STDIN": admission webhook "vpol.validate.kyverno.svc-fail"
denied the request: Policy no-external-ips failed: Service.spec.externalIPs ist verboten
(CVE-2020-8554)
Tip: The deprecation warning shows that newer Kubernetes versions are pushing back on
externalIPsanyway – but do not rely on that; forbid it actively.
Save your progress? Sign up for free
Drill 4: Proof – normal Services keep working
kubectl -n cve create deployment web --image=nginxinc/nginx-unprivileged:stable
kubectl -n cve expose deployment web --port=80
kubectl -n cve get svc web -o jsonpath='{.spec.type}'; echoExpected:
ClusterIP
Clean up:
kubectl delete validatingpolicy no-external-ips
kubectl delete namespace cveSave your progress? Sign up for free
Checkpoint
Without the policy, the cluster accepts externalIPs – with the policy, it does not. Check that currently no Service in the cluster carries externalIPs:
kubectl get svc -A -o json | python3 -c '
import sys,json
hit=False
for s in json.load(sys.stdin)["items"]:
eip=s["spec"].get("externalIPs")
if eip:
print(s["metadata"]["namespace"]+"/"+s["metadata"]["name"], eip); hit=True
print("keiner" if not hit else "BEFUND")'Expected: keiner
Challenge
CVE-2020-8554 also affects the status.loadBalancer IP.
Think about why a pure spec.externalIPs policy is not
enough when a LoadBalancer controller runs in the cluster – and where
the additional boundary lies.
Hint: The status IP is set by the LoadBalancer
controller, not by the user; the lever is who may change
services/status.
Solution
The LoadBalancer status IP is not set via spec, but via
the services/status subresource – an
externalIPs policy does not apply there. The boundary is
RBAC: only the LoadBalancer controller may have
update/patch on services/status,
no workload and no user. Check this as on Day 2:
kubectl auth can-i update services/status --as=system:serviceaccount:attacker:default
(Expected: no).
Save your progress? Sign up for free
Enterprise Note
- Forbid
externalIPscluster-wide via policy; if a service genuinely needs them, restrict them tightly via an allowlist to fixed, verified IPs. - Allow
services/statusonly to the LoadBalancer controller. - CVEs without a code fix (design CVEs) keep coming up – the defense is almost always admission policy plus RBAC. Your Kyverno setup thus becomes part of the patch process.
- For third-party CVEs, subscribe to the official Kubernetes security announcements (kubernetes-announce) and keep policies ready as a response.