Skip to content

Security Operations / System auditing · Step 4 of 5

Lesson: Integrity BaselinesSwitch
← Security Operations

Security investigations

Integrity Baselines

Record a trusted state of important files and compare later states with it.

A baseline is a record of how files looked at a moment you trust. Later scans compare the current state with it and report what was added, removed or changed.

Start from a good state

Create the baseline after installing and configuring a system you trust, ideally before it is exposed to others. A baseline taken after tampering records the tampered files as normal.

Build one by hand

bash
sudo find /etc/ssh -type f -exec sha256sum {} + > ssh.sha256
sudo sha256sum -c --quiet ssh.sha256

With --quiet, successful files are not listed. This catches changed or missing files, but not new files, because they are not in the list. Compare file lists to find additions:

bash
sudo find /etc/ssh -type f | sort > files.now

Compare it with a list saved at baseline time using diff.

Use AIDE

AIDE (Advanced Intrusion Detection Environment) does this properly, checking contents, permissions, owners and more according to rules in its configuration. The generic steps are:

bash
sudo aide --init
sudo aide --check
sudo aide --update

--init writes a new database, which you must move to the location configured as the input database before --check can use it. --update checks and also writes a new database. Paths, the configuration file and helper commands differ: Debian and Ubuntu provide aideinit and may need --config. Read your distribution's AIDE documentation.

Choose what to watch

Good candidates are system programs, libraries, boot files and key configuration under /etc. Logs and caches change constantly, so exclude them or check only their permissions and ownership.

Protect and refresh

Keep a copy of the database off the host or on read-only media. Run checks on a schedule and make sure someone reads the reports.

After a planned update, review the differences, confirm that they match the change, and only then accept the new database. Accepting blindly can hide an unwanted change among the expected ones.

An integrity scan detects; it does not prevent or repair. A change made and reverted between two scans can also be missed.

Try it

Create a directory with two files, hash them into a baseline stored outside it, then edit one and add a third. Run the check and notice that only the edit is reported. The search and archives lab helps with find.

Check your understanding

Integrity Baselines

All 3 sections · no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.