百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

sandlock

> AI 编程
开源

最轻量级的 AI 沙箱。基于进程的 Linux 沙箱,无容器、无虚拟机、无特权、无提示注入

316 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

最轻量级的 AI 沙箱。基于进程的 Linux 沙箱,无容器、无虚拟机、无特权、无提示注入

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

bash
# 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

bash
cargo install --path crates/sandlock-cli

Quick Start

CLI

…

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

Python API

…

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

Rust API

…

Documentation

Document Contents
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/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

bash
# Rust tests
cargo test --release

# Python tests
cd python && pip install -e . && pytest tests/

Issues· 20 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustai-agentsfaaslandlocklinux

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类AI 编程
定价开源

> 相关工具

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.