← 开源
multikernel

sandlock

The lightest AI sandbox. A process-based sandbox for Linux, no container, no VM, no privilege, no prompt injection

InfrastructureMake world agent-readyRust
在 GitHub 打开
增长势头
+124 小时新增 Star+0.2%
569
Star
59
Fork
11
贡献者
创建于 2026-03-13 · 更新于 2026-10-16 · 今日第 6720 名
主要开发者

multikernel/sandlock 排名第 6,720,有 569 个星标。

同类别比较

multikernel/sandlock 排名第 6,720,此处有 8 个同类条目;intel/llm-scaler 排名第 6,728。

同类别比较
名称排名指标
AmazingAng/auth2api6,677
语言:
TypeScript
星标数:
583
分叉数:
130
简介:
Lightweight Claude OAuth to OpenAI-compatible API proxy
Samsung/ONE6,684
语言:
Python
星标数:
581
分叉数:
186
简介:
On-device Neural Engine
uppinote20/claude-dashboard6,687
语言:
TypeScript
星标数:
581
分叉数:
67
简介:
Comprehensive status line plugin for Claude Code with context usage, API rate limits, and cost tracking
Continuum-AI-Corp/OrcaBonsai-27B-Uncensored6,690
语言:
Python
星标数:
577
分叉数:
67
intel/llm-scaler6,728
语言:
C++
星标数:
565
分叉数:
84
microsoft/mscclpp6,729
语言:
C++
星标数:
563
分叉数:
110
简介:
MSCCL++: A GPU-driven communication stack for scalable AI applications
yassa9/qwen6006,735
语言:
Cuda
星标数:
561
分叉数:
49
简介:
Static suckless single batch CUDA-only qwen3-0.6B mini inference engine
rookiestar28/ComfyUI-OpenClaw6,744
语言:
Python
星标数:
558
分叉数:
58
简介:
Your own personal AIGC Factory. Any picture. Any reel. The Comfy way. ©️
关键参数与规格
关键参数与规格
参数值
语言Rust
类别Infrastructure
子类别Make world agent-ready
关键词AI safety, DevOps, Guardrails, Security
星标数569
分叉数59
贡献者11
创建日期2026-03-13
更新日期2026-10-16
1 天星标数1
排名6,720
上次排名6,886
排名变化166
7 天星标排名19,237
上次 7 天星标排名19,207
7 天星标排名变化-30
总星标排名17,505
上次总星标排名17,496
总星标排名变化-9
README 摘录

Sandlock Lightweight process sandbox for Linux. Confines untrusted code using **Landlock** (filesystem + network + IPC), **seccomp-bpf** (syscall filtering), and **seccomp user notification** (resource limits, IP enforcement, /proc virtualization). Containers and VMs are powerful but heavy. Sandlock targets the gap: strict confinement without image builds or root privileges. Built-in COW filesystem protects your working directory automatically. Architecture Sandlock is implemented in **Rust** for performance and safety: **sandlock-core**: Rust library (Landlock, seccomp, supervisor, COW, pipeline) **sandlock-cli**: Rust CLI binary

( ) **sandlock-oci**: OCI runtime shim for containerd, CRI-O, and Kubernetes (namespace-less) **sandlock-ffi**: C ABI shared library ( ) **Python SDK**: ctypes bindings to the FFI library **Go SDK**: cgo bindings to the FFI library See for how the pieces fit together and how confinement is applied. 7 (ABI v4) | | Landlock IPC scoping | 6. 12 (ABI v6) | Protections can be selectively waived per-policy when needed; see . Install From source CLI only Optional features All five features ( , , , , ) are enabled by

default. Build with none or select the ones you need: See Building Sandlock for feature dependencies and Rust library configuration. Quick Start CLI The full option tour (GPU, network grammar, HTTPS MITM, credential injection, port virtualization, chroot, nesting) is in . Python API See for the SDK guide, including HTTP ACL, chroot mounts, port virtualization, , and deferred commit. 1% of bare metal | | Redis GET (100K ops) | 79K rps | 77K rps | 53K rps | 97. 1% of bare metal | | Redis p99 latency | 0

.

常见问题

记录了多少星标和分叉?

