enrich: Add SHA256 hash of executable to SYSCALL records#289
Open
rhaist wants to merge 7 commits intothreathunters-io:masterfrom
Open
enrich: Add SHA256 hash of executable to SYSCALL records#289rhaist wants to merge 7 commits intothreathunters-io:masterfrom
rhaist wants to merge 7 commits intothreathunters-io:masterfrom
Conversation
Adds a new `exe-hash` option to the `[enrich]` config section. When enabled, LAUREL reads the executable file referenced in SYSCALL.exe and appends its SHA256 hash as EXE_HASH to the SYSCALL record. This allows analysts to detect tampered or renamed binaries. Closes threathunters-io#222
Collaborator
|
Thanks for the PR. Placing the enrichment late into the chain makes sens, However, I'd rather not merge the feature as implemented since there is potential for seriously DoSing the process and some measures should be taken to keep system administrators from shooting themselves in the foot.
Please keep your patch minimal – I'd only want to see changes related to the added dependency in Cargo.lock. Also, some |
- Remove unrelated #[cfg_attr] annotations from enrich_sockaddr and enrich_syscall; revert ContainerInfo import to original single line - Add exe-hash-size-limit option to skip hashing large executables, preventing DoS via unbounded I/O on huge binaries - Add LRU exe hash cache (exe-hash-cache-entries, default 1024) keyed by (dev, inode, mtime_nsec) to avoid redundant reads of unchanged executables
Author
|
Tried to incorporate all your points - at some point a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
exe-hashenrichment option requested in #222. When enabled, LAUREL reads the executable file referenced inSYSCALL.exeat event processing time and appends its SHA256 digest as anEXE_HASHfield to the SYSCALL record.Motivation
Process execution events carry the path of the executed binary, but not a hash. This makes it difficult to detect cases where a binary has been replaced or tampered with between invocations, or where a known-bad executable is renamed to evade file path–based detection rules. Adding a content hash allows analysts and SIEM rules to correlate against threat intelligence feeds and detect renamed or modified binaries.
Configuration
The feature is disabled by default to avoid I/O overhead for users who don't need it. Enable it by adding the following to
etc/laurel/config.toml:When enabled, each SYSCALL record gains an
EXE_HASHfield containing the lowercase hex-encoded SHA256 of the executable:If the file cannot be read (e.g. the process has already exited and the binary was deleted), the field is silently omitted rather than causing an error.
Implementation notes
sha2crate (pure Rust, no new system library dependencies). On x86/x86_64, hardware acceleration is detected via CPUID; on aarch64, viagetauxval(available since glibc 2.16 / CentOS 7). Neither path introduces new minimum glibc version requirements for the distributed binaries.Testing
A unit test (
exe_hashinsrc/coalesce.rs) writes a temporary file, constructs a synthetic SYSCALL+EXECVE+EOE event pointing at it, runs it throughCoalescewithenrich_exe_hash = true, and asserts the correct SHA256 appears in the output.Closes #222