Skip to content

[Security] Defend Deep Research against prompt injection from untrusted sources #16

Open

Description

@helsome

Background

Deep Research 会持续读取网页、搜索结果、文档、附件及第三方工具返回内容。这些内容本质上都是 untrusted input。一旦来源中夹带“忽略之前指令”“读取本地文件”“把 API Key 发到某 URL”“调用某工具执行命令”等指令,如果 Research Agent 把来源内容当成可执行指令,可能导致任务劫持、敏感信息泄漏或工具权限升级。

需要在现有 Deep Research / Agent production path 上建立明确的 trust boundary,而不是只依赖 system prompt 中一句“不要听网页指令”。

Requirements

  • 明确区分并在运行时保持以下信任层级:
    • system / developer policy
    • user task
    • tool policy / capability policy
    • retrieved web/document/search content
  • 所有 retrieval/search/document 内容默认视为 data, not instructions。
  • 对高风险工具建立 capability/allowlist 约束,来源内容本身不得触发权限升级。
  • 禁止由来源内容诱导执行以下行为:
    • 读取或回显 API Key、token、cookie、credential;
    • 访问与任务无关的本地敏感文件(如 SSH key、shell history 等);
    • 任意 shell/process 执行;
    • 向来源指定的第三方 endpoint 外传 prompt、credential、文件或内部上下文;
    • 修改 system/tool policy。
  • 对疑似 prompt injection / tool injection 事件提供结构化记录,例如 injection_detected、policy_denied、source id、tool name、reason;不得把敏感 payload 原样写入 telemetry。
  • 与 [Eval] Integrate Langfuse tracing and evaluation for Agent / Deep Research runs #14 Langfuse trace 兼容:可以观察拦截事件,但不能因此泄露完整敏感内容。
  • 防御机制应位于统一的 Agent / tool boundary,避免每个工具各写一套字符串过滤。

Adversarial Cases

至少覆盖:

  • Ignore previous instructions ...
  • 假冒 <system> / developer message 的网页内容;
  • 要求读取 .env / ~/.ssh/* / credential store;
  • 要求把 secret 发送到指定 URL;
  • search result / document 中嵌入恶意 tool arguments;
  • 编码、Markdown、HTML 或间接表述的注入;
  • 多跳注入:A 来源要求去读取 B 来源,再由 B 来源诱导调用工具。

Acceptance Criteria

  • Retrieval/source 内容在 Agent runtime 中有明确 untrusted 边界,不能覆盖 system/tool policy。
  • 高风险工具调用经过统一 capability/policy gate。
  • 至少建立一组可持续回归的 prompt-injection adversarial cases。
  • 注入拦截事件可被诊断和评测,但 telemetry/log 中不泄露敏感值。
  • 使用 canary secret 验证:恶意来源尝试获取或外传该 secret 时,最终回答、tool args、网络请求、日志和 trace 中均不存在 canary。
  • 必须至少执行 1 次真实模型 + 实际 Deep Research production path 的 adversarial E2E;只跑 mock / regex unit test 不算完成。
  • PR 中附攻击样例、实际 Agent 行为、被拒绝的 tool call / policy decision 以及测试结果。

Non-goals

  • 不接受仅靠关键词黑名单或正则过滤作为完整方案。
  • 不要求首版实现复杂的安全分类模型;优先把 trust boundary、capability gate 和可回归攻击测试建立起来。

Activity

  1. haomint commented on Sep 11, 2026

    @haomint

    我想认领这个 issue,麻烦分配给我(Zhangchenhao-111),谢谢!

  2. added
    claimed
    on Sep 11, 2026
  3. github-actions commented on Sep 11, 2026

    @github-actions

    @lhy-dcf 已认领该 Issue,并已自动设为 Assignee。提交 PR 时请在描述中写 Closes #16。

  4. Lym308758 commented on Oct 16, 2026

    @Lym308758
    Contributor

    /claim

  5. github-actions commented on Oct 16, 2026

    @github-actions

    @Lym308758 这个 Issue 已经由 @lhy-dcf 认领。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

claimed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions