十年匠心定制 · 商业建站与技术教学双线并行 咨询热线:400-886-1026 service@lmnt.cn
ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

如何用 Ruflo AIDefence 扫描用户输入中的提示注入威胁?

如何用 Ruflo AIDefence 扫描用户输入中的提示注入威胁? 如何用 Ruflo AIDefence 扫描用户输入中的提示注入威胁【免费下载链接】ruflo The original agent meta-harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, RAG integration, and native Claude Code / Codex / Hermes and many more Integrated项目地址: https://gitcode.com/GitHub_Trending/cl/ruflo如果你的 AI 应用会接收用户提交、API 载荷或 webhook 数据这些内容在重新进入 LLM 提示之前必须先过一道威胁扫描否则提示注入、越狱和角色劫持类文本可能直接改变模型行为。Ruflo 提供 AIDefenceAI Manipulation Defense System来完成这件事它内置 50 检测模式覆盖指令覆盖instruction override、越狱jailbreak、角色切换role switching、上下文操纵context manipulation和编码攻击encoding attack并对检测到的威胁给出严重级别、置信度和缓解建议。本文给出两条文档中的操作路径用claude-flow/cli的security defend子命令做命令行扫描以及在 Ruflo 插件环境中按插件契约使用aidefence_*MCP 工具做逐条检查。前提条件命令行路径只需要能运行npx claude-flow/cli自适应学习引擎claude-flow/aidefence是可选依赖Node.js 18、TypeScript 5.3未安装时 CLI 会回退到内置确定性扫描引擎并在输出中提示Using built-in defense engine (install claude-flow/aidefence for adaptive learning)。插件路径需要先安装ruflo-aidefence插件且宿主 CLI 锁定在claude-flow/cliv3.6 majorminor见 插件 README 的 Compatibility 一节。使用 CLI 扫描单条输入最短主路径是直接对一段用户输入运行 defend 命令npx claude-flow/cli security defend -i ignore previous instructions-i, --input传入待扫描文本。其他可用参数来自 security 命令实现-f, --file改为扫描一个文件例如批量提示文件npx claude-flow/cli security defend -f ./user-prompts.txt-Q, --quick快速扫描模式只做威胁布尔判断更快但信息更简略-l, --learn启用学习模式默认开启true配合claude-flow/aidefence学习引擎使用-s, --stats不执行扫描直接显示检测统计-o, --output输出格式text默认或json。文本模式下安全输入会输出No threats detected发现威胁时按严重级别[CRITICAL]、[HIGH]等逐条列出威胁类型、描述和置信度并对 critical 级威胁给出推荐缓解策略。claude-flow/aidefence的 README 给出了一个文档示例输出示例结果实际数值以你的输入为准️ AIDefence - AI Manipulation Defense System ─────────────────────────────────────────────────────── ⚠️ 2 threat(s) detected: [CRITICAL] instruction_override Attempt to override system instructions Confidence: 95.0% [HIGH] jailbreak Attempt to bypass restrictions Confidence: 85.0% Recommended Mitigations: instruction_override: block (95% effective) jailbreak: block (92% effective) Detection time: 0.042ms用 JSON 输出判断扫描结果在脚本或管道中使用时加-o json得到结构化结果便于程序化处理npx claude-flow/cli security defend -i test -o jsonJSON 输出包含四个字段字段定义见 CLI defend 子命令实现{ safe: true, threats: [], piiFound: false, detectionTimeMs: 0.0 }判定规则是safe为真且piiFound为假时命令以退出码 0 结束检测到威胁或 PII 时以退出码 1 结束——因此可以直接在 CI 或网关脚本中用退出码决定是否放行该输入。piiFound表示输入中还发现了邮箱、SSN、API key 等敏感数据这在提示注入之外同样需要处理例如脱敏或隔离后再入库。查看检测统计扫描若干输入后用--stats检查累计统计npx claude-flow/cli security defend --stats统计框展示 Detection Count、Avg Detection Time、Learned Patterns、Mitigation Strategies 和平均缓解有效率。启用学习模式并持续反馈检测结果后Learned Patterns 会增长这是学习引擎在工作的一种观察方式参见 AIDefence 库 README 的 Self-Learning 一节。可选分支在 Ruflo 插件流程中使用 MCP 工具如果你的目标是把扫描嵌入 Ruflo 代理工作流而不是命令行批处理先安装插件/plugin marketplace add ruvnet/ruflo /plugin install ruflo-aidefenceruflo插件暴露 6 个aidefence_*MCP 工具aidefence_scan、aidefence_analyze、aidefence_stats、aidefence_learn、aidefence_is_safe、aidefence_has_pii。safety-scan 技能给出的处理顺序是aidefence_is_safe做布尔安全检查aidefence_analyze获取威胁分类与置信度详情aidefence_scan做多层完整扫描aidefence_learn用已确认的威胁训练检测aidefence_stats查看检测率与误报指标。插件契约ADR-0001进一步定义了所有处理不可信内容的插件应遵循的 3-gate 模式顺序固定#门禁工具时机1Pre-storage PIIaidefence_has_pii任何 AgentDB /memory_store写入之前——先脱敏或隔离再持久化2Sanitizationaidefence_scan针对 cookie、token、高熵内容——放入不透明句柄而非内嵌原始值3Prompt-injectionaidefence_is_safe任何提取文本重新进入 LLM 提示之前——命中则隔离到findings.md此外插件提供/aidefence命令作为状态与统计仪表盘调用aidefence_stats展示总扫描数、威胁数、误报率和 PII 检测数见 命令定义。检测覆盖方面aidefence2.3.0起的第 3 道门禁aidefence_is_safe会标记三类输入修饰词窗口 0..4 的提示注入如ignore all previous instructions、disregard the system prompt、角色劫持you are now …、act as …和越狱标记DAN mode、developer mode等详见 插件 README 的 What the gates catch 表格。验证插件契约是否完整插件自带结构化的 smoke 测试作为契约验证手段在仓库根目录运行bash plugins/ruflo-aidefence/scripts/smoke.sh预期输出为10 passed, 0 failed。它检查插件元数据版本与关键词、6 个aidefence_*工具是否都在文档中引用、CLI v3.6 兼容性钉选、3-gate 模式文档、防御纵深段落loader-hijack 拒绝名单、文件模式 0600/0700、静态加密 opt-in以及技能 frontmatter 完整性。任一项失败时输出以非零退出码结束。适用条件与限制插件与宿主 CLI 版本钉选claude-flow/cliv3.6 majorminor不满足时不要混用插件 MCP 工具面。security defend的学习模式--learn默认开启只有在安装了claude-flow/aidefence时才生效未安装时使用内置确定性引擎无自适应学习。性能指标检测约 0.04ms、单线程吞吐 12,000 requests/秒来自 AIDefence 库 README 的基准表属于库的自报数据可作为量级参考不应写进你自己的 SLA 预期。插件的security-patternsAgentDB 命名空间由该插件独占不得与pattern、claude-memories、default等保留命名空间冲突。完成一次端到端验证对一条正常输入和一条含ignore previous instructions的输入分别运行security defend -o json确认前者safe: true、后者safe: false且threats中给出instruction_override类条目即可说明扫描链路在你的环境中工作正常。【免费下载链接】ruflo The original agent meta-harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, RAG integration, and native Claude Code / Codex / Hermes and many more Integrated项目地址: https://gitcode.com/GitHub_Trending/cl/ruflo创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表