Skip to content

docs(security): three-component architecture (PTY + eBPF + SLM daemon)#75

Merged
fentas merged 2 commits into
masterfrom
docs/security-ebpf-slm-architecture
May 18, 2026
Merged

docs(security): three-component architecture (PTY + eBPF + SLM daemon)#75
fentas merged 2 commits into
masterfrom
docs/security-ebpf-slm-architecture

Conversation

@fentas
Copy link
Copy Markdown
Owner

@fentas fentas commented May 18, 2026

Summary

Major update to `docs/security-guard-design.md` capturing the 2026-05-18 design conversation. Key shift: no custom kernel module, three cooperating user-space + eBPF pieces, hybrid sync/async driven by a PTY-proxy threat-level state machine.

Architectural reframe

```
atty (PTY proxy, Zig) ◀── UDS RPC ──▶ atty-guard (Rust/Go daemon)
│ │
▼ PID → threat level ▼
eBPF hash map ─────────────▶ ONNX-SLM (Tier 1 regex + Tier 2 model)

│ kernel: bpf_lsm_security_bprm_check + sys_enter_execve

every execve gated by parent's threat-level entry
```

  • atty (PTY proxy) — sees command intent at typed-line time, picks the threat level.
  • eBPF LSM — backstops the PTY blind spot (e.g. `npm postinstall` scripts that fork detached processes).
  • atty-guard — owns the ONNX SLM (eBPF verifier rejects FP + >512B stack + unbounded loops).

What the doc now covers

  • TL;DR section with an ASCII flow diagram.
  • Threat-level matrix (Benign → Critical) with example triggers + inspection mode.
  • Two modes spelled out (async = log-and-pass, sync = stall execve until SLM verdicts).
  • Edge cases: terminal-escape obfuscation, non-PTY bypass (reverse shells), PID-tree explosion on `make -j`, atty-guard down, state-sharing options.
  • V2 rewrite: atty-guard now ships TWO things together (daemon + eBPF object). Explicit "why three processes" rationale: failure isolation, CAP_BPF privilege boundary, model footprint, classifier sandboxing.
  • V3 stretch: Tier 3 SIGSTOP-on-`;C` is subsumed by the eBPF backstop; new stretch items — process-group propagation + MFA on Critical-tier blocks.
  • Anti-patterns clarified: custom kernel module is OUT (use eBPF). Separate daemon process is IN by design.

Test plan

  • `zig fmt --check` clean (no code changes)
  • Markdown renders (verified locally)

🤖 Generated with Claude Code

fentas and others added 2 commits May 18, 2026 09:05
Major design update per 2026-05-18 external review. Three cooperating
pieces with a hard kernel/user-space split:

  1. atty (PTY proxy, Zig) — sees command intent at typed-line time,
     decides threat level via deterministic state machine, marks
     high-risk PID trees in an eBPF hash map.
  2. eBPF LSM (kernel, no custom module) — backstops the PTY blind
     spot (postinstall scripts that fork detached processes never go
     through atty's PTY but DO go through security_bprm_check).
  3. atty-guard (Rust/Go daemon) — owns the ringbuf + ONNX SLM.
     eBPF can't host the model (verifier rejects FP / >512B stack /
     unbounded loops).

Hybrid async/sync mode driven by threat level: `git status` stays
async (zero perceptible latency); `npm install` / `curl | bash` /
interpreted-code-execution flip to synchronous block-and-classify.
PID-tree marking propagates the high-threat status to every child
process spawned under a risky parent, closing the postinstall
bypass.

Doc additions:

  - TL;DR ASCII diagram of the three-component flow.
  - Threat-level matrix (Benign/High/Critical with example commands).
  - Spelled-out semantics of the two modes (async vs sync).
  - Edge cases: terminal-escape obfuscation, non-PTY bypass, PID-tree
    explosion on `make -j`, atty-guard down, state-sharing options.
  - V2 section rewritten — atty-guard now ships TWO pieces (daemon +
    eBPF object), with explicit "why three processes" rationale
    (failure isolation, CAP_BPF boundary, model footprint).
  - V3 stretch — Tier 3 SIGSTOP is subsumed by the eBPF backstop;
    list process-group propagation + MFA on Critical as new stretch.
  - Anti-patterns clarified: custom kernel module is OUT (use eBPF);
    separate daemon is IN by design, not against the suckless ethos.

No code changes — design doc only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@fentas fentas merged commit 2c4214c into master May 18, 2026
3 checks passed
@fentas fentas deleted the docs/security-ebpf-slm-architecture branch May 18, 2026 07:11
@github-actions github-actions Bot mentioned this pull request May 19, 2026
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.

1 participant