Skip to content
jmanoj0905Public

About

Kernel-level dynamic policy enforcement for AI agents, intercepts LLM intent from TLS traffic, synthesizes per-task syscall policies, blocks violations before completion.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

KAIROS

CI BPF build

KAIROS (καιρός)

The right action, at the right time.


KAIROS is a Linux security research project for AI agent sandboxing. It explores whether an agent's declared tool intent can be observed from LLM API traffic, translated into a task-scoped policy, and enforced at the kernel layer before a forbidden action completes.

The current target is a focused prototype that proves the intent-to-policy-to-enforcement loop for one monitored agent process. Larger platform features are documented as future work.

Problem

AI agent security tools usually see only one side of the system.

Application-layer tools understand prompts, tool calls, and intent, but they share the agent's trust boundary. A prompt injection that escapes through bash, a package postinstall script, or an unmonitored subprocess can bypass them.

Kernel-layer tools see process execution, file access, and network activity, but they lack semantic context. They cannot naturally distinguish a legitimate task-specific file read from an unrelated sensitive-file access.

KAIROS focuses on the gap between those layers: use observed LLM intent to generate narrow, temporary kernel-enforced permissions.

Approach

flowchart LR
    accTitle: KAIROS MVP Pipeline
    accDescr: KAIROS observes LLM intent, synthesizes a policy, loads it into the enforcement substrate, and evaluates whether agent actions stay within the declared task.

    tls["Observed LLM traffic"]
    extractor["Intent extractor"]
    synthesizer["Policy synthesizer"]
    loader["Policy loader"]
    enforcement["Kernel enforcement"]
    eval["Evaluation harness"]

    tls --> extractor --> synthesizer --> loader --> enforcement --> eval
Loading

The MVP targets an Anthropic-backed CLI agent in a controlled Linux environment where OpenSSL SSL_read uprobes can observe decrypted API responses. Tetragon is the provisional enforcement substrate; raw BPF LSM remains the fallback if Tetragon cannot prove pre-completion blocking semantics.

MVP Scope

Component MVP target
Intent source Anthropic tool-use responses observed through OpenSSL
Policy engine Deterministic rule-based taxonomy
Enforcement Tetragon first, raw BPF LSM fallback if needed
Environment macOS M1 Docker for development; Linux / EC2 for validation
Evaluation Benign sessions, attack corpus, latency, overhead

Attack Corpus

Attack class Required MVP behavior
Prompt injection file access Block unauthorized sensitive-file reads
Malicious package postinstall Block unauthorized subprocess execution
Unauthorized PII file access Block file access outside declared task scope

DNS tunneling, lateral movement, Kubernetes deployment, HITL approval, OPA hooks, LLM refinement, signed audit logs, replay tooling, and multi-tenant support are future work.

Build & Run

Layout

Package Role
probe/ eBPF programs (probe/bpf/*.bpf.c) and the Go event source that reads the ring buffer
extractor/ Extracts declared tool intent from observed HTTP/2 LLM API streams
synthesizer/ Turns extracted intent into a task-scoped policy
compiler/ Lowers a policy into a backend-neutral representation
loader/ + backend/ Orchestrates the intent-to-enforcement loop; backend is the seam to the substrate (Tetragon gRPC)
bus/ Typed generic pub/sub event bus connecting the stages
internal/wire/ Binary wire format between the BPF layer and userspace
internal/types/ Domain types shared across packages
attribution/, audit/, daemon/, eval/ Process attribution, durable audit trail, process wiring, attack harness

Unit tests — no toolchain needed

The pure-Go packages build and test on any platform with a Go toolchain:

make test-unit

Full build — Linux with a BPF toolchain

probe/probes_bpfel.go embeds probes_bpfel.o, which is generated rather than committed, so the probe package does not compile until the BPF objects are built. That needs:

  • Linux, kernel 5.8+ (BPF ring buffer); enforcement additionally needs Tetragon v1.6.0+
  • clang and llvm (BPF target)
  • libbpf-dev
  • Go toolchain per go.mod

probe/bpf/vmlinux.h is committed, so no BTF dump from your own kernel is required for a CO-RE build:

make build-bpf     # compile BPF C, run bpf2go
make build         # build all Go binaries
make test          # all tests, race detector on
make lint          # go vet + clang static analysis of the BPF C

Regenerate vmlinux.h against your own kernel only if you need to:

make vmlinux       # needs bpftool and /sys/kernel/btf/vmlinux

Enforcement

Development on macOS runs userspace code in Docker; kernel enforcement claims are validated on real Linux. See Docs/BUILD.md for the Docker and Linux enforcement profiles, and Docs/ENFORCEMENT_PROOF.md for the Phase 0 evidence that blocking happens before the syscall completes. Design decisions are logged in Docs/DESIGN.md.

The integration test under probe/ carries //go:build linux && integration and needs root for BPF map access:

sudo -E go test -tags integration -race -count=1 ./probe/

Status

Area Status
Scope and threat model Defined
Docker development strategy Defined
Phase 0: Enforcement proof Complete (2026-05-18)
Phase 1: eBPF Probe Layer Complete
Phase 2: Intent Extractor Complete
Phase 3: Policy Synthesizer Complete
Phase 4: Policy Loading + Enforcement In progress
Phase 5: Core Pipeline Integration Not started
Final validation Pending real Linux / EC2 run

Success Criteria

Metric Target
MVP attack blocking 3 / 3 attacks blocked
False positive rate Under 5 percent on benign sessions
Policy swap latency p99 under 100 ms if the substrate supports it
CPU overhead Under 5 percent relative to baseline
Reproducibility Documented Docker and Linux validation workflows

Limitations

  • Native macOS kernel enforcement is not supported.
  • Docker Desktop is a development environment, not the final validation target.
  • The MVP does not claim universal agent or provider support.
  • The MVP assumes observable OpenSSL traffic for the target agent.
  • Prevention claims depend on the enforcement proof passing on real Linux.

About

Kernel-level dynamic policy enforcement for AI agents, intercepts LLM intent from TLS traffic, synthesizes per-task syscall policies, blocks violations before completion.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages