rand-guard

rand-guard는 Rust와 Aya로 만든 작은 eBPF EDR 프로젝트다. 목표는 상용 EDR을 흉내 내는 것이 아니라, Linux endpoint에서 발생하는 process, file, network telemetry를 eBPF로 수집하고 userspace에서 정규화, 보강, 탐지, 출력까지 이어지는 파이프라인을 직접 구현해 보는 것이다.

이 프로젝트는 넓은 기능 목록보다 작고 설명 가능한 end-to-end 흐름을 우선한다. 커널에서는 tracepoint를 통해 제한된 이벤트만 안전하게 수집하고, 정책 판단과 출력은 userspace에서 처리한다. 이벤트는 crates/common의 고정 레이아웃 ABI를 거쳐 EVENTS ring buffer로 전달되고, userspace runtime은 이를 NDJSON 형태로 출력한다.

현재 구현된 범위는 process lifecycle, file event, opt-in network syscall telemetry, built-in detection, MVP rule engine, alert record, packaging과 demo workflow까지다. DNS 수집, payload 수집, accept/accept4, socket lifecycle correlation, multi-event time-window rule correlation은 아직 구현하지 않았다.

프로젝트 코드는 https://github.com/random6-xyz/rand-guard에서 확인할 수 있다.

Posts

  1. Building a Small Rust eBPF EDR 1: MVP Architecture

    첫 글은 rand-guard의 전체 구조를 설명한다. Linux tracepoint에서 시작한 이벤트가 eBPF program, EVENTS ring buffer, userspace normalization, detection/rule evaluation, NDJSON output으로 이어지는 흐름을 잡는다.

  2. Building a Small Rust eBPF EDR 2: Stable Event ABI

    eBPF와 userspace 사이에서 이벤트를 안전하게 주고받기 위한 ABI 설계를 다룬다. crates/common#[repr(C)] 구조체, EventHeader, schema version, event kind, fixed-size string field, truncation flag를 중심으로 설명한다.

  3. Building a Small Rust eBPF EDR 3: Process Lifecycle Telemetry

    execve, execveat, fork, exit 이벤트를 어떻게 수집하고 userspace process table로 보강하는지 설명한다. sched_process_exec와 syscall tracepoint를 함께 쓰는 이유, ppid, comm, exe_path enrichment, cache eviction의 한계를 다룬다.

  4. Building a Small Rust eBPF EDR 4: File Telemetry and Persistence Detection

    open, write, rename, unlink 계열 file event 수집과 persistence-sensitive path detection을 설명한다. watch_paths, watch_patterns, exclude_paths, systemd service와 cron path detection, source event annotation과 alert record의 차이를 정리한다.

  5. Building a Small Rust eBPF EDR 5: Optional Network Telemetry

    기본적으로 비활성화된 network telemetry를 왜 opt-in으로 두었는지 설명한다. 현재 지원하는 connect, bind, listen tracepoint, IPv4/IPv6 sockaddr parsing, suspicious port detection, process name filter, 그리고 DNS/payload/socket correlation을 구현하지 않은 이유를 다룬다.

  6. Building a Small Rust eBPF EDR 6: MVP Rule Engine and Alert Records

    userspace rule engine의 현재 범위를 설명한다. process, file, network 단일 이벤트 matcher, built-in rule과 config [[rules]], stable event_type = "alert" record, 그리고 regex나 multi-event correlation을 아직 넣지 않은 이유를 다룬다.

  7. Building a Small Rust eBPF EDR 7: Running, Packaging, Health, and Roadmap

    프로젝트를 빌드하고 실행하고 패키징하는 흐름을 정리한다. xtask, systemd packaging, quickstart demo, health record, local throughput benchmark, threat model, roadmap을 통해 현재 프로젝트를 어떻게 검증하고 어디까지 확장할 수 있는지 설명한다.

Current Scope

  • Process lifecycle collection: execve, execveat, fork, exit.
  • File telemetry: open, write, rename, unlink syscall families.
  • Optional network telemetry: connect, bind, listen.
  • Shared fixed-layout event ABI in crates/common.
  • Ring-buffer delivery through the EVENTS map.
  • Userspace normalization and process context enrichment.
  • Built-in persistence-sensitive file detections.
  • Built-in suspicious network port detections.
  • MVP single-event [[rules]] evaluation.
  • Stable event_type = "alert" records.
  • Stdout newline-delimited JSON output.
  • xtask workflows for build, test, package, smoke, and throughput.

Current Limits

  • 이 프로젝트는 production EDR parity를 목표로 하지 않는다.
  • 룰 엔진은 단일 이벤트 matcher MVP이며 expression DSL, regex, time window, multi-event correlation은 없다.
  • network collection은 connect, bind, listen syscall tracepoint에 한정된다.
  • DNS collection과 payload collection은 구현하지 않았다.
  • accept/accept4 telemetry와 full socket lifecycle correlation은 구현하지 않았다.
  • runtime output은 현재 stdout NDJSON 중심이다.
  • eBPF program loading에는 root 또는 적절한 Linux capability가 필요하다.

Code

  • crates/common: eBPF와 userspace가 공유하는 이벤트 ABI.
  • crates/ebpf: no_std, no_main Aya eBPF tracepoint programs.
  • crates/user: loader, config, ring-buffer consumer, normalization, enrichment, detection, rule engine, output.
  • xtask: format, check, clippy, test, build, package, run, ci-smoke, throughput workflow.
  • docs: architecture, quickstart, threat model, roadmap, benchmark, demo scenarios.