Skip to content

Commit 78fe02d

Browse files
authored
Merge pull request #338 from atomicturtle/docs/issue-2028-realtime-limits
Fix for ossec issue #2028
2 parents 24c8c69 + 839d41f commit 78fe02d

3 files changed

Lines changed: 73 additions & 2 deletions

File tree

docs/faq/syscheck.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Syscheck: FAQ
22
-------------
33

4-
.. contents::
4+
.. contents::
55
:local:
66

77

@@ -104,6 +104,22 @@ To enable this functionality, <alert_new_files> must be set to yes inside the <s
104104
Also, the rule to alert on new files (rule 554) is set to level 0 by default.
105105
The alert level will need to be raised in order to see the alert.
106106
Alerting on new files does not work in realtime, a full scan will be necessary to detect them.
107+
See :ref:`syscheck-realtime-limits`.
108+
109+
Why don't permission changes alert immediately with realtime enabled?
110+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
111+
112+
``realtime="yes"`` uses filesystem event notifications to re-check files quickly, but only
113+
**content integrity** changes (checksums/size) on existing files produce immediate alerts.
114+
A ``chmod`` or ownership change on a monitored file is detected on the next **scheduled
115+
syscheck scan**, not at the moment the permission is changed. See :ref:`syscheck-realtime-limits`.
116+
117+
Why does auto_ignore not suppress noisy realtime alerts?
118+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
119+
120+
``auto_ignore`` is applied on the manager when handling events from scheduled scans. Alerts
121+
from the realtime monitoring path are not subject to ``auto_ignore``. Use ``<ignore>`` or a
122+
local rule for files that change frequently in realtime directories.
107123

108124
Add the following to local_rules.xml:
109125

docs/manual/syscheck/index.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ Real time Monitoring
121121
OSSEC supports realtime (continuous) file integrity monitoring on Linux (support was added kernel version 2.6.13) and Windows systems.
122122

123123
The configuration is very simple. In the ``<directories>`` option where you specify what directories to monitor, adding ``realtime="yes"`` will enable it.
124+
125+
.. warning::
126+
127+
**``realtime="yes"`` does not make every ``check_*`` option instantaneous.** Realtime
128+
monitoring uses filesystem notifications (inotify on Linux, ``ReadDirectoryChangesW`` on
129+
Windows) to detect changes quickly, but only **file content integrity** (checksum/size
130+
changes on existing files) is evaluated in near real time. See :ref:`syscheck-realtime-limits`
131+
below.
132+
124133
For example:
125134

126135
.. code-block:: xml
@@ -132,6 +141,36 @@ For example:
132141
133142
In this case, the directories /etc, /usr/bin and /usr/sbin will be monitored in real time. The same applies to Windows too.
134143

144+
.. _syscheck-realtime-limits:
145+
146+
Realtime limitations
147+
^^^^^^^^^^^^^^^^^^^^
148+
149+
Although ``check_all="yes"`` enables permission, ownership, group, size, and checksum
150+
monitoring for a directory, **realtime mode only alerts immediately for content integrity
151+
changes** (for example MD5, SHA1, or SHA256 hash changes) on files already present in the
152+
syscheck database.
153+
154+
The following are **not** detected immediately when only realtime monitoring is enabled:
155+
156+
* **Permission changes** (``check_perm``) — ``chmod`` and similar attribute updates are
157+
picked up on the next **scheduled scan**, not instantly.
158+
* **Ownership or group changes** (``check_owner``, ``check_group``) — same as permissions;
159+
wait for the next scheduled scan.
160+
* **New files** — requires the ``alert_new_files`` option and a full scan; see
161+
:doc:`Why aren't new files creating an alert? </docs/faq/syscheck>`.
162+
163+
Additionally:
164+
165+
* **`auto_ignore`** is enforced on the manager when processing syscheck events from
166+
scheduled scans. It **does not apply** to alerts generated by the realtime monitoring
167+
path. For frequently changing files in realtime directories, use ``<ignore>`` or a local
168+
rule instead.
169+
170+
If you need immediate alerting on permission or ownership changes, combine realtime with an
171+
appropriate scan ``frequency`` and accept that metadata-only changes may lag until the next
172+
scan completes.
173+
135174
.. warning::
136175

137176
The real time monitoring will not start immediately. First ossec-syscheckd needs to scan the file system and add each sub-directory to the realtime queue.

docs/syntax/ossec_config.syscheck.trst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@
1010

1111
- **realtime**: Value=yes
1212

13-
- This will enable realtime/continuous monitoring on Linux (using the inotify system calls) and Windows systems.
13+
- Enable realtime/continuous monitoring on Linux (inotify) and Windows
14+
(``ReadDirectoryChangesW``).
15+
16+
.. note::
17+
18+
Realtime mode alerts immediately on **file content integrity** changes (checksums
19+
and size) for files already in the syscheck database. Permission, ownership, and
20+
group changes are detected on the **next scheduled scan**, not instantly. See
21+
:ref:`syscheck-realtime-limits`.
1422

1523
- **report_changes**: Value=yes
1624

@@ -138,6 +146,13 @@
138146

139147
**Valid:** server, local
140148

149+
.. note::
150+
151+
``auto_ignore`` applies to syscheck events processed from **scheduled scans** on the
152+
manager. It does **not** apply to alerts from realtime monitoring. For noisy files
153+
under ``realtime="yes"`` directories, use ``<ignore>`` or a local rule instead. See
154+
:ref:`syscheck-realtime-limits`.
155+
141156
.. _alert_new_files:
142157
.. object:: alert_new_files
143158

@@ -152,6 +167,7 @@
152167
.. note::
153168

154169
New files will only be detected on a full scan, this option does not work in realtime.
170+
See :ref:`syscheck-realtime-limits`.
155171

156172
.. object:: scan_on_start
157173

0 commit comments

Comments
 (0)