Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Detect and contain a persistence and a denial of service

By updated

Improve this page

Logo Kubernetes

This challenge checks that you can, on your own, find what an attacker left to keep access and remove it for good, then cap a namespace where an abusive workload runs. It is meant for people who have just followed the lesson Denial of service: exhausting a cluster. It runs in a dsoxlab virtual machine, on a kubeadm cluster with Kubernetes 1.37, and takes about 45 minutes. It gives no hints and teaches nothing new: it checks what the lessons and their guided labs have already let you practice.

What you will learn

The lab reads the state of the cluster and the record file, creates probe Pods and sends real HTTP requests. It checks that you can:

  • Identify what the attacker left to keep access and record it in a file, exported from the live object, before any deletion.
  • Delete that object for good, so that the access does not come back even without the original Pod.
  • Keep the legitimate application at its three available replicas.
  • Cap a namespace with a ResourceQuota, and set default values with a LimitRange.
  • Check that a creation beyond the cap is refused and that an application of another namespace answers during the load.

What should you be able to do before you start?

No step-by-step guide goes with the challenge, and choosing the right objects is part of what it checks. The steps it asks for are taught in four lessons:

If one of these points feels unclear, reread the lesson before you start.

What does the statement ask for?

Two incidents hit the kubeadm cluster on the same morning. In the reservations namespace, an attacker got in through a Pod named diagnostic-reseau. The account it runs under, maintenance, reads the Secrets of every namespace. The team removed it by hand twice: it came back within seconds each time. Next to it runs the legitimate application reservations, three replicas behind its Service, which the business cannot lose.

In the calcul-lots namespace, the moulinette workload runs two replicas with nothing to stop it from taking whatever it wants. It is bounded here so that the node stays safe; the next one will not be. The team wants to keep it running, but contained. You are on the control plane, with kubectl configured, as root.

The statement says what must be true at the end, never how to get there:

  1. What the attacker left to keep access is identified and recorded in /root/constat-attaque.yaml, exported from the live object, before any deletion.
  2. That object is deleted and the attacker's access does not come back, even once the diagnostic-reseau Pod is deleted: no more maintenance account, no more token, no more rights on the cluster. This requirement is blocking.
  3. The legitimate application reservations still has its three replicas available.
  4. calcul-lots caps what is requested: at most 800m of CPU and 768Mi of memory, all Pods together.
  5. A container that declares no resources in calcul-lots receives default requests and limits, for CPU and memory.
  6. A creation beyond this cap is refused by the cluster. This requirement is blocking.
  7. While moulinette still runs its two replicas, reservations keeps answering on its Service.

How do you start the challenge and get graded?

You start the lab with dsoxlab run k8s-challenge-contenir-une-attaque: it prepares the cluster and the two incidents. Two commands are then used. dsoxlab check k8s-challenge-contenir-une-attaque tells you where you stand, criterion by criterion, as many times as you like, and dsoxlab submit k8s-challenge-contenir-une-attaque returns the final result. The grade never looks at the commands you typed. The lab compares your record with the object created at the start, waits for a full cycle of the mechanism before judging that the access is gone, creates probe Pods in calcul-lots to see what the cluster accepts or refuses, and sends real HTTP requests to reservations.

Put it into practice

This lab is the challenge itself. It puts you in front of the situation described above and it reads the state of the cluster, as a colleague taking over your work would do.

How is the challenge graded?

The pass mark is 70 points out of 100. The seven requirements weigh the same. Requirements 2 and 6 are blocking: if one of the two is not met, the challenge fails, whatever the total. The feedback only lists the unmet criteria, by their label, with the grade: no message says why.

If a criterion is not met, reread the lesson that teaches it, fix it, then run dsoxlab check again. The lesson Persistence: what an attacker leaves behind covers the access that was left behind, and ResourceQuota and LimitRange: control resources per namespace covers the cap.

Key points

  • The challenge is a final exercise to do alone and without hints: it explains nothing and grades the state of the cluster, not your commands.
  • Requirements 2 and 6 are blocking: the access left by the attacker removed for good, and a cap that really refuses a creation.
  • The record is written before any deletion, exported from the live object.
  • dsoxlab check shows where you stand as often as you like; dsoxlab submit returns the result.