prompt-injection-shield

提示注入防护 — 在不可信内容进上下文之前先扫描:中英双语文式库(忽略指令/角色劫持/越狱/DAN/索要系统提示)+ 启发式 + 沙箱规则,输出风险分·命中规则·处置建议。

Install

openclaw skills install @zhaoxinghua09-cell/prompt-injection-shield

凡自治之物 · LGD 治理学 · 创造术家族 | 评测协议:skill-quality-gate

English

Prompt Injection Shield

When to use

  1. Before data ingestion: when web pages, emails, tool returns, or uploaded documents are about to be fed to the AI, pre-scan before they enter context.
  2. Prevent instruction hijack: detect "ignore previous instructions", "you are a new AI", jailbreak or system-prompt-leak attempts.
  3. As a pre-stage to release-gate, combining desens-scan for double-checking so untrusted content cannot pollute context.

How to use

  • Run python scripts/prompt_injection_scan.py.
  • Pass the text to scan via --input and set the scan mode via --mode safe/aggressive.
  • Output includes risk score, matched rules, and disposition advice; read the returned JSON for downstream decisions.

Workflow

  1. Submit content to the bilingual pattern + heuristic scanner.
  2. The engine identifies jailbreak, DAN, role hijack, and system-prompt-leak traits and checks sandbox rules.
  3. Score the overall risk; record matched rules and decide whether to trigger desensitization or blocking.
  4. Produce a disposition (drop/isolate/sandbox), reusing desens-scan and release-gate logic.
  5. The front-end acts on the score: block, isolate, or run in a safe sandbox.

Evidence & safety

  • Evidence: TBD; Version: 1.0.1; Security: no independent scan (TBD).

中文

提示注入防护

何时用

  1. 数据接入前扫描:网页抓取、邮件、工具返回值或上传文档喂给 AI 前做安全预审。
  2. 防止指令劫持:检测「忽略之前指令」「你是新 AI」等触发词,防越狱或泄露系统提示。
  3. 作为 release-gate 前置环节,结合 desens-scan 双重校验,防不可信内容污染上下文。

用法

  • 运行 python scripts/prompt_injection_scan.py。
  • --input 传入待扫描文本,--mode safe/aggressive 指定模式。
  • 输出含风险分、命中规则详情与处置建议,可读返回 JSON 做后续决策。

流程

提交内容到双语文式库+启发式扫描入口 → 识别越狱/DAN/角色劫持/系统提示泄露特征并关联沙箱规则 → 计算风险分并记录命中规则 → 生成处置建议(丢弃/隔离/沙箱)→ 前端按分拦截/隔离/沙箱运行。

证据与安全声明

  • 证据:TBD;版本:1.0.1;安全:未做独立安全扫描(TBD)。