Feat: extend syslog clearing rule - add variants & empty-file idioms - #5600
Conversation
… fix invalid unlink flags added common truncation/overwrite patterns: redirections (>, >|, :>), true/echo -n/printf '' >, cat|cp /dev/null, truncate, shred. added symlink variants removed invalid unlink flags and kept only unlink /var/log/syslog kept ATT&CK mapping (T1070.002) and existing metadata; status remains test
Removed lingering whitespace and went over comments
Overhauled the rule to remove so unnecessary additions, added journalctl --rotate
swachchhanda000
left a comment
There was a problem hiding this comment.
Hi @vl43den,
Thanks for your submission. But before we can proceed with review,
Can you share like any example or references for the changes you have made?
It would be easier for us to cross-reference while reviewing.
|
Hi @swachchhanda000, I have prepared the following sources/briefings for what's included in the extension: Unlink flags: Redirections (">"," >|"): Colon/null builtin (":>", ":"): "/dev/null": "truncate": "shred -u": "ln /dev/null" variants: -s (symlink), -f (force), -n (no-dereference), -T (no-target-directory) "journalctl --rotate": Patrick Bareiss rule down in the references (lnx_shell_clear_cmd_history) has a lot of similar mentions and is a good measure for already implemented similar rules References
Minimal reproduction examples (on safe temp files)TMPDIR="$(mktemp -d)"; LOG="$TMPDIR/syslog.demo"; LINK="$TMPDIR/log.link"
echo "TMPDIR=$TMPDIR"
# Truncation via redirection
head -c 256 /dev/urandom > "$LOG"; stat -c%s "$LOG"
: > "$LOG"; stat -c%s "$LOG"
head -c 256 /dev/urandom > "$LOG"; stat -c%s "$LOG"
> "$LOG"; stat -c%s "$LOG"
head -c 256 /dev/urandom > "$LOG"; stat -c%s "$LOG"
printf '' > "$LOG"; stat -c%s "$LOG"
# noclobber vs forcing with >|
head -c 256 /dev/urandom > "$LOG"; stat -c%s "$LOG"
set -o noclobber
> "$LOG" 2>/dev/null || echo "blocked"
: >| "$LOG"
set +o noclobber
stat -c%s "$LOG"
# /dev/null variants
head -c 256 /dev/urandom > "$LOG"; stat -c%s "$LOG"
cat /dev/null > "$LOG"; stat -c%s "$LOG"
head -c 256 /dev/urandom > "$LOG"; stat -c%s "$LOG"
cp /dev/null "$LOG"; stat -c%s "$LOG"
# “blackhole” symlink (affects new opens only)
ln -sfn /dev/null "$LINK"
printf hi > "$LINK" || true
wc -c < "$LINK"
ls -l "$LINK"
# coreutils truncate
head -c 256 /dev/urandom > "$LOG"; stat -c%s "$LOG"
truncate -s 0 "$LOG"; stat -c%s "$LOG"
# unlink (single pathname)
TODEL="$(mktemp -p "$TMPDIR")"; ls -l "$TODEL"
unlink "$TODEL"
[ -e "$TODEL" ] && echo "still there" || echo "removed"
# shred (temp file only)
SH="$(mktemp -p "$TMPDIR")"
head -c 256 /dev/urandom > "$SH"; stat -c%s "$SH"
shred -u "$SH"
echo "exists after shred? $([ -e "$SH" ] && echo yes || echo no)"Please let me know if further references, context, or compliance details would improve this PR. Open to your suggestions and discussion, hope you can help me sort out the fitting additions! |
Updated the title and description for clarity. Added new command selections for syslog clearing techniques and refined existing selections.
a6254cb to
b9a91bb
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR extends the Linux syslog clearing rule to broaden detection coverage by adding multiple file-emptying techniques and correcting invalid command usage patterns.
- Restructured detection logic with multiple selection criteria for different command patterns (rm, unlink, mv, truncate, ln, cp, shred)
- Added shell redirection operators and journalctl variants for comprehensive coverage
- Removed invalid unlink command flags that don't exist in actual implementations
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
… Via System Utilities` new: Syslog Clearing or Removal Via System Utilities --------- Co-authored-by: Nasreddine Bencherchali Co-authored-by: Swachchhanda Shrawan Poudel <87493836+swachchhanda000@users.noreply.github.com>
Summary of the Pull Request
Extend Linux “Clear/Remove Syslog” rule to broaden coverage of file-emptying techniques and correct unlink usage
Changelog
update: Syslog Clearing or Removal Via System Utilities – increase coverage
Example Log Event
N/A – coverage extension, not a false-positive fix!
Fixed Issues
N/A
SigmaHQ Rule Creation Conventions