Detect configuration drift on a machine¶
What you'll learn:
- What drift detection checks, and how it differs from the vulnerability scan
- How to write a baseline, the state you want a machine to be in
- How to attach it to a machine, run a scan and read the gaps
- What happens when you patch a machine and the baseline no longer matches
Time: ~20 minutes
Prerequisites: A machine registered in SSH mode (see Add your first client machine) and a maintainer or administrator account.
What drift detection answers¶
The vulnerability scan asks "does this machine have known flaws?". Drift detection asks a different question: "is this machine still in the state I declared?"
You write the desired state once, as a baseline: packages that must be present, absent or at a given version, services that must be running, files that must keep a known checksum, permissions that must be set. Repod compares the machine with it and reports every gap.
Two properties are worth knowing before you start:
- It is read-only. Repod only looks. It never changes the machine, and there is no automatic repair: fixing a gap is up to you.
- It only checks machines that have a baseline. A machine with no baseline is simply not checked, and that is a normal state, not an error.
Step 1 — Open the page¶
Open Sécurité → Détection de dérive.
Figure 1 — The page before any baseline exists.
- No baseline. "Une machine sans baseline assignée n'a simplement aucune vérification de dérive — ce n'est pas une erreur."
- Créer la première baseline. The two buttons at the top right do the same job in two ways: Nouvelle baseline (name and description, then you add rules one by one) and Importer YAML (the whole baseline at once). We use the second one.
Step 2 — Write the baseline¶
A baseline is a short YAML document. Here is the one we use, for an Ubuntu 22.04 server:
name: demo-ubuntu-jammy
description: Baseline de démonstration pour une machine Ubuntu 22.04
rules:
- id: git-version
type: package
target: git
expected: "1:2.34.1-1ubuntu1"
severity: high
- id: openssh-present
type: package
target: openssh-server
expected: present
severity: high
- id: telnet-absent
type: package
target: telnet
expected: absent
severity: medium
- id: ssh-running
type: service
target: ssh
expected_state: active
severity: critical
- id: sshd-config-hash
type: file
path: /etc/ssh/sshd_config
expected_sha256: "<the SHA-256 of the file>"
severity: high
- id: shadow-permissions
type: permission
path: /etc/shadow
expected_mode: "640"
expected_owner: root
expected_group: shadow
severity: high
Each rule has a unique id, a type, what to look at, what is expected, and a severity (critical, high, medium or low):
| Type | Looks at | Expected value |
|---|---|---|
package |
target: the package name |
expected: an exact version, a pattern such as 1.18.*, present or absent |
service |
target: the service name |
expected_state: active, inactive, enabled or disabled |
file |
path |
expected_sha256: the checksum. Get it with sha256sum /etc/ssh/sshd_config |
permission |
path |
any of expected_mode, expected_owner, expected_group. Only what you write is checked |
Click Importer YAML.
Figure 2 — The import window.
- The text area. Paste your YAML here.
- Insérer un exemple. Fills it with a complete example to adapt.
- Importer. Creates the baseline.
Figure 3 — The baseline, ready to import.
- Name and description.
- A rule. Its
id,typeandtarget. - The expected value. For
git, the exact version. - Importer. Click it. The window closes and a message confirms the import.
Importing twice creates two baselines
The import does not update an existing baseline: it adds a new one. To change a baseline, edit it or duplicate it, then delete the old one.
Step 3 — Check the rules¶
The baseline now appears in the list.
Figure 4 — The baseline list.
- The baseline. Name, description and author.
- The actions. Règles / Attribution, Éditer, Dupliquer and Supprimer.
Click Règles / Attribution.
Figure 5 — The rules.
- Two tabs. Règles and Attribution.
- A rule. Its type (PAQUET, SERVICE, FICHIER, PERMISSION), its
id, its target and its severity. Retirer deletes it. - A service rule. Here
ssh-running, markedcritical. - Nouvelle règle. Adds a rule by hand: identifier, type, target, severity, and optional parameters in JSON.
- Exporter YAML. Downloads the baseline back as YAML, for a backup or to reuse it.
Step 4 — Attach the baseline to a machine¶
A baseline does nothing until it is attached. Open the Attribution tab.
Figure 6 — Attaching the baseline.
- Nouvelle attribution. Choose the kind, Tag machine or Machine (client), then the tag or the machine, and click Attribuer.
- The rule of precedence. "Une attribution par client remplace entièrement les attributions par tag pour cette machine (pas de fusion)." A baseline attached directly to a machine replaces the ones it would get through its tags. They are never combined.
- The attribution. Here the machine
ubuntu-deb. Retirer removes it.
Attach by tag to cover a whole group of machines at once, for example everything tagged prod. Attach to a machine for an exception. We chose the machine, so the demonstration touches nothing else.
Step 5 — Run a scan and read the result¶
Open Clients → Machines clientes, click the machine, then open its Dérive tab.
Figure 7 — Before the first scan.
- No result yet. Either no baseline is attached to this machine, or no scan has been run.
- Lancer le scan de dérive. Starts the first scan.
Repod connects over SSH and reads what each rule asks for. A few seconds later:
Figure 8 — The result.
- The counters. Dérive (here 2), Conforme (4), Erreur (0) and Non applicable (0), with the date of the scan and a Rescanner button.
- Services. Rules grouped by type. A green badge means everything in the group conforms.
- A drift.
git-version: "attendu : 1:2.34.1-1ubuntu1 → constaté : 1:2.34.1-1ubuntu1.17". The line gives the expected value and the observed one side by side. - Another drift.
telnet-absent: "attendu : absent → constaté : 0.17-44build1". The telnet client is installed although the baseline says it should not be. - A conforming rule. The permissions of
/etc/shadowmatch the baseline. The file checksum does too.
The four states:
- Conforme. The machine matches the rule.
- Dérive. The machine differs. This is the finding to look at.
- Erreur. Repod could not check, for example because the SSH command failed.
- Non applicable. The rule cannot apply to this machine. This is the case for service, file and permission rules on a machine in agent mode, which Repod cannot query.
Step 6 — A drift is not always a problem¶
The first drift above deserves a second look. The baseline says git must be 1:2.34.1-1ubuntu1. The machine runs 1:2.34.1-1ubuntu1.17 because it was patched to fix a vulnerability (see Fix a vulnerability on your machines). The machine got better, and the baseline is now wrong.
So a drift can mean two things:
- The machine moved away from the standard: someone installed
telnet, changed a file. Decide whether to put it back. - The baseline is out of date: the standard itself must change.
Do not pin an exact version unless you must
A rule with an exact version drifts at every security update. For a package you want to keep patched, prefer present, or a pattern such as 1:2.34.*. Pin a precise version only when a precise version really is a requirement.
Drift detection also runs by itself, every day (see Schedule the recurring scans and mirrors): you do not have to click Rescanner to learn that something changed.
What's next¶
- Drift baselines: the full reference, including the API
- Add your first client machine: the SSH access that the checks need
- Fix a vulnerability on your machines: the patch that made
gitdrift - Maintenance windows: control when changes happen







