360 Secure SkillHub
360 安全技能中心

Promptguard

PromptGuard是为处理外部不可信文本的AI代理设计的安全API,核心功能是扫描文本中的指令覆盖、HTML注释注入、零宽字符等多种提示注入攻击模式。用户通过POST请求提交1-100000字符的待扫描文本,API返回含0.0(安全)至1.0(高风险)的风险分数、检测到的攻击模式列表及输入长度的JSON结果,帮助防范注入风险。

mirni
mirni
热度 45.34
最近更新 2026-05-11 17:42:41
分类:安全依赖:代码执行 / 第三方 API

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add promptguard
Metadata
name
promptguard
description
Detect prompt injection attacks in text. Returns risk score and detected patterns.
version
0.1.1
metadata
{"openclaw":{"requires":{"bins":["python"]},"install":[{"kind":"uv","packages":["fastapi","uvicorn","pydantic"]}]}}

PromptGuard

A security API that scans text for common prompt injection patterns and returns a risk score. Designed for AI agents that process untrusted text input from external sources.

What It Detects

  • Instruction override attempts
  • HTML comment injection
  • Zero-width unicode characters
  • Delimiter-based attacks
  • Role switching tokens
  • System prompt extraction attempts

Installation

pip install fastapi uvicorn pydantic

Usage

Start the server:

uvicorn promptguard.app:app --port 8000

Then send a POST request:

curl -X POST http://localhost:8000/v1/scan \
  -H "Content-Type: application/json" \
  -d '{"text": "What is the weather in London today?"}'

Response (clean text):

{
  "risk_score": "0",
  "patterns_detected": [],
  "input_length": 38
}

Request

Field Type Required Description
text string yes Text to scan (1-100,000 chars)

Response

Field Type Description
risk_score decimal 0.0 (safe) to 1.0 (high risk)
patterns_detected list Names of detected patterns
input_length integer Length of input text