# 第十二章：Harness 安全体系

智能体系统通过工具调用与外部系统交互。这一能力强大却危险——恶意的工具调用可能导致数据泄露、系统破坏、权限提升。与通用AI安全研究不同， **Harness层安全** 聚焦于工程实践：如何在运行时检测和阻止危险操作。

本章与《AI安全指南》互补。AI安全研究关注模型对齐和提示注入的防御；Harness安全专注操作系统级别的防护——路径校验、权限控制、沙箱隔离、危险命令检测。这是智能体系统从实验室走向生产的必经之路。

## 核心主题

1. **威胁模型**：Harness特有的安全威胁景象。区别于通用AI系统。
2. **权限与沙箱**：多层隔离策略。从进程级到虚拟机级。
3. **工具调用护栏**：危险操作的自动检测与阻止。
4. **路径校验**：最复杂也最关键的防护。URL编码、Unicode、符号链接等多种攻击向量。
5. **实战集成**：将所有防护机制整合到MiniHarness中。

## 相关工程实现

* **Claude Code**：default、acceptEdits、plan、auto、dontAsk、bypassPermissions 权限模式，allow/deny 工具规则、组织级策略，以及危险命令防护。
* **OpenClaw**：三级权限系统(deny/allowlist/full)、SOUL.md 行为约束、Docker 容器沙箱。

## 本章阅读路线

* 快速上手：阅读12.3和12.4，理解核心防护机制。
* 深度理解：从12.1开始，完整掌握威胁景象。
* 动手实现：直接跳到12.5，在MiniHarness中集成安全层。

## 本章结构

* 12.1：Harness 层安全威胁模型
* 12.2：权限系统与沙箱设计
* 12.3：工具调用护栏
* 12.4：路径校验与注入防护
* 12.5：实战：MiniHarness 安全层集成

***

**下一章将进入评估与质量保障，确保安全防护的有效性。**


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yeasy.gitbook.io/harness_engineering_guide/di-si-bu-fen-an-quan-ping-gu-yu-yan-jin/12_security.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
