The “invalid trailer structure” rule detects potential adversarial manipulation of file structures to evade standard detection mechanisms by introducing malformed trailer data. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify and mitigate sophisticated file-based attacks that may bypass traditional signature-based detection.
YARA Rule
rule invalid_trailer_structure : PDF raw
{
meta:
author = "Glenn Edwards (@hiddenillusion)"
version = "0.1"
weight = 1
strings:
$magic = { 25 50 44 46 }
// Required for a valid PDF
$reg0 = /trailer\r?\n?.*\/Size.*\r?\n?\.*/
$reg1 = /\/Root.*\r?\n?.*startxref\r?\n?.*\r?\n?%%EOF/
condition:
$magic in (0..1024) and not $reg0 and not $reg1
}
This YARA rule can be deployed in the following contexts:
This rule contains 3 string patterns in its detection logic.
Scenario: Backup Job Completion Notification
Description: A legitimate backup tool (e.g., Veeam, Commvault) generates a file with a non-standard trailer structure as part of its job completion log.
Filter/Exclusion: Check for known backup tool signatures or filter files containing known backup job identifiers (e.g., VeeamBackup, CommvaultJobID).
Scenario: System Log Rotation
Description: Log rotation tools (e.g., logrotate, systemd-journald) may append metadata or trailers to log files during rotation, triggering the rule.
Filter/Exclusion: Exclude files with logrotate configuration patterns or files containing logrotate or systemd in their metadata.
Scenario: Scheduled Maintenance Task
Description: A scheduled task (e.g., via Task Scheduler, cron) generates a temporary file with a malformed trailer during system maintenance.
Filter/Exclusion: Filter files created by known maintenance scripts or tasks (e.g., maintenance-script.sh, task-scheduler.exe).
Scenario: File Integrity Monitoring (FIM) Tool
Description: FIM tools (e.g., Tripwire, OSSEC) may append checksums or metadata to files, which could be misinterpreted as invalid trailer structures.
Filter/Exclusion: Exclude files with FIM tool-specific headers or checksum markers (e.g., Tripwire, OSSEC).
Scenario: Database Backup with Metadata
Description: A database backup tool (e.g., MySQL mysqldump, PostgreSQL pg_dump) may include metadata or trailer information in the backup file.
Filter/Exclusion: Filter files containing known database backup headers or file extensions (e.g., .sql, .dump, mysqldump).