multikernel/sandlock 有 569 个星标和 59 个分叉。

仓库排名是多少?

multikernel/sandlock 排名第 6,720。

记录的语言和类别是什么?

multikernel/sandlock 有 569 个星标,语言为 Rust,类别为 Infrastructure。

哪个仓库排名最接近?

multikernel/sandlock 与 intel/llm-scaler 比较,后者排名第 6,728,有 565 个星标。

README

Sandlock

Lightweight process sandbox for Linux. Confines untrusted code using Landlock (filesystem + network + IPC), seccomp-bpf (syscall filtering), and seccomp user notification (resource limits, IP enforcement, /proc virtualization). No root, no cgroups, no containers.

sandlock run -w /tmp -r /usr -r /lib -m 512M -- python3 untrusted.py

Why Sandlock?

Containers and VMs are powerful but heavy. Sandlock targets the gap: strict confinement without image builds or root privileges. Built-in COW filesystem protects your working directory automatically.

Feature Sandlock Container MicroVM (Firecracker)
Root required No Yes* Yes (KVM)
Image build No Yes Yes
Startup time ~5 ms ~200 ms ~100 ms
Kernel Shared Shared Separate guest
Filesystem isolation Landlock + seccomp COW Overlay Block-level
Network isolation Landlock + seccomp notif Network namespace TAP device
HTTP-level ACL Method + host + path rules N/A N/A
Syscall filtering seccomp-bpf seccomp N/A
Resource limits seccomp notif + SIGSTOP cgroup v2 VM config

* Rootless containers exist but require user namespace support and /etc/subuid configuration.

Architecture

Sandlock is implemented in Rust for performance and safety:

  • sandlock-core: Rust library (Landlock, seccomp, supervisor, COW, pipeline)
  • sandlock-cli: Rust CLI binary (sandlock run ...)
  • sandlock-oci: OCI runtime shim for containerd, CRI-O, and Kubernetes (namespace-less)
  • sandlock-ffi: C ABI shared library (libsandlock_ffi.so)
  • Python SDK: ctypes bindings to the FFI library
  • Go SDK: cgo bindings to the FFI library

See docs/architecture.md for how the pieces fit together and how confinement is applied.

Requirements

  • Linux 6.12+ (Landlock ABI v6), Rust 1.70+ (to build)
  • Python 3.8+ (optional, for Python SDK)
  • No root, no cgroups
Feature Minimum kernel
seccomp user notification 5.6
Landlock filesystem rules 5.13
Landlock TCP port rules 6.7 (ABI v4)
Landlock IPC scoping 6.12 (ABI v6)

Protections can be selectively waived per-policy when needed; see docs/sandbox-reference.md#protection-opt-out.

Install

From source

# Build the Rust binary and shared library
cargo build --release

# Install Python SDK (auto-builds Rust FFI library)
cd python && pip install -e .

CLI only

cargo install --path crates/sandlock-cli

Optional features

All five features (http, checkpoint, image, profiles, cow) are enabled by default. Build with none or select the ones you need:

cargo build --release --no-default-features
cargo build --release --no-default-features --features http,profiles

See Building Sandlock for feature dependencies and Rust library configuration.

Quick Start

CLI

# Basic confinement
sandlock run -r /usr -r /lib -w /tmp -- ls /tmp

# Interactive shell (the sandboxed command inherits the terminal)
sandlock run -r /usr -r /lib -r /lib64 -r /bin -r /etc -w /tmp -- /bin/sh

# Resource limits + timeout
sandlock run -m 512M -P 20 -t 30 -- ./compute.sh

# Outbound allowlist: one host on one port
sandlock run --net-allow api.openai.com:443 -r /usr -r /lib -r /etc -- python3 agent.py

# HTTP-level ACL (method + host + path rules via transparent proxy)
sandlock run \
  --http-allow "GET docs.python.org/*" \
  --http-allow "POST api.openai.com/v1/chat/completions" \
  --http-deny "* */admin/*" \
  -r /usr -r /lib -r /etc -- python3 agent.py

# COW filesystem (writes captured, committed on success)
sandlock run --workdir /opt/project -r /usr -r /lib -- python3 task.py

