Audit, integrity and incident response
Quick answer
Audit and integrity monitoring provide evidence for investigating changes. Incident response combines triage, containment, recovery and documentation without treating every alert as proof of compromise.
An audit record reports an event; an integrity check reports a difference from a baseline. Neither alone proves malicious intent. Preserve originals, record collection context and use authorized analysis copies. Avoid storing unnecessary personal data or credentials in the evidence.
Prepare the practice environment
Run python3 lab-fixtures/security/setup.py from the extracted root as an ordinary user. Enter the printed fresh private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. Run each snippet in a separate Bash process, not your interactive shell. Only private files are used; optional examples require an authorized snapshot VM. Do not modify system services or security policy. Review the lab guide.
Prerequisites
Review: SELinux and AppArmor.
How it works
Linux Audit can record events selected by rules; auditctl -s reports status and ausearch queries records. Journal and audit logs differ in coverage and retention. Record timestamps with timezone, event source, scope and uncertainty. Compare changes to an approved baseline stored independently; a checksum mismatch establishes a byte difference, not who changed it. Preserve original evidence and use copies for analysis, restrict access, redact secrets from shared reports, and record handling. If compromise is suspected, follow authorized incident procedures and avoid arbitrary cleanup or reboot before evidence and containment decisions. Hashes alone do not establish complete chain of custody. The lab uses invented account and change alerts with no real identifiers.
Try the examples
The alert records a change but does not identify the actor. Correlate with approved maintenance before attributing cause.
Expected stdout:
2025-01-01T10:05:00Z event=change asset=config actor=unknownif printf '%s altered.txt\n' "$(cut -d' ' -f1 payload.sha256)" | sha256sum --status -c -; then exit 1else test "$?" -eq 1 printf 'mismatch detected\n'fiThe deliberately altered fixture fails checksum verification; the expected failure is checked explicitly.
Expected stdout:
mismatch detectedOptional authorized VM inspection, may require audit privileges. Do not alter rules. Output varies by kernel and daemon configuration.
Manual example; not executed locally. Follow its stated environment restrictions.
Common mistakes
Do not delete suspicious logs, expose secrets or treat an untrusted hash as an independent baseline. Avoid attributing an incident without corroboration.
Practice
Build a timeline from incident.log, identify what remains unknown, verify the altered fixture and describe evidence access and escalation.
Related references
Study: auditctl, ausearch, journalctl. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Audit, integrity and incident response — Knowledge Check
Apply defensive security concepts to synthetic fixtures and VM-only scenarios.
What does an integrity mismatch establish?
What should analysis use where practical?
What does auditctl -s inspect?
What belongs in an incident timeline?