33. File integrity monitoring (FIM)
This guide describes Lawliet 1.6.3.b (the current release, a beta: earlier releases are beta. The first stable release will be 2.0.0). Screens, commands and procedures may change in later versions; the usage guide is updated with each release. Check the version your server runs under Settings > Platform or with ./lawliet version, and see the Releases page for what changed.
FIM watches chosen files, directories and (on Windows) registry keys on each host. The agent records an approved baseline - hashes, sizes, owners, permissions - and then reports every change against it, with the process that made the change when the platform can identify it. A change is either expected (a patch, a deployment) and accepted into the baseline, or unauthorised and investigated.
FIM is a licensed module.
Permissions:
| Task | Permission | Four-eyes |
|---|---|---|
| See policies, baselines, coverage | View FIM | - |
| See events (the list, one event, a policy's or a host's events) | View FIM and View findings | - |
| Create, edit, enable, disable, delete policies; build a baseline; verify; accept into baseline | Manage FIM | no |
| Triage events (status, note) | Triage findings | no |
33.1 The tabs#
Path: FIM. The page title is File integrity monitoring.
- Tiles: Total events, Critical/High, Investigating, Malicious.
- Tabs: Changes, Policies, Agents and baselines.
33.2 Procedure: create a FIM policy#
Permission: Manage FIM. Four-eyes: no.
Risk: watching a busy directory (logs, caches, temporary files) floods the event list and costs CPU on the host. Rollback: disable or delete the policy.
- Open FIM > Policies and press New policy.
- Optional: Start from a template - "fills the fields below; everything stays editable". Or keep Blank policy.
- Fill the form:
| Field | Meaning |
|---|---|
| Name | For example "Payment web root" |
| Operating system | Any OS, Linux, macOS or Windows |
| Description | Optional |
| Monitored paths | One per line; a file or a directory |
| Excluded paths | And everything below them |
| Include patterns | Empty = every file |
| Exclude patterns | A name, or a path with / |
| Registry keys (Windows) | For example HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run. Values are hashed; polled every 10 s in real time |
| Detection | Real time - as each change happens, or Scheduled, every N |
| Include subdirectories | Watch below the monitored directories |
| Report these changes | Created, Modified (content), Deleted, Renamed, Permissions, Owner, Attributes (Windows) |
| Hash | sha256, sha512, sha1, md5, or no content hash |
| Hash files up to | Larger files are not content-hashed (MB) |
| Severity | low, medium, high, critical |
| Apply to agents | Tick hosts; none selected = every matching agent |
| Enabled | "agents start enforcing it within five minutes" |
- Press Create policy (or Save changes for an existing policy). The button stays disabled while "N problems to fix before saving" is shown; each problem is named under its field.
What you see: the policy in Policies with its Scope, Watches, Filters and Reports.
Next: build the baseline on each agent (33.3). Until a baseline exists the agent has nothing to compare against.
Procedure: change, disable or delete a FIM policy#
Permission: Manage FIM. Four-eyes: no. Risk: disabling or deleting a policy stops monitoring those paths on its hosts, so changes there go unseen; widening it can flood the event list. Rollback: change it back, enable it again, or create it again (a deleted policy is gone, with its baselines).
To change it:
- Open FIM > Policies and click the policy's name. The editor opens with its values.
- Change the fields and press Save changes. Agents pick up the change within five minutes. Build the baseline again (33.3) if you changed the paths or filters.
To disable or enable it:
- Press Disable on the policy's row. The row shows " - disabled" under the name and its hosts stop monitoring those paths; Verify all agents is greyed out.
- Press Enable to turn it back on. You see "Policy enabled".
To delete it:
- Press Delete on the policy's row.
- Confirm "Delete policy "<name>"? Its hosts stop monitoring these paths."
- What you see: "Policy deleted". Events it already raised stay in Changes.
33.3 Baselines and verification#
Path: FIM > Agents and baselines. Columns: Agent, Policy, Mode, Baseline, Last baseline, Last verify. "No policy applies to this host." means no policy targets it.
Procedure: build a baseline#
Do this after the host is in its approved state (after patching, before go-live).
- Find the agent and policy row and press Baseline now.
- The scan view opens: "Waiting for the agent. Tasks are delivered on its next heartbeat and run on the host."
- When it completes, the Baseline column shows the number of entries. Click it to browse the baseline (Path, Type, Mode, Owner, Size, Hash; Filter by path...).
Procedure: verify a host against its baseline#
- Press Verify now on the row (or Verify all agents on the Policies tab, which says "N scan(s) queued" and how many hosts were skipped).
- The agent re-hashes the policy's files and reports every difference as an event.
- Open the result from the Last verify cell of the row. "No differences: all N path(s) match the baseline." means nothing changed.
Procedure: accept verified changes into the baseline#
Permission: Manage FIM. Use this after a planned change (patching, a deployment), once you have confirmed every difference is legitimate. Rollback: none in the console; if you accepted a change by mistake, restore the file on the host and build the baseline again.
- Open the verification result (step 3 above). It lists each changed, new and removed path.
- Press Accept on a single path, or Accept all N change(s) into the baseline.
- The baseline now holds the new state; the next verification compares against it.
Administrators can also run both from Operations (chapter 39).
33.4 Working the changes#
A change a Lawliet command made - a hardening step writing the file it backed up, a decoy being planted or removed - is stored with status expected and the label Changed by Lawliet (action N). It is not queued for review and is not drift. Hide Lawliet's own activity above the list (on by default) leaves these out and says how many it hid; see 30.1.
Path: FIM > Changes. The Event matrix: File path, Host, Event type, Changed by, Severity, Status, Risk, Detected. Filter by path... narrows it.
Click an event for the detail: Path, Change, Severity, Risk, Host, Authorised, Detected, Changed by (process, Identified by, Executable), Renamed from, Found by, and the before/after of Mode, Size, Owner and the hashes (Hash before, Hash after).
Procedure: triage a change#
Permission: Triage findings.
- Open the event and press one of the statuses under Set status:
| Status | Meaning |
|---|---|
| acknowledged | Seen, not yet judged |
| investigating | Being looked at now |
| expected | A legitimate change - deployment, patch, or approved edit |
| malicious | Unauthorised. Treat as an incident |
| resolved | Dealt with; no further action needed |
- Type the reason in the note and press Save.
Procedure: accept a change into the baseline#
Permission: Manage FIM. Use this only for a change you have confirmed is legitimate.
- Open the event and press Accept into baseline.
- The baseline is updated to the file's new state, so later verifications compare against it.
A malicious change: open an investigation (chapter 34) and consider containment (chapter 36). Do not accept it into the baseline.
33.5 What a fresh install watches (the default watch list)#
The first time an agent of an operating system enrols, Lawliet creates that system's default policies, named Default: ... on FIM > Policies. They cover what an intruder touches first and cost a production host nothing noticeable (no whole-disk policies):
| Agent OS | Default policies |
|---|---|
| Linux | Accounts and privilege (/etc/passwd, shadow, group, sudoers, sudoers.d, PAM), SSH configuration and every authorized_keys, cron and systemd units, system binaries (/usr/bin, /usr/sbin, /bin, /sbin, /usr/local/*) |
| Windows | hosts file, autostart (Run keys and Startup folders), scheduled tasks (System32\Tasks), persistence keys (Image File Execution Options, AppInit, LSA), services registry (checked hourly) |
| macOS | LaunchDaemons and LaunchAgents, system configuration (hosts, sudoers, SSH, PAM) |
Rules: it happens once per operating system, on a new install (an upgraded install that already has agents of that system is left as it is); it never happens when you already have a policy for that system (your setup is respected); sandbox hosts get none; they are ordinary policies, so edit, disable or delete them as in 33.2. Deleting them is permanent: they are not re-created.
33.6 How changes are reported#
- A save through a temporary file (
sed -i, vim, visudo,useradd, package managers, most Windows editors) is reported as one modified event on the file, with the Hash before and Hash after. The temporary file is not reported. A save that writes the same bytes reports nothing. - Changes made while the agent was not running are reported when it starts, as events whose Found by says the change was made while the agent was not running. The first start of a policy, and the first start after you edit it, only record the starting state.
- Every 12 hours each real-time policy is re-checked in full, which finds any change the operating system failed to announce (Found by: verify).
- A flood of new files under policies that are all low or medium severity (more than 100 creates in 10 seconds in one directory) is folded into one summary event for the directory: the event detail lists the count and the folded paths and hashes (paths cut at 512 characters; past 256 KB the rest are counted, with a digest). A file covered by a high or critical policy is never folded, even when a lower policy also covers it. A change to a file that already existed, and a delete or rename of one, are never folded, and the most severe events are sent first, so a flood cannot hide the one change that matters.
- Events the agent could not keep are counted. The agent holds up to 20,000 events, writes each to disk as it is queued, keeps them there until the server acknowledges them, and reloads them after a restart. If it ever has to discard events (queue full, or its queue file is missing or unreadable at start) the host raises a critical FIM events were lost on <host> item in the Review queue (chapter 21) and a notification; if its loss counter goes down (its state files were deleted or replaced, or its event numbering went back) it raises FIM counters were reset on <host>; events that vanished without being counted raise FIM events vanished on <host>. Treat the host as possibly tampered with, run Verify on its policies and narrow the policy that produced the flood.
- The agent's FIM state (queue and reference state) is private: root only on Linux and macOS, SYSTEM and Administrators on Windows.
33.7 If it fails#
| Symptom | Cause | Fix |
|---|---|---|
| No events from a host | No policy applies, no baseline, or the agent is offline | Check Agents and baselines |
| Baseline stays "Waiting for the agent" | Agent offline | Check Environment > Hosts |
| Thousands of events | A noisy path is watched | Add it to Excluded paths or Exclude patterns |
| Changed by is empty | The process could not be identified for that change | Use the time and host to search SIEM |
| FIM column on Proof of protection says Not configured | No FIM policy on that host | Create a policy and baseline |
| A FIM events were lost item in the Review queue | The agent's queue overflowed, or someone flooded a watched directory | See 33.6: verify the host's policies, then narrow the noisy policy |
| modified shows no Hash before | The file was not known to the agent before (first start of its policy) | Normal for a new policy; later changes carry both hashes |