# Dry-run (show what files would change, then discard)
sandlock run --dry-run --workdir . -w . -r /usr -r /lib -r /bin -r /etc -- make build

# Use a saved profile
sandlock run -p build -- make -j4

The full option tour (GPU, network grammar, HTTPS MITM, credential injection, port virtualization, chroot, nesting) is in docs/cli.md.

Python API

from sandlock import Sandbox, BranchAction

sandbox = Sandbox(
    fs_writable=["/tmp/sandbox"],
    fs_readable=["/usr", "/lib", "/etc"],
    max_memory="256M",
    max_processes=10,
    clean_env=True,
)

# Run a command (with optional timeout in seconds)
result = sandbox.run(["python3", "-c", "print('hello')"], timeout=30)
assert result.success
assert b"hello" in result.stdout

# Dry-run: see what files would change, then discard
sandbox = Sandbox(fs_writable=["."], workdir=".", fs_readable=["/usr", "/lib", "/bin", "/etc"],
                  on_exit=BranchAction.ABORT)
result = sandbox.run(["make", "build"])
for c in result.changes:
    print(f"{c.kind}  {c.path}")  # A=added, M=modified, D=deleted

See python/README.md for the SDK guide, including HTTP ACL, chroot mounts, port virtualization, confine(), and deferred commit.

Rust API

use sandlock_core::{confine, Confinement, Sandbox};
use sandlock_core::sandbox::ByteSize;

let mut sandbox = Sandbox::builder()
    .fs_read("/usr").fs_read("/lib")
    .fs_write("/tmp")
    .max_memory(ByteSize::mib(256))
    .name("hello-box")
    .build()?;
let result = sandbox.run(&["echo", "hello"]).await?;
assert!(result.success());

// HTTP ACL: restrict API access at the HTTP level
let mut agent = Sandbox::builder()
    .fs_read("/usr").fs_read("/lib").fs_read("/etc")
    .http_allow("POST api.openai.com/v1/chat/completions")
    .http_deny("* */admin/*")
    .name("agent-box")
    .build()?;
let result = agent.run(&["python3", "agent.py"]).await?;

// Confine the current process (Landlock filesystem only, irreversible)
let confinement = Confinement::builder()
    .fs_read("/usr").fs_read("/lib")
    .fs_write("/tmp")
    .build();
confine(&confinement)?;

Documentation

Document Contents
docs/building.md Build commands, optional features, and minimal Rust embedding
docs/cli.md Every sandlock run option by example, profiles, ps / inspect / kill
docs/sandbox-reference.md Every Sandbox field, default, and TOML key; credentials; protection opt-out
docs/network.md Endpoint grammar, protocol gating, HTTP interception, bind rules, port virtualization
docs/policy-fn.md Dynamic policy callbacks: events, verdicts, context methods, TOCTOU guarantees
docs/pipelines.md Pipelines, the XOA pattern, COW fork and map-reduce
docs/prompt_injection.md Prompt injection defenses: isolation, permissions, credentials, and text inspection
docs/architecture.md Crate layout, confinement sequence, supervisor handlers, COW filesystem
docs/learn.md sandlock learn: generate a profile from an observed run
docs/extension-handlers.md Custom seccomp-notification handlers (Rust and C ABI)
docs/python-handlers.md Custom handlers from Python
python/README.md Python SDK guide
go/README.md Go SDK guide
crates/sandlock-oci/README.md OCI runtime shim

Performance

Benchmarked on a typical Linux workstation:

Workload Bare metal Sandlock Docker Sandlock overhead
/bin/echo startup 2 ms 7 ms 307 ms 5 ms (44x faster than Docker)
Redis SET (100K ops) 82K rps 80K rps 52K rps 97.1% of bare metal
Redis GET (100K ops) 79K rps 77K rps 53K rps 97.1% of bare metal
Redis p99 latency 0.5 ms 0.6 ms 1.5 ms ~2.5x lower than Docker
COW fork ×1000 n/a 530 ms n/a 530μs/fork, ~1,900 forks/sec

Testing

# Rust tests
cargo test --release

# Python tests
cd python && pip install -e . && pytest tests/
排名相邻
同类项目