File integrity monitoring
File integrity monitoring is performed by comparing the cryptographic checksum and other attributes of a known file against those of the modified file.
The Wazuh File Integrity Monitoring (FIM) module stores checksums and other attributes of monitored files in a dedicated database on the monitored endpoint. During scans, it compares the current file checksums and attributes with the previously stored values to identify additions, modifications, and deletions. When changes occur, the Wazuh agent reports them to the Wazuh manager, which processes and forwards them to the Wazuh indexer for rule matching and indexing. If an event matches a detection rule, Wazuh generates a security finding.
The Wazuh FIM module helps to meet the following PCI DSS requirement.
Requirement 11 - Test Security of Systems and Networks Regularly: Vulnerabilities are being discovered continually by malicious individuals and researchers, and being introduced by new software. System components, processes, and bespoke and custom software must be tested frequently to verify that security controls continue to reflect a changing environment.
This requirement aims to verify that systems and networks are regularly tested to confirm their security status. These tests include vulnerability scans and file integrity monitoring. The Wazuh FIM module supports this requirement by detecting modifications and deletions of monitored files. File integrity monitoring helps organizations identify unauthorized changes to critical files and assess whether security controls remain effective.
Use case
Below is a PCI DSS requirement that the Wazuh FIM module can meet.
PCI DSS requirement 11.5.2
This requirement mandates the deployment of a change-detection mechanism such as FIM to alert personnel when critical system, configuration, or content files are modified without authorization. The mechanism must perform critical file comparisons at least weekly.
In the following sections, configure Wazuh to do the following:
Detect changes in a file
For this use case, configure Wazuh to detect changes to files in the /root/credit_cards directory and to record the user who made them. When a file is modified, Wazuh triggers a finding identifying the user and process responsible.
On the agent
Switch to the root user with
sudo su, then check whether the Audit daemon is installed on your endpoint.# auditctl -v
If the Audit daemon is installed, the output shows its version, for example,
auditctl version 3.1.2. You need this version in a later step. In Red Hat-based systems, Auditd is commonly installed by default. If it's not installed, install it using the following command:# yum install audit
For Debian-based systems, use the following command:
# apt install auditd
For audit version 3.1.1 and later, restart the audit service. On Red Hat-based systems, first install the
audispd-af_unixplugin withyum install audispd-plugins. On Debian-based systems, theauditdpackage already includes the plugin:# service auditd restart
Create the directory to monitor and a file inside it:
# mkdir -p /root/credit_cards # touch /root/credit_cards/cardholder_data.txt
Add sample data to the
cardholder_data.txtfile and verify its contents:# echo 'User1 = card4' > /root/credit_cards/cardholder_data.txt # cat /root/credit_cards/cardholder_data.txt
The command output looks similar to this:
User1 = card4
Add the following configuration to the
syscheckblock of the agent configuration file (/var/ossec/etc/ossec.conf):<directories whodata="yes">/root/credit_cards</directories>
You don't need a
<whodata>block. Without one, the FIM module uses the audit provider for who-data monitoring on Linux. Add a<whodata>block only to choose another provider, such asebpf.Restart the Wazuh agent to apply the changes:
# systemctl restart wazuh-agent
Execute the following command to check if the Audit rule for monitoring the selected folder is applied:
# auditctl -l | grep wazuh_fim
Check in the command output that the rule was added:
-w /root/credit_cards -p wa -k wazuh_fim
Add new content to the file:
# echo 'User2 = card2' >> /root/credit_cards/cardholder_data.txt
Open the menu (☰), go to Endpoint security > File Integrity Monitoring, and click the Findings tab. You can see a finding indicating that a file in the monitored directory was modified.
In the expanded finding, you can see that the PCI DSS requirement has been met. The finding shows the differences in the file checksum, the file modified, the modification time, and whodata details identifying the process and user responsible.
Perform critical file comparisons at specified intervals
In this use case, configure the Wazuh FIM module to scan monitored files every hour and report file changes.
Note
The Wazuh FIM module runs scans every 12 hours by default. The scan frequency set applies to all monitored files/directories, except directories with real-time monitoring enabled.
Configure the frequency option carefully. Depending on the number of files and directories configured for scanning, you might observe increased CPU and memory usage.
Content change reporting is currently limited to text files.
On the agent
Switch to the root user with
sudo su, then create the directory to monitor and a file inside it:# mkdir -p /root/debit_cards # touch /root/debit_cards/cardholder_data.txt
Update the frequency option of the
syscheckblock in the agent configuration file (/var/ossec/etc/ossec.conf) to the scan interval in seconds. This example uses 3600 seconds (one hour):<frequency>3600</frequency>
Add the following configuration to the
syscheckblock of the agent configuration file (/var/ossec/etc/ossec.conf):<directories report_changes="yes">/root/debit_cards/cardholder_data.txt</directories>
Restart the Wazuh agent to apply the changes.
# systemctl restart wazuh-agent
Add sample data to the
cardholder_data.txtfile.# echo 'User5 = card5' > /root/debit_cards/cardholder_data.txt # echo 'User6 = card6' >> /root/debit_cards/cardholder_data.txt
A finding is generated during the next FIM scan, up to one hour later with this frequency, to report the file modification. For a quicker test, set a lower value, such as
300, and restore your production value afterward. Open the menu (☰), go to Endpoint security > File Integrity Monitoring, and click the Findings tab.
In the expanded finding, you can see the changes made in file.diff, the file modified, and the PCI DSS requirement met. It also includes the differences in the file checksum, the modification time, and other details.
Detect file creation and deletion
In this use case, the Wazuh FIM module detects when a file in a monitored directory is created or deleted. This action triggers a finding with the user and process responsible for the change.
On the agent
Switch to the root user with
sudo su, then create the/root/pin_datadirectory to monitor for changes:# mkdir -p /root/pin_data
Add the following whodata configuration to the
syscheckblock of the agent configuration file (/var/ossec/etc/ossec.conf):<directories whodata="yes">/root/pin_data</directories>
Restart the Wazuh agent to apply the changes.
# systemctl restart wazuh-agent
Create the
pin.txtfile in the directory:# touch /root/pin_data/pin.txt
Wait a few seconds, then delete the
pin.txtfile:# rm /root/pin_data/pin.txt
Open the menu (☰), go to Endpoint security > File Integrity Monitoring, and click the Findings tab. You can see one finding for the created file and one for the deleted file.
In the details of the deletion finding, you can see the file deleted, the PCI DSS requirement met, the deletion time, and other details.
You can track these activities from the PCI DSS dashboard. The dashboard shows all activities that trigger a PCI DSS requirement, including FIM changes.