# 沙箱（计算机安全）

在计算机安全领域，沙箱是一种受限的执行环境，不可信或存在漏洞的代码在其中运行，其对资源的访问受到显式或隐式安全策略的限制。凡是必须运行软件但又无法信任或验证软件的地方，都会出现沙箱：Chrome 和 [Internet Explorer](https://www.edgepedia.org/zh/internet-explorer) 等浏览器引擎、[Microsoft Word](https://www.edgepedia.org/zh/microsoft-word) 和 Adobe Reader 等生产力软件，以及 [Windows 8](https://www.edgepedia.org/zh/windows-8) 等操作系统内核，都在不同程度上被沙箱化<sup>[1](https://www.cs.cmu.edu/~jssunshi/assets/pdf/maass2016systematic.pdf)</sup>。包括 Android、iOS 和各大 Linux 发行版在内的现代操作系统，都允许在沙箱内运行不可信进程，其资源访问按可配置的策略受到限制<sup>[2](https://www.fruct.org/files/publications/volume-35/fruct35/Niem.pdf)</sup>。沙箱不同于虚拟机——虚拟机在独立于系统其余部分的模拟硬件上运行软件<sup>[1](https://www.cs.cmu.edu/~jssunshi/assets/pdf/maass2016systematic.pdf)</sup>；沙箱的目标是缓解应用程序中缺陷以及意外或恶意行为的安全影响<sup>[3](https://man7.org/linux/man-pages/man7/Landlock.7.html)</sup>。浏览器利用沙箱将网页内容与操作系统其余部分隔离，这样即使恶意脚本或漏洞利用在浏览器中运行，也无法轻易访问文件、执行系统命令或进行横向移动<sup>[4](https://www.rapid7.com/fundamentals/sandboxing/)</sup>。

| 关键事实 | 详情 |
|---|---|
| 定义 | 在显式或隐式安全策略下受限执行不可信代码，用于浏览器、办公软件、内核和恶意软件分析<sup>[1](https://www.cs.cmu.edu/~jssunshi/assets/pdf/maass2016systematic.pdf)</sup><sup> • </sup><sup>[2](https://www.fruct.org/files/publications/volume-35/fruct35/Niem.pdf)</sup> |
| 核心机制 | 命名空间虚拟化、系统调用介入、内核子系统挂钩、软件故障隔离和硬件虚拟化<sup>[2](https://www.fruct.org/files/publications/volume-35/fruct35/Niem.pdf)</sup><sup> • </sup><sup>[6](https://cseweb.ucsd.edu/~dstefan/cse227-spring22/papers/tan:sfi.pdf)</sup><sup> • </sup><sup>[5](https://www.salmanq.com/blog/understanding-sandboxes/)</sup> |
| 开销 | 软件故障隔离开销低于 5%；Chrome 沙箱增加约 2–5% 的 CPU 占用；Firecracker 微虚拟机启动时间低于 125 毫秒，VMM 内存占用低于 5 MiB<sup>[6](https://cseweb.ucsd.edu/~dstefan/cse227-spring22/papers/tan:sfi.pdf)</sup><sup> • </sup><sup>[7](https://blog.send.win/browser-isolation-vs-sandboxing-complete-comparison-alternatives-2026/)</sup><sup> • </sup><sup>[5](https://www.salmanq.com/blog/understanding-sandboxes/)</sup> |
| 逃逸记录 | 浏览器被称为受攻击最多的沙箱，但大多数年份在 Pwn2Own 上仍被攻破；容器运行时反复出现逃逸 CVE，包括 runc CVE-2019-5736 和 CVE-2024-21626<sup>[8](https://www.endorlabs.com/learn/sandboxes-a-primer-on-containing-things-that-dont-want-to-be-contained)</sup><sup> • </sup><sup>[9](https://longtermwiki.vercel.app/wiki/E513)</sup> |
| 规避 | 规避型恶意软件主要关注检测沙箱，主要手段是指纹识别，而响应式防御很容易被零日指纹识别和拖延战术挫败<sup>[10](https://dl.acm.org/doi/10.1145/3365001)</sup> |
| 近期转变 | WASI Preview 2（2024 年）使 WebAssembly 成为可声明的能力接口<sup>[11](https://www.systemshardening.com/articles/wasm/wasi-preview2-capability-isolation/)</sup> |

## 隔离机制

沙箱实现借助少数几种机制构建而成。主要构件是命名空间虚拟化、系统调用介入和内核子系统挂钩<sup>[2](https://www.fruct.org/files/publications/volume-35/fruct35/Niem.pdf)</sup>。综述文献区分了三种遏制方式：进程自遏制，由进程自身配置；进程包装，由沙箱管理器应用配置；以及强制进程遏制，由特权系统管理员配置<sup>[2](https://www.fruct.org/files/publications/volume-35/fruct35/Niem.pdf)</sup>。

**系统调用过滤与访问控制。** 在 Linux 上，seccomp-BPF 限制进程可以发起哪些系统调用；Chromium 的 Linux 沙箱在其第二层中使用它，该层是减少攻击面的层，限制进程对内核攻击面的访问<sup>[13](https://chromium.googlesource.com/chromium/src.git/+show/63cff3378eccfcba582f16fdf1f3db5d9108b1c4/docs/linux_sandboxing.md)</sup>。Landlock 是一个可堆叠的 Linux 安全模块，扮演不同的角色：其规则侧重于内核对象上的访问控制，而非系统调用过滤——后者是 seccomp-bpf 的目的<sup>[14](https://docs.kernel.org/security/landlock.html)</sup>。Landlock 规则无法以编程方式与用户空间通信，这一设计选择是为了避免侧信道攻击，例如安全策略泄露<sup>[14](https://docs.kernel.org/security/landlock.html)</sup>。Linux 能力（capabilities）通过将 root 的整体特权拆分为约 40 种细粒度能力（如 CAP_NET_ADMIN 和 CAP_SYS_PTRACE）来补充这些过滤器<sup>[5](https://www.salmanq.com/blog/understanding-sandboxes/)</sup>。

**软件故障隔离。** 基于软件的故障隔离（SFI）通过在内存和控制转移指令之前插入动态检查来建立逻辑保护域；已报告的实现达到了低于 5% 的性能开销，且不依赖特殊硬件或操作系统支持<sup>[6](https://cseweb.ucsd.edu/~dstefan/cse227-spring22/papers/tan:sfi.pdf)</sup>。由于 SFI 保护域保持在同一个进程内，域跨越的成本很低，这使得该技术对浏览器与插件通信等频繁交互场景具有吸引力<sup>[6](https://cseweb.ucsd.edu/~dstefan/cse227-spring22/papers/tan:sfi.pdf)</sup>。

**硬件虚拟化。** 在硬件虚拟化一端，客户机内核在非根模式下运行，但隔离依赖于 hypervisor 和虚拟化机制；面向主机的攻击面包括 hypervisor 的设备模拟代码和虚拟机退出处理，而非容器所使用的共享宿主内核系统调用接口<sup>[5](https://www.salmanq.com/blog/understanding-sandboxes/)</sup>。

**各层泄露什么。** 隔离层在隔离什么以及在哪里泄露方面各不相同。CPU 配额泄露时序侧信道；内存隔离泄露共享缓存；文件系统命名空间泄露绑定挂载的宿主路径和 /proc；系统调用过滤使内核攻击面暴露；身份作用域泄露环境变量和挂载的凭据<sup>[8](https://www.endorlabs.com/learn/sandboxes-a-primer-on-containing-things-that-dont-want-to-be-contained)</sup>。命名空间和 seccomp 边界是同一内核内的软件检查——不可信代码正是调用这个内核——因此一个可利用的内核漏洞就能一次性移除所有这些边界，而 VM 边界则需要单独的 hypervisor 或 KVM 漏洞才能到达主机<sup>[15](https://opencomputer.dev/guides/firecracker-vs-cloud-hypervisor-vs-kata/)</sup>。gVisor 占据中间位置：它是一个应用内核，实现类 Linux 接口，用内存安全语言 Go 编写并在用户空间运行；它不是 seccomp-bpf 那样的系统调用过滤器，不是 firejail 或 AppArmor 之上的包装器，也不是传统虚拟机<sup>[16](https://fly.io/learn/firecracker-vs-gvisor/)</sup>。

## 各平台的沙箱实现

**Windows。** Windows 8 引入的 AppContainer 提供沙箱环境，除非明确允许，否则限制对系统资源、其他应用程序和用户数据的访问，使用 SID、令牌和 DACL<sup>[17](https://learn.microsoft.com/en-us/windows/win32/secauthz/implementing-an-appcontainer)</sup>。AppContainer 的访问令牌携带唯一的包 SID 以及能力 SID：没有网络能力就无法访问网络，没有摄像头能力就无法访问摄像头<sup>[17](https://learn.microsoft.com/en-us/windows/win32/secauthz/implementing-an-appcontainer)</sup>。AppContainer 以低完整性级别运行，限制与更高完整性对象的交互，并与其他应用程序的进程、窗口、设备、文件、注册表项、网络和凭据隔离<sup>[17](https://learn.microsoft.com/en-us/windows/win32/secauthz/implementing-an-appcontainer)</sup>。低特权 AppContainer（LPAC）隔离程度更高：LPAC 没有 registryRead 能力就无法打开注册表项，没有 lpacCom 能力就无法使用 COM<sup>[17](https://learn.microsoft.com/en-us/windows/win32/secauthz/implementing-an-appcontainer)</sup>。Windows Sandbox 位于此层之上：它使用基于 hypervisor 的虚拟化将应用程序与主机隔离，依赖 Microsoft hypervisor 运行单独的内核<sup>[18](https://learn.microsoft.com/en-us/windows/security/application-security/application-isolation/windows-sandbox/)</sup>。它是一次性的、纯净的，关闭时丢弃一切，启动只需数秒，内存占用低于完整 VM，随 Windows 专业版、企业版和[教育](https://www.edgepedia.org/zh/education)版提供<sup>[18](https://learn.microsoft.com/en-us/windows/security/application-security/application-isolation/windows-sandbox/)</sup>。

**macOS。** Apple 的 App Sandbox 仅授予沙箱化应用对操作系统在启动时创建的容器目录的无限制读写访问；应用对用户主文件夹没有无限制访问权限<sup>[19](https://developer.apple.com/documentation/security/protecting-user-data-with-app-sandbox.md)</sup>。操作系统禁止沙箱化应用进行某些活动，开发者必须移除这些活动或找到替代方式提供相同功能<sup>[19](https://developer.apple.com/documentation/security/protecting-user-data-with-app-sandbox.md)</sup>。

**Linux。** Landlock 使任何进程能够安全地限制自身及其未来的子进程，在现有的系统级访问控制之上创建沙箱层<sup>[3](https://man7.org/linux/man-pages/man7/Landlock.7.html)</sup>。结合命名空间和 seccomp-BPF，这些原语构成了大多数 Linux 沙箱的基础，而 minijail 等统一框架将多种进程沙箱技术抽象在通用接口之后<sup>[2](https://www.fruct.org/files/publications/volume-35/fruct35/Niem.pdf)</sup>。

**浏览器。** Chromium 沙箱是一个 C++ 库，创建沙箱化进程，这些进程唯一可自由使用的资源是 CPU 周期和内存<sup>[20](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/design/sandbox_faq.md)</sup>。沙箱化进程无法写入磁盘或显示自己的窗口，行为由显式策略管理<sup>[20](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/design/sandbox_faq.md)</sup>。渲染进程以这种方式运行，因此其中的缺陷无法在用户账户中安装持久性恶意软件，也无法读取和窃取任意文件<sup>[20](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/design/sandbox_faq.md)</sup>。沙箱化代码通过管道或共享内存通信；在 Chromium 中，整个 WebKit 代码在沙箱中运行，输出渲染为位图<sup>[20](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/design/sandbox_faq.md)</sup>。沙箱在进程调用 LowerToken() 后生效，在此之前存在一个启动窗口期，进程可以访问关键资源<sup>[20](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/design/sandbox_faq.md)</sup>。

## 沙箱、容器与虚拟机的比较

三方分类涵盖了主要运行时选项：使用 [Linux 命名空间](https://www.edgepedia.org/zh/linux-namespaces)和 cgroup 的容器化运行时，可选地用 gVisor 或 seccomp 加固；微虚拟机，即 KVM 支持的轻量级 VM，配有极简 VMM，如基于 [Firecracker](https://www.edgepedia.org/zh/firecracker) 的提供商和 Kata Containers；以及操作系统级隔离器，如 Linux 上的 bubblewrap 和 macOS 上的 sandbox-exec/Seatbelt<sup>[21](https://www.agentpatterns.ai/security/sandbox-runtime-comparison/)</sup>。在此比较中，容器被描述为在没有 gVisor 或 Kata 的情况下多租户安全性较弱，而微虚拟机被描述为提供强隔离<sup>[21](https://www.agentpatterns.ai/security/sandbox-runtime-comparison/)</sup>。

成本差异显著。Firecracker 的规格目标是在 1 vCPU/128 MiB 下 VM 启动到客户机 init ≤125 毫秒，VMM 开销 ≤5 MiB，而操作系统级隔离器在几十毫秒内启动，开销可忽略不计，但继承父环境，包括其机密信息<sup>[21](https://www.agentpatterns.ai/security/sandbox-runtime-comparison/)</sup>。一份运行时比较报告称，runc 启动时间约 50 毫秒，gVisor 约 100 毫秒，Kata（QEMU）100–200 毫秒，Firecracker 低于 125 毫秒，内存开销分别约为 0、50–100 MB、20–50 MB 和 5 MB<sup>[22](https://safeguard.sh/resources/blog/container-runtime-comparison-security)</sup>。Firecracker 等轻量级 VMM 将模拟设备模型削减到几乎为零，但 VM 仍需要客户机内核和内存，启动时间因实现而异<sup>[8](https://www.endorlabs.com/learn/sandboxes-a-primer-on-containing-things-that-dont-want-to-be-contained)</sup>。Vercel Sandboxes 在各自的 Firecracker 微虚拟机中运行每个沙箱，配有专用内核，提供比共享内核容器方案更强的隔离，因此适合运行不可信代码<sup>[23](https://vercel.com/docs/sandbox/concepts)</sup>。在 macOS 上，sandbox-exec 自 macOS 10.13 起已弃用，因此新的 macOS 工具首选容器或微虚拟机<sup>[21](https://www.agentpatterns.ai/security/sandbox-runtime-comparison/)</sup>。

## 恶意软件分析中的沙箱

动态分析沙箱有几种类型。AMTSO 沙箱评估框架 v1.1 将其分类为实时动态、基于模拟、基于 QEMU 和传统基于 VM 的沙箱，每种在速度、资源效率和分析深度方面各有取舍<sup>[24](https://www.amtso.org/wp-content/uploads/2026/06/AMTSO_Sandbox_Evaluation_Framework_v1.1_ForReview.pdf)</sup>。几乎所有最大的恶意软件分析平台，如 [VirusTotal](https://www.edgepedia.org/zh/virustotal) 和 Malwr，以及内部反恶意软件项目，都使用 [Cuckoo Sandbox](https://www.edgepedia.org/zh/cuckoo-sandbox) 产品作为自动行为分析的后端<sup>[25](https://www.virusbulletin.com/uploads/pdf/magazine/2016/VB2016-Chailytko-Skuratovich.pdf)</sup>。

配置很重要，覆盖范围有限。一项知识系统化研究分析了八个家族中的 1,471 个真实恶意软件样本，发现所提出的沙箱指南可以将可观察的沙箱痕迹改善至少 1.6 倍；研究还发现通用沙箱的覆盖范围有限，偏向更突出的恶意软件家族，而基于虚拟化的沙箱在检测系统中更受青睐<sup>[26](https://arxiv.org/pdf/2403.16304)</sup>。同一研究指出，实际环境中的大多数恶意软件使用反分析策略来逃避检测和逆向工程<sup>[26](https://arxiv.org/pdf/2403.16304)</sup>。

## 规避与沙箱逃逸

**指纹识别与拖延。** 一项关于动态分析规避的综述发现，规避行为主要关注检测和逃避沙箱，指纹识别是主要策略，其次是较新的反向[图灵测试](https://www.edgepedia.org/zh/turing-test)策略，旨在检测人类交互<sup>[10](https://dl.acm.org/doi/10.1145/3365001)</sup>。恶意软件检查环境是否看起来像目标主机而非自动化系统<sup>[27](https://unit42.paloaltonetworks.com/sandbox-evasion-memory-detection/)</sup>。一个常见类别是检测文件是否在虚拟机中执行，通过指纹识别低 CPU 核心数、系统或视频内存、屏幕分辨率或特定 VM 的痕迹<sup>[27](https://unit42.paloaltonetworks.com/sandbox-evasion-memory-detection/)</sup>。供应商在 KVM、VirtualBox 和 Xen 等 VM 方案中选择，每种都有可被内部运行软件检测到的痕迹；Unit 42 认为防御者可能需要编写更难检测的定制沙箱<sup>[27](https://unit42.paloaltonetworks.com/sandbox-evasion-memory-detection/)</sup>。为击败规避，复杂的检测沙箱模仿真实用户的行为，延长样本运行时间以便观察延迟触发，并改变系统标识符使环境看起来像真实机器。<sup>[28](https://any.run/cybersecurity-blog/what-is-malware-sandbox/)</sup> 综述得出结论，当前的防御策略，从响应式方法到透明分析系统，都很容易被零日指纹识别或拖延等其他规避策略挫败<sup>[10](https://dl.acm.org/doi/10.1145/3365001)</sup>。Check Point Research（2025 年）描述了由此产生的动态：一旦攻击者添加沙箱规避检查，防御者就可以利用这些人类交互反规避机制中的统计弱点，通过假阴性和假阳性将检测压力翻转回攻击者身上<sup>[29](https://research.checkpoint.com/2025/the-cat-and-mouse-game-exploiting-statistical-weaknesses-in-human-interaction-anti-evasions/)</sup>。

**已知逃逸。** 有记录的逃逸包括 VENOM（CVE-2015-3456），它让客户机代码通过 QEMU 的虚拟软盘控制器突破；以及 2018 年的 Spectre 和 Meltdown 泄露，表明推测执行可以跨越硬件强制边界泄露内存<sup>[8](https://www.endorlabs.com/learn/sandboxes-a-primer-on-containing-things-that-dont-want-to-be-contained)</sup>。容器运行时 runc 产生了多个逃逸 CVE，包括 CVE-2019-5736，其中恶意镜像可以覆盖主机的 runc 二进制文件并在主机上执行代码<sup>[8](https://www.endorlabs.com/learn/sandboxes-a-primer-on-containing-things-that-dont-want-to-be-contained)</sup>。时间线中较晚的条目包括 CVE-2024-21626（“Leaky Vessels”），2024 年 1 月披露的通过文件描述符泄露的严重 runc 逃逸<sup>[9](https://longtermwiki.vercel.app/wiki/E513)</sup>；NVIDIA Container Toolkit 中的 CVE-2024-0132（CVSS 9.0，2024 年 9 月），允许从恶意容器镜像完全访问主机；以及 CVE-2025-23266（“NVIDIAScape”，CVSS 9.0），2025 年通过 OCI 钩子配置错误获得 root 访问权限<sup>[9](https://longtermwiki.vercel.app/wiki/E513)</sup>；还有 CVE-2024-1086，一个 [Linux 内核](https://www.edgepedia.org/zh/linux-kernel) netfilter 释放后使用漏洞，可实现容器逃逸，CISA 于 2025 年 10 月确认其正被用于勒索软件攻击<sup>[9](https://longtermwiki.vercel.app/wiki/E513)</sup>。瞬态执行侧信道也触及软件沙箱：它们可以绕过 [WebAssembly](https://www.edgepedia.org/zh/webassembly) 和 eBPF 的机密性和完整性属性，而 Meltdown-PK 允许攻击者完全绕过 Intel PKU<sup>[30](https://arxiv.org/html/2410.08434v1)</sup>。

**浏览器逃逸。** 浏览器同时堆叠所有技术：每个站点一个进程，渲染器被剥离几乎所有操作系统特权，以及源之间的站点隔离。但大多数年份在 Pwn2Own 上仍被攻破，因此强度来自整个技术栈而非任何单一壁垒<sup>[8](https://www.endorlabs.com/learn/sandboxes-a-primer-on-containing-things-that-dont-want-to-be-contained)</sup>。Chromium 沙箱本身无法提供对其运行所在内核等系统组件中缺陷的保护<sup>[20](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/design/sandbox_faq.md)</sup>。在 SandboxGym 研究的产品中，外围实现一次又一次地通过不安全的挂载配置、执行不一致的策略、路径处理错误、以提升权限运行的辅助程序、跨组件共享的状态以及管理 API 侵蚀甚至击败了隔离边界。<sup>[31](https://sandboxgym.io/)</sup>

## 数据一览

沙箱的开销因技术不同而相差数个数量级。SFI 开销低于 5%<sup>[6](https://cseweb.ucsd.edu/~dstefan/cse227-spring22/papers/tan:sfi.pdf)</sup>；面向 ARM64 的 LFI 系统在单个地址空间中支持数万个 4 GiB 沙箱，对加载、存储和跳转进行完整软件隔离，在 SPEC 2017 兼容子集上运行时开销为 7%<sup>[32](https://dl.acm.org/doi/10.1145/3620665.3640408)</sup>。Chrome 内置沙箱增加约 2–5% 的 CPU 占用<sup>[7](https://blog.send.win/browser-isolation-vs-sandboxing-complete-comparison-alternatives-2026/)</sup>。在开销较大的一端，Windows Sandbox 需要 Hyper-V，每个实例消耗 1–2 GB 内存，而基于 Docker 的浏览器容器增加约 200–500 毫秒的启动延迟<sup>[7](https://blog.send.win/browser-isolation-vs-sandboxing-complete-comparison-alternatives-2026/)</sup>。

用户空间内核以兼容性换取隔离。gVisor 暴露约 68 个宿主系统调用，支持约 350 个系统调用中的约 237 个，通过 Gofer RPC 路径提供降级的 I/O，被 Google Cloud Run 和 GKE Sandbox 使用<sup>[5](https://www.salmanq.com/blog/understanding-sandboxes/)</sup>；另一项比较将其覆盖率定为 70–80%，I/O 性能约为 Docker 的 10%<sup>[9](https://longtermwiki.vercel.app/wiki/E513)</sup>。Firecracker 启动时间低于 125 毫秒，每个微虚拟机 VMM 内存低于 5 MiB，提供完整的 Linux 兼容性和接近原生的 virtio I/O，被 [AWS Lambda](https://www.edgepedia.org/zh/aws-lambda) 和 AWS Fargate 使用<sup>[5](https://www.salmanq.com/blog/understanding-sandboxes/)</sup>。

硬件隔离有其自身代价。Intel SGX 加密内存操作可能比正常内存访问慢 5–20 倍，使得全浏览器 SGX 飞地化不切实际<sup>[7](https://blog.send.win/browser-isolation-vs-sandboxing-complete-comparison-alternatives-2026/)</sup>。一项针对五个 AI 代码沙箱的测量研究评估了六个引擎级属性，包括攻击面、信息泄露、CVE 历史、补丁延迟和模糊测试，发现引擎类别（微虚拟机、用户空间内核与容器）是主要的架构信号<sup>[33](https://fellows.tech/ai-sandboxes-paper)</sup>。上游沙箱引擎的补丁时间约为 0 天，但修复到达运营商的时间从当天到 471 天以上不等，这由每个产品的版本固定策略驱动<sup>[33](https://fellows.tech/ai-sandboxes-paper)</sup>。

## 近期发展

**WebAssembly 作为能力系统。** WASI Preview 2 在 2024 年 2 月发布的 Wasmtime 18.0 中稳定，引入了组件模型——一种用于 WASM 模块的类型安全、可组合的二进制格式<sup>[11](https://www.systemshardening.com/articles/wasm/wasi-preview2-capability-isolation/)</sup>；字节码联盟于 2024 年 1 月宣布了稳定化<sup>[34](https://safeguard.sh/resources/blog/webassembly-wasi-security-model-2025)</sup>。在 Preview 2 中，组件使用的每一项能力，包括文件系统访问、出站 HTTP、TCP 套接字、环境变量、随机数生成和挂钟时间，都必须表示为命名的 WIT 导入；未声明的导入不会被链接，从而不提供环境访问<sup>[11](https://www.systemshardening.com/articles/wasm/wasi-preview2-capability-isolation/)</sup>。Preview 2 用类型化的 WIT 接口（如 wasi:filesystem/preopens@0.2.0、wasi:io/streams@0.2.0 和 wasi:http/outgoing-handler@0.2.0）取代了 Preview 1 的扁平类 POSIX 接口<sup>[34](https://safeguard.sh/resources/blog/webassembly-wasi-security-model-2025)</sup>。运行时支持随之而来：wasmtime 25 同时支持用于旧版 Preview 1 模块的 p1 适配器和原生 p2 组件，WasmEdge 0.14 和 wasmCloud 1.1 在 2024–2025 年提供了 Preview 2 支持<sup>[34](https://safeguard.sh/resources/blog/webassembly-wasi-security-model-2025)</sup>。WASI Virt 通过虚拟化组件的 WASI 依赖来扩展该模型：特定文件路径可以作为编译后操作挂载并虚拟化到组件中，同时禁止最终组件访问宿主文件系统，组合后的组件不再有文件系统导入，因此可以在不提供文件系统 API 的主机上运行<sup>[35](https://github.com/bytecodealliance/wasi-virt)</sup>。WebAssembly 的基线模型为模块提供一个线性内存，模块无法在其外部寻址，没有系统调用，也没有宿主显式导入之外的能力；WASI 使其成为能力模型，但代码必须编译到该模型，而宿主绑定正是错误所在之处<sup>[8](https://www.endorlabs.com/learn/sandboxes-a-primer-on-containing-things-that-dont-want-to-be-contained)</sup>。

**AI 智能体遏制。** Microsoft 的 mxc 旨在跨 Windows、Linux 和 macOS 执行不可信代码（如模型输出、插件和工具），提供沙箱化代码执行，并附带多个遏制后端：ProcessContainer、Windows Sandbox、LXC、Bubblewrap、Seatbelt、MicroVM（NanVix）、Hyperlight、IsolationSession 和 WSLC<sup>[12](https://github.com/microsoft/mxc?tab=readme-ov-file)</sup>；在 [Windows 11](https://www.edgepedia.org/zh/windows-11) 24H2+ 上默认后端是 processcontainer，Linux 默认为 bubblewrap，macOS 默认为 Seatbelt<sup>[12](https://github.com/microsoft/mxc?tab=readme-ov-file)</sup>。2026 年 10 月，Microsoft 宣布了执行容器（Execution Containers），有四个后端：用于 Windows 11、macOS 和 Linux 的进程容器，使用 AppContainer、Seatbelt 或 Bubblewrap；仅用于 Windows 11 的会话容器；仅用于 Windows 11 的 WSL 容器；以及用于 Windows 11 和 Linux 的实验性 MicroVM<sup>[36](https://blogs.windows.com/windowsdeveloper/2026/10/07/microsoft-execution-containers-policy-driven-containment-for-ai-agents/)</sup>。AWS 的 Strands Box 使用两层：通过操作系统级隔离（如 macOS Seatbelt）进行遏制，定义智能体在主机和网络上可以触及的范围，策略管理该边界内的操作<sup>[37](https://aws.amazon.com/blogs/opensource/introducing-strands-box-ai-agent-sandboxes-powered-by-dogwood/)</sup>。Docker 认为加固 V8 很困难，且 V8 引擎中的安全漏洞比成熟 hypervisor 中出现得更频繁，这推动了面向智能体工作负载的基于微虚拟机的沙箱<sup>[38](https://www.docker.com/blog/why-microvms-the-architecture-behind-docker-sandboxes/)</sup>。

**编译器级隔离。** LFI 独立于现有编译器工具链实现，包含一个小型静态验证器以减少 TCB 大小，针对基本 Spectre 攻击进行了加固，并支持异常和 SIMD<sup>[32](https://dl.acm.org/doi/10.1145/3620665.3640408)</sup>。随着云计算和无服务器计算的发展，对 SFI 系统的需求增加，这些计算需要以低延迟和低上下文切换时间运行不可信代码<sup>[32](https://dl.acm.org/doi/10.1145/3620665.3640408)</sup>。面对这些进展，从 Spectre 和 Meltdown 开始的瞬态执行攻击可以破坏页表、Intel PKU、Intel MPX、ARM PAC 和 ARM TrustZone 等机制的机密性和完整性保证<sup>[30](https://arxiv.org/html/2410.08434v1)</sup>。

## 局限与争议

若干问题仍有争议。关于先沙箱后执行用于恶意软件检测的可靠性，1,471 个样本的 SoK 研究发现通用沙箱的覆盖范围有限，偏向突出的恶意软件家族，尽管其配置指南将可观察痕迹改善至少 1.6 倍<sup>[26](https://arxiv.org/pdf/2403.16304)</sup>。关于反规避，ACM 综述得出结论，响应式防御和透明分析系统很容易被零日指纹识别和拖延挫败，并建议采用强调路径探索技术的通用防御<sup>[10](https://dl.acm.org/doi/10.1145/3365001)</sup>，而 Check Point 2025 年的分析认为，一旦攻击者采用人类交互反规避检查，猫鼠动态就可以反过来对付攻击者<sup>[29](https://research.checkpoint.com/2025/the-cat-and-mouse-game-exploiting-statistical-weaknesses-in-human-interaction-anti-evasions/)</sup>。关于产品设计，AI 沙箱测量研究发现，没有产品同时提供微虚拟机（最强隔离）和持续公共模糊测试器（最强缺陷发现）；它还指出 microsandbox/libkrun 没有 CVE、没有模糊测试器、也没有学术研究，这意味着其真实风险是未被测量而非很低<sup>[33](https://fellows.tech/ai-sandboxes-paper)</sup>。最后，SandboxGym 的产品检查表明隔离边界本身往往不是故障点：不安全的挂载、不一致的策略执行、路径处理错误、特权辅助程序、共享状态和管理 API 一再削弱或破坏它<sup>[31](https://sandboxgym.io/)</sup>。

## References

1. [A systematic analysis of the science of sandboxing (Maass et al., CMU)](https://www.cs.cmu.edu/~jssunshi/assets/pdf/maass2016systematic.pdf)
2. [Survey of Real-World Process Sandboxing (Fruct, vol. 35)](https://www.fruct.org/files/publications/volume-35/fruct35/Niem.pdf)
3. [landlock(7), Linux manual page](https://man7.org/linux/man-pages/man7/Landlock.7.html)
4. [What Is Sandboxing in Cybersecurity? (Rapid7)](https://www.rapid7.com/fundamentals/sandboxing/)
5. [Understanding Sandboxes: gVisor, Hypervisors, and Firecracker (salmanq.com)](https://www.salmanq.com/blog/understanding-sandboxes/)
6. [Principles and Implementation Techniques of Software-Based Fault Isolation](https://cseweb.ucsd.edu/~dstefan/cse227-spring22/papers/tan:sfi.pdf)
7. [Browser Isolation Vs Sandboxing: Complete Comparison & Alternatives (2026) (send.win)](https://blog.send.win/browser-isolation-vs-sandboxing-complete-comparison-alternatives-2026/)
8. [Sandboxes: A Primer on Containing Things That Don't Want to Be Contained (Endor Labs)](https://www.endorlabs.com/learn/sandboxes-a-primer-on-containing-things-that-dont-want-to-be-contained)
9. [Sandboxing / Containment (longtermwiki)](https://longtermwiki.vercel.app/wiki/E513)
10. [Malware Dynamic Analysis Evasion Techniques: A Survey (ACM Computing Surveys)](https://dl.acm.org/doi/10.1145/3365001)
11. [WASI Preview 2 and the Component Model: What Capability-Based Isolation Actually Prevents (systemshardening.com)](https://www.systemshardening.com/articles/wasm/wasi-preview2-capability-isolation/)
12. [microsoft/mxc (GitHub)](https://github.com/microsoft/mxc?tab=readme-ov-file)
13. [docs/linux_sandboxing.md, Chromium source](https://chromium.googlesource.com/chromium/src.git/+show/63cff3378eccfcba582f16fdf1f3db5d9108b1c4/docs/linux_sandboxing.md)
14. [Landlock LSM: kernel documentation](https://docs.kernel.org/security/landlock.html)
15. [Firecracker vs Cloud Hypervisor vs Kata Containers (opencomputer.dev)](https://opencomputer.dev/guides/firecracker-vs-cloud-hypervisor-vs-kata/)
16. [Firecracker vs gVisor: Sandbox Isolation for Untrusted and Agent-Generated Code (Fly.io)](https://fly.io/learn/firecracker-vs-gvisor/)
17. [Implementing an AppContainer (Microsoft Learn)](https://learn.microsoft.com/en-us/windows/win32/secauthz/implementing-an-appcontainer)
18. [Windows Sandbox overview (Microsoft Learn)](https://learn.microsoft.com/en-us/windows/security/application-security/application-isolation/windows-sandbox/)
19. [Protecting user data with App Sandbox (Apple Developer)](https://developer.apple.com/documentation/security/protecting-user-data-with-app-sandbox.md)
20. [Chromium Sandbox FAQ](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/design/sandbox_faq.md)
21. [Sandbox Runtime Comparison (agentpatterns.ai)](https://www.agentpatterns.ai/security/sandbox-runtime-comparison/)
22. [Container Runtime Security Comparison: runc vs gVisor vs Kata vs Firecracker (safeguard.sh)](https://safeguard.sh/resources/blog/container-runtime-comparison-security)
23. [Understanding Sandboxes (Vercel)](https://vercel.com/docs/sandbox/concepts)
24. [AMTSO Sandbox Evaluation Framework v1.1](https://www.amtso.org/wp-content/uploads/2026/06/AMTSO_Sandbox_Evaluation_Framework_v1.1_ForReview.pdf)
25. [Defeating Sandbox Evasion (Virus Bulletin 2016)](https://www.virusbulletin.com/uploads/pdf/magazine/2016/VB2016-Chailytko-Skuratovich.pdf)
26. [SoK: An Essential Guide For Using Malware Sandboxes In Security Applications](https://arxiv.org/pdf/2403.16304)
27. [Navigating the Vast Ocean of Sandbox Evasions (Unit 42)](https://unit42.paloaltonetworks.com/sandbox-evasion-memory-detection/)
28. [What is a Malware Sandbox? (ANY.RUN)](https://any.run/cybersecurity-blog/what-is-malware-sandbox/)
29. [The Cat and Mouse Game: Exploiting Statistical Weaknesses in Human Interaction Anti-Evasions (Check Point Research, 2025)](https://research.checkpoint.com/2025/the-cat-and-mouse-game-exploiting-statistical-weaknesses-in-human-interaction-anti-evasions/)
30. [SoK: Software Compartmentalization](https://arxiv.org/html/2410.08434v1)
31. [SandboxGym: How Well Your Sandboxes and Virtual Machines Really Work](https://sandboxgym.io/)
32. [Lightweight Fault Isolation: Practical, Efficient, and Secure Software Sandboxing (ASPLOS 2024)](https://dl.acm.org/doi/10.1145/3620665.3640408)
33. [Measurement study of AI-code sandboxes (fellows.tech)](https://fellows.tech/ai-sandboxes-paper)
34. [WebAssembly WASI Security Model in 2025 (safeguard.sh)](https://safeguard.sh/resources/blog/webassembly-wasi-security-model-2025)
35. [bytecodealliance/WASI-Virt (GitHub)](https://github.com/bytecodealliance/wasi-virt)
36. [Microsoft Execution Containers: Policy-driven containment for AI agents (Windows Developer Blog)](https://blogs.windows.com/windowsdeveloper/2026/10/07/microsoft-execution-containers-policy-driven-containment-for-ai-agents/)
37. [Introducing Strands Box: AI agent sandboxes powered by Dogwood (AWS Blog)](https://aws.amazon.com/blogs/opensource/introducing-strands-box-ai-agent-sandboxes-powered-by-dogwood/)
38. [Why MicroVMs: The Architecture Behind Docker Sandboxes (Docker Blog)](https://www.docker.com/blog/why-microvms-the-architecture-behind-docker-sandboxes/)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/sandbox-computer-security

English original: https://www.edgepedia.org/sandbox-computer-security
