File integrity monitoring
File Integrity Monitoring (FIM) helps you audit sensitive files and meet regulatory compliance requirements. Wazuh has a built-in FIM module that monitors file system changes to detect the creation, modification, and deletion of files. This use case uses the Wazuh FIM module to detect changes in monitored directories on Ubuntu and Windows endpoints. The Wazuh FIM module enriches finding data by fetching information about the user and process that made the changes using who-data audit.
Infrastructure
Endpoint |
Description |
|---|---|
Ubuntu 24.04 |
The Wazuh FIM module monitors a directory on this endpoint to detect file creation, changes, and deletion. |
Windows 11 |
The Wazuh FIM module monitors a directory on this endpoint to detect file creation, changes, and deletion. |
Configuration
Ubuntu endpoint
Perform the following steps to configure the Wazuh agent to monitor file system changes in the /root directory.
Edit the Wazuh agent
/var/ossec/etc/ossec.confconfiguration file. Add the following configuration within the<syscheck>block to specify the monitored directory and who-data provider. For this use case, you configure Wazuh to monitor the/rootdirectory:<directories check_all="yes" report_changes="yes" whodata="yes">/root</directories> <whodata> <provider>ebpf</provider> </whodata>
The ebpf provider needs a Linux kernel with BPF ring buffer and BTF support (5.8 or later, which Ubuntu 24.04 meets). If its health check fails, the agent logs (
6959) and switches to the audit provider, which needs the auditd package. See Who-data monitoring for both providers.Note
You can also configure any path of your choice in the
<directories>block.Restart the Wazuh agent to apply the configuration changes:
$ sudo systemctl restart wazuh-agent
Windows endpoint
Take the following steps to configure the Wazuh agent to monitor file system changes in the C:\Users\<USER_NAME>\Desktop directory.
Edit the
C:\Program Files (x86)\ossec-agent\ossec.confconfiguration file on the monitored Windows endpoint. Add the directories for monitoring within the<syscheck>block. To get additional information about the user and the process that made the changes, enable who-data audit. Replace<USER_NAME>with the name of the user:<directories check_all="yes" report_changes="yes" whodata="yes">C:\Users\<USER_NAME>\Desktop</directories>
Note
You can also configure any path of your choice in the
<directories>block.Restart the Wazuh agent using PowerShell with administrator privileges to apply the changes:
> Restart-Service -Name WazuhSvc
As an alternative to local configurations on the Wazuh agents, you can centrally configure groups of agents.
Test the configuration
On the Ubuntu endpoint, run the following steps as root, for example with sudo, because the monitored directory is /root. Before you start, wait until the Wazuh agent finishes its initial scan. On the Ubuntu endpoint, the agent logs (6009): File integrity monitoring scan ended. in /var/ossec/logs/ossec.log, and (6048): Healthcheck for eBPF FIM whodata module success. when the eBPF who-data engine is ready. Changes made before that aren't reported. On the Windows endpoint, wait until C:\Program Files (x86)\ossec-agent\ossec.log shows (6009): File integrity monitoring scan ended. and (6019): File integrity monitoring real-time Whodata engine started. See Real-time monitoring.
Ubuntu endpoint
Create a text file in the monitored directory, then wait for 5 seconds:
# echo "Hello from Wazuh FIM" > /root/fim-test.txt # sleep 5
Add content to the text file and save it. Then wait for 5 seconds:
# echo "Modified content" >> /root/fim-test.txt # sleep 5
Delete the text file from the monitored directory:
# rm /root/fim-test.txt
Windows endpoint
Create a text file in the monitored directory, then wait for 5 seconds:
> Set-Content -Path C:\Users\<USER_NAME>\Desktop\fim-test.txt -Value "Hello from Wazuh FIM" > Start-Sleep 5
Add content to the text file and save it. Then wait for 5 seconds:
> Add-Content -Path C:\Users\<USER_NAME>\Desktop\fim-test.txt -Value "Modified content" > Start-Sleep 5
Delete the text file from the monitored directory:
> Remove-Item -Path C:\Users\<USER_NAME>\Desktop\fim-test.txt
Visualize the findings
You can visualize the findings in the Wazuh dashboard. To do this, navigate to Endpoint security > File Integrity Monitoring and click the Findings tab.
Note
Findings appear in the dashboard a few minutes after each change. The Wazuh agents report real-time and who-data changes right away, and the wazuh-fim detector creates the findings on its next run, every minute in the default content.
Windows and Ubuntu findings for the simulated events
Finding showing who-data information on Ubuntu
Finding showing who-data information on Windows