> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/zh/xin/studio/security.md).

# Unsloth 中的安全性

Unsloth 在 Unsloth Studio 和 Unsloth Desktop 中采用了一系列安全措施，以帮助保护/保障用户。下面概述了关键保障措施。

### 1. 操作系统沙盒

Unsloth 使用 **bubblewrap** ，在 Linux 上， **Seatbelt** 在 macOS 上，以及 **MXC** 在 Windows 上。请参见 [Unsloth 中的沙盒机制](https://unsloth.ai/docs/zh/xin/studio/unsloth-zhong-de-sha-he-ji-zhi.md) 了解更多细节

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fopx5w9JIwYNWGi2VWD0S%2Fimage.png?alt=media&amp;token=8091a99d-fd15-47bf-89c3-45a5c558c660" alt=""><figcaption></figcaption></figure>

### 2. Hugging Face 仓库安全扫描器

所有 Hugging Face 仓库都会被扫描。反向 shell、云元数据访问和凭据窃取会被直接阻止。例如， `deepseek-ai/deepseek-ocr` 和 `moonshotai/Kimi-VL-A3B-Instruct` 这两个在运行前都需要权限 `trust_remote_code = True`:

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FV42Li7ASTlRoaVBuCi8r%2Fsecurity-01-deepseek-remote-code.png?alt=media" alt="DeepSeek-OCR custom-code approval dialog with a high-severity exec/eval scanner flag"><figcaption><p>上游的 DeepSeek-OCR 示例会请求权限，并在模型代码中显示一个 exec/eval 发现项。</p></figcaption></figure>

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FcjbNPE46ghs02GlCeawS%2Fsecurity-02-kimi-remote-code.png?alt=media" alt="Kimi-VL-A3B-Instruct custom-code approval dialog with a scanner flag"><figcaption><p>Kimi-VL-A3B-Instruct 示例会请求权限，并显示扫描器的高级混淆模式标记。</p></figcaption></figure>

我们移除了 `eval` 调用和其他有问题的代码段，并提供 `unsloth/DeepSeek-OCR` 和 `unsloth/DeepSeek-OCR-2`，例如：

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2Fb01XsCClbvFsVel1FcOL%2Fsecurity-03-unsloth-deepseek.png?alt=media" alt="Unsloth DeepSeek-OCR custom-code approval dialog with no worrying files flagged"><figcaption><p>即使扫描器没有标记出令人担忧的文件，改造后的 Unsloth DeepSeek-OCR 仓库仍然会请求自定义代码权限。</p></figcaption></figure>

### 3. 恶意软件扫描器

Unsloth 会检查某个模型在 Hugging Face 上的安全扫描状态。例如， `mcpotato/42-eicar-street` 会被阻止加载，并显示原因：

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FjqiNuBgoc5OqUFfcfY0W%2Fsecurity-04-malware-block.png?alt=media" alt="Unsafe-files dialog blocking mcpotato/42-eicar-street and listing flagged files"><figcaption><p>恶意软件警告会阻止该模型，并解释被标记的文件从未下载过。</p></figcaption></figure>

### 4. 登录失败限制

Unsloth 会限制登录失败尝试次数。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F3uHp3NutN8szExxV7lZr%2Fsecurity-05-login-limit.png?alt=media" alt="Unsloth sign-in screen showing a cooldown after too many failed login attempts"><figcaption><p>登录失败限速会显示重试倒计时；此示例显示还剩 53 秒。</p></figcaption></figure>

### 5. HTTPS 远程访问

`unsloth studio --secure` 通过 Cloudflared 隧道提供仅 HTTPS 端点。

“ [远程访问指南](https://unsloth.ai/docs/zh/ji-chu-zhi-shi/ru-he-zai-ren-he-di-fang-ti-gong-ben-di-llm-fu-wu-shi-yong-cloudflare-he-unsloth-shi-xian-an-quan-yu.md) 将这与在已运行且绑定通配符地址的服务器上启动隧道区分开来：后者可能会让原始网络端口保持可访问。

该指南还警告，服务器端工具会以你的用户身份运行，并且拥有网络访问权限的 API 密钥持有者可以在机器上执行代码。它建议 `--disable-tools` 在暴露 Unsloth 时这样做。请妥善保管访问凭据，并在启用远程访问之前查看完整指南。HTTPS 会加密连接；但它并不会让特权工具访问变得无害。

### 6. 密码

密码使用带盐的 PBKDF2-HMAC-SHA256。首次运行时的管理员密码是随机生成的，且该账户必须在首次登录时修改密码。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FC5ncbwkNXCXRGsrKKtTm%2Fsecurity-06-password-login.png?alt=media" alt="Unsloth password sign-in screen"><figcaption><p>安全实践文档中包含的密码登录界面。</p></figcaption></figure>

### 7. 加密的 API 密钥

保存的提供方凭据会被加密。在浏览器中输入的 API 密钥会使用每次安装生成的 RSA 密钥进行加密。

### 8. 多账户隔离

受管理账户只能访问自己的文件夹，无法访问所有者的 Hugging Face 令牌，使用模型前需要所有者授权，并且被禁止运行仓库代码。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FjxPTtS99YYycwpYCK4ny%2Fsecurity-07-managed-accounts.png?alt=media" alt="Accounts settings showing an installation owner and separate private accounts"><figcaption><p>账户设置区分了安装所有者和受管理的私人账户。</p></figcaption></figure>

### 9. 沙盒化工件

HTML 和 MCP 工件会在具有各自内容安全策略（CSP）的沙盒框架中渲染。

### 10. PyTorch 模型加载

PyTorch 2.6+ 的最低要求意味着 `.bin` 权重会使用 `weights_only=True`.

### 11. 审批模式

Unsloth 提供 `ask`, `auto`，以及 `full` 审批模式。 `auto` 该模式会将网络和文件系统导入标记为需要审批，文件路径也需要审批。危险的 shell 命令会被阻止。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F3QjAxThLgzRROgxtrFki%2Fsecurity-08-tool-approval.png?alt=media" alt="File-edit tool call waiting for approval with Allow, Always allow, and Deny controls"><figcaption><p>文件编辑工具调用会等待审批，并提供允许、始终允许和拒绝控制。</p></figcaption></figure>

### 12. npm 最低发布时长

npm 设置 `min-release-age=7` 会拒绝最近七天内发布的软件包。

### 13. 安装脚本允许列表

一个 `allowScripts` 列表指定了唯一允许运行安装脚本的软件包。CI 会对任何未经审查的内容失败。

### 14. Codex Security 和迭代审查

在整个开发过程中都会使用 Codex Security 和迭代式 Codex 审查，以发现安全问题和 bug：

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FgMgORmGSKJG6j1xUAxdO%2Fsecurity-09-codex-review.png?alt=media" alt="Codex Security review on a merged GitHub pull request"><figcaption><p>附加在拉取请求上的 Codex Security 审查示例。显示的结果适用于该被审查的提交。</p></figcaption></figure>

### 15. 锁定文件与可复现的 npm 安装

锁定文件和 `npm ci` 被用于所有地方，并且安装程序会将用户升级到 npm 11 或更新版本。

### 16. CI 加固

`lockfile_supply_chain_audit.py` 在任何 `npm ci` 或 `cargo fetch`.

`之前，拒绝显示出 Shai-Hulud 风格注入迹象的锁定文件` 和 `scan_packages.py` 会扫描 npm tar 包和 PyPI 包，包括安装脚本中的凭据读取。

代码检查器会通过基线防止不安全的加载器和动态执行。编译代码路径也有一个动态执行允许列表。

### 17. 依赖审计

Unsloth 使用 `pip-audit`, `npm audit` 包括签名检查，以及 `cargo audit`.

### 18. 代码分析与依赖更新冷却期

Unsloth 使用 **CodeQL** 和 **Semgrep**，以及 **Dependabot** ，并设置三到七天的冷却期。

### 19. 固定的 GitHub Actions

GitHub Actions 固定到提交 SHA，没有使用可变标签。

### 20. llama.cpp 发布验证

预编译的 llama.cpp 二进制文件会与发布版 SHA-256 摘要进行校验。另一个独立工作流会审计 Windows 上的 llama.cpp 签名。

### 21. VirusTotal 发布扫描

所有 Desktop 版本都会使用 VirusTotal 扫描。

<figure><img src="https://2657992854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FbAF1S0JxrvtmGrArUIwf%2Fsecurity-10-virustotal.png?alt=media" alt="VirusTotal scan result for Unsloth Studio Desktop showing zero detections out of 70 vendors"><figcaption><p>所提供的 Desktop 版本示例显示，在扫描时 70 个供应商中检测结果为 0。</p></figcaption></figure>

### 使用这些控制措施

安全检查可以降低风险；它们并不能证明某个模型、依赖项、代码片段或发布工件在任何情况下都是安全的。请仔细审查代码执行请求，保持 Unsloth 及其依赖项为最新，并使用满足需求的最小权限审批模式。截图展示的是特定示例；扫描结果仅适用于所示文件或提交。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://unsloth.ai/docs/zh/xin/studio/security.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
