Skip to content

Commit 984c0b1

Browse files
committed
[Fix] ignore_inotify.defaults: sentinel guard against user-file false positives; issue #480
- [Fix] files/internals/ignore_inotify.defaults: * Replace bare 'sql_' with '/var/tmp/#sql_' + '/tmp/#sql_' — bare substring matched legitimate user paths (/home/user/public_html/sql_backup.php); scoped path prefix preserves legacy MySQL #sql_*.MYD coverage without false positives * Drop bare 'scantemp' — same issue (/home/user/scantemplate.php); install- path entries (/usr/local/maldetect/, new /var/lib/maldet/) cover LMD scan temp files transitively * Add /var/lib/maldet/ under "LMD install paths" for FHS scan-temp coverage - [New] tests/47-ignore-inotify-defaults.bats: 3 new regression cases asserting that user PHP files with 'sql_' / 'scantemp' substrings do NOT match defaults, and that FHS /var/lib/maldet/tmp/scantemp.* still matches - [Change] CHANGELOG, CHANGELOG.RELEASE: v2.0.1 [Fix] entry
1 parent cfd54ca commit 984c0b1

File tree

4 files changed

+50
-5
lines changed

4 files changed

+50
-5
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ v2.0.1 | Mar 25 2026:
7777
[Fix] monitor: union-load ignore_inotify + ignore_inotify.defaults; new _monitor_load_ignore_inotify_union helper skips blanks+comments, dedupes across both files; issue #480
7878
[New] packaging: ship ignore_inotify.defaults in RPM spec, DEB rules, links, symlink-manifest; non-conffile under /usr/lib/maldet/internals/ so upgrades refresh the file; override_dh_fixperms preserves 640 mode on DEB; issue #480
7979
[Change] docs: document ignore_inotify.defaults two-file union model in README §5/§7 and maldet.1 MONITOR MODE; issue #480
80+
[Fix] ignore_inotify.defaults: scope 'sql_' to /tmp/#sql_ + /var/tmp/#sql_ and drop bare 'scantemp' to prevent matching user files like sql_backup.php and scantemplate.php; add /var/lib/maldet/ for FHS scan-temp coverage; sentinel remediation for issue #480
8081

8182
-- Changes --
8283

CHANGELOG.RELEASE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ v2.0.1 | Mar 25 2026:
7777
[Fix] monitor: union-load ignore_inotify + ignore_inotify.defaults; new _monitor_load_ignore_inotify_union helper skips blanks+comments, dedupes across both files; issue #480
7878
[New] packaging: ship ignore_inotify.defaults in RPM spec, DEB rules, links, symlink-manifest; non-conffile under /usr/lib/maldet/internals/ so upgrades refresh the file; override_dh_fixperms preserves 640 mode on DEB; issue #480
7979
[Change] docs: document ignore_inotify.defaults two-file union model in README §5/§7 and maldet.1 MONITOR MODE; issue #480
80+
[Fix] ignore_inotify.defaults: scope 'sql_' to /tmp/#sql_ + /var/tmp/#sql_ and drop bare 'scantemp' to prevent matching user files like sql_backup.php and scantemplate.php; add /var/lib/maldet/ for FHS scan-temp coverage; sentinel remediation for issue #480
8081

8182
-- Changes --
8283

files/internals/ignore_inotify.defaults

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
/var/run/mysqld/
1414
/run/mysqld/
1515
sql-temptable-
16-
sql_
16+
/var/tmp/#sql_
17+
/tmp/#sql_
1718
.MYD
1819
.MYI
1920
.MAD
@@ -41,17 +42,15 @@ memcached.sock
4142
/var/tmp/clamav-
4243
/tmp/clamav-
4344

44-
# LMD itself
45+
# LMD install paths (legacy + FHS) — covers scan temp workspaces transitively
4546
/usr/local/maldetect/
4647
/usr/local/sbin/maldet
48+
/var/lib/maldet/
4749

4850
# Device pseudo-fs (non-regular files)
4951
/dev/pts/
5052
/dev/null
5153

52-
# LMD scan temp workspaces
53-
scantemp
54-
5554
# systemd journal + per-user runtime dirs
5655
/run/systemd/
5756
/var/log/journal/

tests/47-ignore-inotify-defaults.bats

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,47 @@ _source_lmd_stack() {
167167
done < "$LMD_INSTALL/internals/ignore_inotify.defaults"
168168
[ "$hit" -ge 1 ]
169169
}
170+
171+
# bats test_tags=monitor,integration,false-positive
172+
@test "defaults: user PHP file with 'sql_' substring does NOT match defaults (sentinel guard)" {
173+
# Regression: bare 'sql_' substring would have matched /home/user/public_html/sql_backup.php
174+
# and suppressed legitimate scan events. Scoped defaults use /tmp/#sql_ and /var/tmp/#sql_.
175+
local sample='/home/user/public_html/sql_backup.php'
176+
local hit=0
177+
while IFS= read -r _line; do
178+
case "$_line" in ''|\#*) continue ;; esac
179+
if [[ "$sample" == *"$_line"* ]]; then
180+
hit=$((hit + 1))
181+
fi
182+
done < "$LMD_INSTALL/internals/ignore_inotify.defaults"
183+
[ "$hit" -eq 0 ]
184+
}
185+
186+
# bats test_tags=monitor,integration,false-positive
187+
@test "defaults: user PHP file with 'scantemp' substring does NOT match defaults (sentinel guard)" {
188+
# Regression: bare 'scantemp' substring would have matched /home/user/public_html/scantemplate.php.
189+
# Scan temps live under install paths (/usr/local/maldetect/, /var/lib/maldet/) which are scoped entries.
190+
local sample='/home/user/public_html/scantemplate.php'
191+
local hit=0
192+
while IFS= read -r _line; do
193+
case "$_line" in ''|\#*) continue ;; esac
194+
if [[ "$sample" == *"$_line"* ]]; then
195+
hit=$((hit + 1))
196+
fi
197+
done < "$LMD_INSTALL/internals/ignore_inotify.defaults"
198+
[ "$hit" -eq 0 ]
199+
}
200+
201+
# bats test_tags=monitor,integration,false-positive
202+
@test "defaults: install-path scan temp still matches (FHS /var/lib/maldet/)" {
203+
# When scan workers write scantemp files under the FHS state dir, defaults must still cover them.
204+
local sample='/var/lib/maldet/tmp/scantemp.12345'
205+
local hit=0
206+
while IFS= read -r _line; do
207+
case "$_line" in ''|\#*) continue ;; esac
208+
if [[ "$sample" == *"$_line"* ]]; then
209+
hit=$((hit + 1))
210+
fi
211+
done < "$LMD_INSTALL/internals/ignore_inotify.defaults"
212+
[ "$hit" -ge 1 ]
213+
}

0 commit comments

Comments
 (0)