Skip to content

Feat: extend syslog clearing rule - add variants & empty-file idioms - #5600

Merged
nasbench merged 7 commits into
SigmaHQ:masterfrom
vl43den:feat/lnx-clear-syslog-coverage
Oct 28, 2025
Merged

Feat: extend syslog clearing rule - add variants & empty-file idioms#5600
nasbench merged 7 commits into
SigmaHQ:masterfrom
vl43den:feat/lnx-clear-syslog-coverage

Conversation

@vl43den

@vl43den vl43den commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Extend Linux “Clear/Remove Syslog” rule to broaden coverage of file-emptying techniques and correct unlink usage

  • added common truncation/overwrite patterns: redirections (>, >|, :>), true/echo -n/printf '' >, cat|cp /dev/null, truncate, shred.
  • added symlink variants
  • added journalctl variant
  • removed invalid unlink flags and kept only unlink /var/log/syslog
  • kept ATT&CK mapping (T1070.002) and existing metadata; status remains test

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

  • If your PR adds new rules, please consider following and applying these conventions

… 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
@github-actions github-actions Bot added Rules Linux Pull request add/update linux related rules labels Aug 18, 2025
Overhauled the rule to remove so unnecessary additions, added journalctl --rotate

@swachchhanda000 swachchhanda000 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@swachchhanda000 swachchhanda000 added the Author Input Required changes the require information from original author of the rules label Aug 27, 2025
@vl43den

vl43den commented Aug 28, 2025

Copy link
Copy Markdown
Contributor Author

Hi @swachchhanda000,

I have prepared the following sources/briefings for what's included in the extension:

Unlink flags:
unlink only supports --help and --version; options like -f or -r are invalid.

Redirections (">"," >|"):
" >" truncates existing files unless noclobber is enabled; ">|" overrides noclobber to force truncation.

Colon/null builtin (":>", ":"):
: builtin does nothing besides argument expansion and redirection, so " :> /var/log/syslog" truncates the file. returns (0) success unless it fails. Could be a minor addition to the already implemented Redirection options by the previous authors.

"/dev/null":
writes are discarded and reads always return EOF, it's abused to empty files (like so: cat /dev/null > /var/log/syslog, cp /dev/null /var/log/syslog)

"truncate":
adjusts file size - shrinking or extending to a given size; used to zero a file with -s 0.

"shred -u":
overwrites the file to prevent later data recovery.

"ln /dev/null" variants:
replaced with a symlink to /dev/null via ln -s, it “blackholes” new opens of the path (existing FileDescriptors keep writing until reopen. My atomics reference added below has the "-sf" flag mentioned, this would in my opinion be the most prevalent one in that regard.

-s (symlink), -f (force), -n (no-dereference), -T (no-target-directory)

"journalctl --rotate":
"Journal file rotation has the effect that all currently active journal files are marked as archived and renamed, so that they are never written to in future. New (empty) journal files are then created in their place". Can be combined with the other flags so tough to pin down. I would omit this by itself as it could hit some more fp's than ideal, it's more malicious with the vacuum flags paired.

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!

@swachchhanda000 swachchhanda000 added 2nd Review Needed and removed Author Input Required changes the require information from original author of the rules labels Oct 15, 2025
Updated the title and description for clarity. Added new command selections for syslog clearing techniques and refined existing selections.
@nasbench nasbench added this to the Sigma-October-Release milestone Oct 15, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread rules/linux/process_creation/proc_creation_lnx_clear_syslog.yml
Comment thread rules/linux/process_creation/proc_creation_lnx_clear_syslog.yml
Comment thread rules/linux/process_creation/proc_creation_lnx_clear_syslog.yml
Comment thread rules/linux/process_creation/proc_creation_lnx_clear_syslog.yml
@nasbench
nasbench merged commit e40fc91 into SigmaHQ:master Oct 28, 2025
13 checks passed
swachchhanda000 added a commit to montysecurity/sigma that referenced this pull request Nov 19, 2025
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Linux Pull request add/update linux related rules Ready to Merge Rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants