Skip to content

observer: add YARA rule-based process execution scanning#4995

Open
4ykutG wants to merge 1 commit into
cilium:mainfrom
4ykutG:feat/issue-1319-yara-detection
Open

observer: add YARA rule-based process execution scanning#4995
4ykutG wants to merge 1 commit into
cilium:mainfrom
4ykutG:feat/issue-1319-yara-detection

Conversation

@4ykutG
Copy link
Copy Markdown

@4ykutG 4ykutG commented May 13, 2026

Fixes #1319

Description
Adds YARA rule-based scanning for process execution events. When a new process starts, its binary is scanned asynchronously against YARA rules. On a match, SIGKILL is sent to terminate the process.

pkg/observer/yara_scanner.go: YARA engine with 4-worker pool, buffered queue (256), per-worker Scanner, fail-safe drop on full queue
pkg/observer/observer.go: whitelist filter + async scan on execve events
pkg/option, pkg/defaults: --yara-rules-dir flag (default /etc/tetragon/yara-rules.d)
cmd/tetragon/main.go: engine initialization at startup (non-fatal if directory missing)
yara-rules/ransomware.yar: detection rules for WannaCry, LockBit, REvil, shadow copy deletion, ransom note names, encryption+mass-write patterns
Known limitation: userspace SIGKILL has a TOCTOU race — the binary starts executing before we can kill it. A proper solution would use eBPF LSM hooks for pre-execution blocking, which could be a follow-up.

Dependency: requires libyara >= 4.2 on the host system.

Changelog

Add YARA rule-based process execution scanning via --yara-rules-dir flag.

Implements issue cilium#1319. Hooks into execve events via HandlePerfData,
scans new process binaries asynchronously with a YARA worker pool,
and sends SIGKILL on a match.

- pkg/observer/yara_scanner.go: YARA engine with 4-worker pool,
  buffered queue (256), per-worker Scanner, fail-safe drop on full queue
- pkg/observer/observer.go: whitelist filter + enqueueYaraScan on execve
- pkg/option, pkg/defaults: --yara-rules-dir flag (default /etc/tetragon/yara-rules.d)
- cmd/tetragon/main.go: InitYaraScanner at startup (non-fatal if missing)
- yara-rules/ransomware.yar: detection rules for WannaCry, LockBit, REvil,
  shadow copy deletion, ransom note names, encryption+mass-write pattern
- vendor: go-yara/v4 binding (requires libyara >= 4.2)

Note: userspace SIGKILL is a known limitation (TOCTOU). A follow-up
could use eBPF LSM hooks for pre-execution blocking.
@4ykutG 4ykutG requested a review from a team as a code owner May 13, 2026 00:30
@4ykutG 4ykutG requested a review from andrewstrohman May 13, 2026 00:30
Copy link
Copy Markdown
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

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

Thanks for the proposal. Could you speak a bit about why you think this is the
right way to solve the problem?

Additionally, if you are using Generative AI tools to create this contribution,
please describe how involved you were using the AI Influence Level, and
describe how you reviewed the output before submission.

Could you also in the future split your commits into logical changes, please read https://tetragon.io/docs/contribution-guide/ before resubmitting. Thanks!

Comment thread Dockerfile
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why did you remove the whole Dockerfile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Yara rule support for detection and blocking file executions

2 participants