mxc README

The project's README from github.com/microsoft/mxc. As one markdown file: README.md.

Microsoft eXecution Container (MXC)

MXC is a sandboxed code execution system for running untrusted code (model output, plugins, and tools) on Windows, Linux, and macOS. It provides multiple containment backends, from OS-native process sandboxes to full VMs, behind a unified containment model and typed SDKs.

Features

What is MXC?

MXC is an SDK dependency that builds into your app.

flowchart LR
    App["Your application<br/>Launch API"] --> SDK["MXC SDK<br/>Rust / .NET / Node<br/>(in process)"]
    SDK --> Backend["Selected backend<br/>(in process)"]
    Backend --> Container["Isolated workload<br/>ProcessContainer / WSLC / Bubblewrap / ..."]

Your application specifies:

MXC validates the request, selects the backend, and launches the workload in the resulting container.

What container types are supported?

MXC runs workloads through platform-appropriate container backends on Windows, Linux, and macOS.

Runtime platform Default backend Other backends Minimum host OS
Windows 11 x64 / ARM64 processcontainer windows_sandbox*, wslc, microvm*, hyperlight*, isolation_session Windows OS-version support
Linux x64 / ARM64 bubblewrap lxc, microvm, hyperlight -
macOS ARM64 / x64 seatbelt - -

* These backends are experimental.

How do I use MXC?

Install an SDK through your package manager. You do not need to clone this repository.

SDK Package
Rust https://crates.io/crates/mxc-sdk
.NET https://www.nuget.org/packages/Microsoft.Mxc.Sdk
Node https://www.npmjs.com/package/@microsoft/mxc-sdk

The Node and .NET packages include the native runtime assets. The Rust crate builds the MXC SDK, engine, and selected backends into the consuming application.

Non-SDK consumption: Platform-specific executor binaries, such as wxc-exec.exe, accept JSON container-creation requests defined by the stable schema. Use for testing or when the SDK cannot be embedded in your app.

Running a contained workload

For complete SDK samples, see the Rust, .NET, and Node samples.

Sample Node snippet

import { spawn, type ContainerRequest } from '@microsoft/mxc-sdk/v1';

const request: ContainerRequest = {
  command: 'node -e "console.log(\'hello from container\')"',
  network: { egress: { default: 'deny' } },
  timeoutMs: 30_000,
};

const child = await spawn(request);

See the runnable streaming standard-I/O sample and the SDK API reference.

My application won't run in the sandbox!

Your application will hit access issues when running in a sandbox, until you've had time to tune your containment rules. We're here to help.

Debug console mode

Native executors normally reserve standard input, output, and error for the workload. Use --debug for MXC diagnostic output:

wxc-exec.exe --debug config.json

See MXC diagnostics for the complete developer reference.

Audit mode

Warning: --audit turns off all sandbox security for the workload being analyzed. Never use it to run untrusted code.

Audit mode helps a policy author find access-denied failures and reconstruct a ProcessContainer policy that grants the files and capabilities a trusted tool actually needs. On supported Windows releases, run:

wxc-exec.exe --audit policy.json

MXC records the observed accesses and produces policy-authoring artifacts. See logging access denied for safe deny-and-record diagnostics, audit outputs, and supported workflows.

Telemetry

Official Microsoft builds can send optional diagnostic telemetry to Microsoft. Telemetry is off unless the individual run opts in, the Windows user has explicitly consented, administrative policy permits collection, and your application enables the telemetry option in a contained workload request. An administrator can block telemetry but cannot grant consent for the user.

Local open-source builds are not configured to route telemetry to Microsoft, and telemetry is a no-op on non-Windows platforms. See telemetry policy and consent for controls and privacy details.

Building from source

Build from source when developing MXC, changing the native runtime, or using the standalone executor binaries instead of a packaged SDK. Repository builds produce the platform-native runtime and executors and stage the native assets used by the Node SDK.

Build prerequisites are:

Build

Windows

build.bat --all             # Release build for current architecture

Linux

./build.sh --all            # Release build

macOS

./build-mac.sh --all        # Release build for native architecture

Documentation

Consumer documentation

Document Repository location Purpose
Terminology docs/glossary.md Plain-English definitions of consumer terms
SDK samples samples/ Runnable Rust, .NET, and Node scenarios
SDK API reference docs/api-reference/ Supported V1 operations and types
Container lifecycle docs/container-lifecycle.md Persistent container lifecycle overview
Logging access denied docs/logging-access-denied.md Diagnose blocked accesses and author policy
Telemetry docs/telemetry.md Consent and administrative controls
Backend guides docs/backends/ Platform and backend prerequisites and behavior

Repository contributors should start with the MXC development documentation.

Contributing

See CONTRIBUTING.md for contribution guidelines.

License

See LICENSE.md for details.

mxc (microsoft/mxc)

Searching Database…

2.9K ·GitHub
这是什么?MXC(Microsoft eXecution Container)是一个沙箱化代码执行系统,用于在 Windows、Linux 和 macOS 上运行不受信任的代码——模型输出、插件和工具,其隔离后端涵盖从操作系统原生进程沙箱到完整虚拟机。
它是独立应用,还是需要嵌入到我代码里的 SDK?它是一个会构建进你应用程序的 SDK 依赖。你指定容器类型、隔离规则和工作负载命令,MXC 会校验请求、选择后端并启动工作负载。
如何把 MXC 加入项目?通过包管理器安装 SDK——Rust crate、.NET 包或 Node 包——无需克隆仓库。此外还有平台专用的执行器二进制文件,如 wxc-exec.exe,用于非 SDK 的基于 JSON 的用法。
如果我的应用操作被沙箱拦截了会怎样?在你调好隔离规则之前,会一直遇到访问被拒绝的失败;MXC 提供用于诊断的调试控制台模式,以及一种关闭全部沙箱安全机制以帮助重建所需策略的审计模式,因此审计模式绝不能用于不受信任的代码。
每个操作系统上分别使用哪些容器后端?Windows 默认使用 ProcessContainer,另有 Windows Sandbox、WSLC、MicroVM、Hyperlight 和 IsolationSession 等实验性备选;Linux 默认使用 Bubblewrap,可选 LXC、MicroVM 和 Hyperlight;macOS 使用 Seatbelt。
MXC 会把我运行的内容作为遥测数据发送出去吗?Microsoft 官方构建版本可以发送可选的诊断遥测,但只有在运行时选择加入、用户同意、管理员策略允许且应用启用时才会开启;本地开源构建不会把遥测数据发送给 Microsoft,并且在非 Windows 平台上遥测是空操作。
MXC 提供哪些 SDK?MXC 提供 Rust、.NET 和 Node SDK,配有带版本号的 API,支持一次性执行和状态感知执行;Node 和 .NET 包内置了原生运行时资源。
容器可以持久保存状态,还是只能运行一次?MXC 支持状态感知的生命周期管理,让你可以创建、启动、执行、停止和回收持久化容器,而不仅限于一次性运行。
我可以为沙箱化的工作负载设置哪些策略?策略涵盖文件系统访问(只读、读写、拒绝路径)、网络访问(代理、出站控制、主机过滤)以及 UI 访问(剪贴板、显示器、GUI 控件)。
为什么要用 MXC,而不是直接运行不受信任的代码?MXC 专为隔离 LLM/模型输出、插件和工具等不受信任的代码而构建,因此行为异常或恶意的工作负载无法访问未被明确授权的文件、网络或 UI。
Creator
microsoft
Size
36.9 MB
Stars
2.9K
Age
8mo
Commits · 90 Days