rand-guard is a small Rust eBPF EDR built for systems and security study. It prioritizes a correct, explainable end-to-end telemetry pipeline over broad product-style feature coverage.
The current agent collects process, file, and opt-in network syscall telemetry, normalizes events in userspace, enriches events with process context, evaluates focused detections and MVP rules, and writes newline-delimited JSON for tests, demos, telemetry, and alerts.
- Process lifecycle visibility for
execve,execveat,fork, andexit. - File visibility for open, write, rename, and unlink syscall families.
- File
watch_paths,watch_patterns, andexclude_pathsfiltering. - Optional network visibility for
connect,bind, andlistensyscall tracepoints. - Shared eBPF/userspace ABI in
crates/commonusing fixed-layout structs. - Ring-buffer delivery through the
EVENTSmap. - Userspace process table enrichment for
ppid,comm, andexe_pathwhen available. - Stdout newline-delimited JSON output.
- Built-in persistence-sensitive file detections.
- Built-in suspicious network port detections.
- MVP
[[rules]]matching for process, file, and network events. - Stable
event_type = "alert"records for rule matches.
- Rule matching is intentionally simple: no expression DSL, regex, multi-event correlation, or time windows.
- Network collection supports only
connect,bind, andlisten. - DNS collection, payload collection,
accept/accept4, and socket lifecycle correlation are not implemented. - Runtime output is stdout JSON only.
- Loading eBPF programs requires root or sufficient Linux capabilities.
- The project is for deep systems/security study, not production EDR parity.
- Quickstart: build, package, install, run, and verify output.
- Architecture: end-to-end event flow and crate responsibilities.
- Threat Model: trust boundaries, assets, assumptions, and non-goals.
- Roadmap: implemented MVP, near-term work, contribution areas, and non-goals.
- Contributing: setup, validation, PR expectations, and eBPF safety rules.
- Security Policy: private vulnerability reporting through GitHub Security Advisories.
- Code of Conduct: community behavior expectations and enforcement.
- Benchmarks: local throughput workflow and interpretation caveats.
- Demo Scenarios: safe local scenarios for current capabilities.
- Example Config: runtime settings, built-in detections, and sample MVP rules.
- License: Apache License 2.0.
crates/common: shared event schema and ABI constants.crates/ebpf:no_stdAya eBPF programs and ring-buffer event producers.crates/user: userspace loader, config validation, ring-buffer consumer, normalization, enrichment, detections, and JSON output.xtask: project automation for format, check, clippy, tests, builds, packaging, run, CI smoke, and throughput.packaging: default config, sample rules, systemd unit, and installer inputs.docs: collaboration, architecture, benchmark, demo, and quickstart documentation.
- Linux with eBPF, BTF, and tracepoint support.
- Stable Rust for userspace crates.
- Nightly Rust with
rust-srcfor the eBPF target. bpf-linkerfor building the eBPF object.- Root or suitable Linux capabilities for actual agent execution.
Install typical Rust tooling:
rustup toolchain install stable
rustup toolchain install nightly --component rust-src
cargo install bpf-linker --lockedRun from the repository root:
cargo run -p xtask -- ci-format
cargo run -p xtask -- check
cargo run -p xtask -- test
cargo run -p xtask -- buildCargo aliases are also available:
cargo xf # format
cargo xc # check
cargo xl # clippy
cargo xt # test
cargo xb # build
cargo xcs # CI smokeCommands that load eBPF generally require sudo or suitable capabilities:
cargo run -p xtask -- run
cargo run -p xtask -- ci-smokeFor the packaged install flow, see Quickstart.
For development from the repository checkout:
cargo run -p xtask -- build
cargo run -p xtask -- runWith the default config, process and file events are enabled and network telemetry is disabled.
Generate a process event:
/bin/trueGenerate a watched file event:
sudo sh -c 'printf "# rand-guard quickstart\n" > /etc/rand-guard-quickstart.service'
sudo rm -f /etc/rand-guard-quickstart.serviceThe example config keeps network collection disabled by default to reduce first-run noise:
[events]
process = true
file = true
network = false
[network]
enabled = false
hooks = ["connect", "bind", "listen"]
collect_dns = false
collect_payload = falseEnable network collection manually by setting both flags:
[events]
network = true
[network]
enabled = true
hooks = ["connect", "bind", "listen"]
collect_dns = false
collect_payload = falseSee config.example.toml for the full configuration shape.
The agent writes one JSON object per line. Process events look like:
{"event_type":"process_start","timestamp_ns":123,"pid":100,"tid":100,"ppid":1,"uid":0,"gid":0,"comm":"bash","exe_path":"/usr/bin/bash","source":"execve","filename_truncated":false}File events can include detection fields when a built-in persistence rule matches:
{"event_type":"file_write","timestamp_ns":123,"pid":100,"comm":"systemctl","resolved_path":"/etc/systemd/system/demo.service","alert":true,"detection_type":"systemd_service_modified"}Rule matches emit a separate stable alert event:
{"event_type":"alert","timestamp_ns":123,"rule_id":"FILE-001","rule_name":"Sensitive file touched","rule_type":"file","severity":"high","action":"alert","source_event_type":"file_write","pid":100,"comm":"bash","path":"/etc/shadow","operation":"file_write"}The eBPF programs rely on modern kernel features:
- Bounded loops, typically kernel 5.3+.
- Ring buffers, kernel 5.8+.
- BTF support for modern eBPF loading.
- Tracepoint programs for scheduler and syscall events.
Loading eBPF requires one of:
- Root.
CAP_BPFplusCAP_PERFMONon supported kernels.CAP_SYS_ADMINon older kernels.
Verified environments include Ubuntu 22.04+ with kernel 5.15+, Fedora 38+ with kernel 6.2+, and Debian 12+ with kernel 6.1+. Older kernels may work with limitations but are not actively tested.
Run the local throughput workflow:
cargo run -p xtask -- throughputThe workflow writes local summaries under .local/throughput/. Treat those numbers as local comparison data, not project-wide guarantees. See Benchmarks.
Safe local demos are documented in Demo Scenarios.
Read CONTRIBUTING.md before opening a pull request. Keep changes focused, include relevant validation, and avoid committing generated output.
Contributors are expected to follow the Code of Conduct.
Report vulnerabilities privately through GitHub Security Advisories. Do not open public issues for exploitable crashes, verifier safety problems, sensitive telemetry leaks, or detection bypass details. See SECURITY.md.
Licensed under the Apache License, Version 2.0. See LICENSE.