MukundaKatta/awesome-prompt-injection-defense

GitHub: MukundaKatta/awesome-prompt-injection-defense

一个精选资源列表,汇集了用于防御大语言模型提示词注入攻击的检测工具、护栏方案、评估数据集和研究论文。

Stars: 1 | Forks: 3

# Awesome Prompt Injection Defense [![Awesome](https://awesome.re/badge.svg)](https://awesome.re) Prompt injection 是生产级 LLM 系统面临的首要安全风险。相关的防御生态目前散落在学术预印本、供应商博客、npm/PyPI 工具以及临时性的系统提示词中。本列表旨在将其整合到一个地方。 ## 目录 - [检测库](#detection-libraries) - [针对 RAG 的护栏](#rag-specific-guardrails) - [评估数据集](#evaluation-datasets) - [在线演示](#live-demos) - [用于 CI 的 GitHub Actions](#github-actions-for-ci) - [研究论文和预印本](#research-papers-and-preprints) - [相关的可靠性工具](#adjacent-reliability-tooling) - [背景阅读](#background-reading) - [贡献指南](#contributing) ## 检测库 在将不受信任的文本传递给 LLM 之前调用的即插即用检查工具。 - [prompt-injection-shield](https://github.com/MukundaKatta/prompt-injection-shield) (npm) - 零依赖检测器,用于检测典型的指令重写、URL 数据泄露、系统提示词冒充和工具调用劫持模式。 - [prompt-injection-shield-py](https://pypi.org/project/prompt-injection-shield-py/) (PyPI) - 上述工具的 Python 移植版,具有相同的规则集。 - [Rebuff](https://github.com/protectai/rebuff) - 自我增强型 prompt injection 检测器,最初由 ProtectAI 开发。 - [LLM Guard](https://github.com/protectai/llm-guard) - 全面的 LLM 输入/输出安全套件,包含 prompt injection 扫描器。 - [PromptArmor](https://github.com/promptarmor/promptarmor) - 托管型 prompt injection 检测 API。 - [Lakera Guard](https://www.lakera.ai/lakera-guard) - 提供慷慨免费额度的商业护栏。 ## 针对 RAG 的护栏 RAG 中的 prompt injection 通常隐藏在检索到的文档中(间接注入)或被投毒的向量中。 - [vector-poison-score](https://github.com/MukundaKatta/vector-poison-score) (npm) / [vector-poison-score-py](https://pypi.org/project/vector-poison-score-py/) (PyPI) - 用于评估检索到的 chunk 是否被投毒的启发式评分。 - [rag-guardrails-action](https://github.com/MukundaKatta/rag-guardrails-action) - 在 CI 中对 fixtures 目录运行上述两个检测器的 GitHub Action。 - [LangChain Guardrails](https://python.langchain.com/docs/guardrails/) - 为基于 LangChain 的 RAG 提供内置的信任链模式。 - [LlamaIndex SafetyToolkit](https://docs.llamaindex.ai/en/stable/module_guides/evaluating/) - 可用作护栏的评估钩子。 ## 评估数据集 用于对检测器进行基准测试的标注语料库。 - [prompt-injection-eval](https://huggingface.co/datasets/mukunda1729/prompt-injection-eval) - 包含 9 个类别(典型指令重写、URL 数据泄露、系统提示词冒充、工具劫持、角色重写、编码、间接 RAG 投毒、边界情况和良性样本)的 74 行人工筛选数据。采用 MIT 许可证。 - [deepset/prompt-injections](https://huggingface.co/datasets/deepset/prompt-injections) - 规模更大的英语/德语 prompt injection 语料库。 - [JailbreakBench](https://github.com/JailbreakBench/jailbreakbench) - 针对“越狱”攻击的标准化基准测试(属于相关但更广泛的类别)。 - [Lakera Gandalf prompts](https://gandalf.lakera.ai/) - 从 Gandalf 游戏中收集的真实攻击提示词。 ## 在线演示 在浏览器中体验这些检测器。 - [Prompt Injection Shield Demo](https://huggingface.co/spaces/mukunda1729/prompt-injection-shield-demo) - 部署在 Hugging Face Spaces 上的 Streamlit 应用,粘贴一段文字即可查看基于严重程度的评分命中结果。 - [Lakera Gandalf](https://gandalf.lakera.ai/) - 用于设计绕过护栏提示词的互动游戏。 ## 用于 CI 的 GitHub Actions 接入 Pull Request 流程。 - [rag-guardrails-action](https://github.com/MukundaKatta/rag-guardrails-action) - 封装了 prompt-injection-shield + vector-poison-score 的复合 Action。遇到高严重级别时报错失败,中等级别时发出警告。 ## 研究论文和预印本 - [Small-Rule Guardrails for Retrieval-Augmented Generation](https://zenodo.org/records/20057632) - Mukunda Rao Katta。包含 Zenodo + Figshare DOI。是 prompt-injection-shield 的配套资料。 - [Greshake et al., Not what you've signed up for](https://arxiv.org/abs/2302.12173) - 关于间接 prompt injection 的基础性论文。 - [Perez and Ribeiro, Ignore Previous Prompt](https://arxiv.org/abs/2211.09527) - 关于 prompt injection 的早期研究。 - [Liu et al., Prompt Injection Attacks and Defenses in LLM-Integrated Applications](https://arxiv.org/abs/2310.12815) - 对攻击与防御空间的系统性梳理。 ## 相关的可靠性工具 并非严格意义上的 prompt injection 防护,但通常会与其组合使用。 - [APort](https://github.com/aporthq/aport-integrations) - APort 的开源集成工具包,APort 是专为 AI agent 设计的中立信任护栏。 - [agentvet](https://github.com/MukundaKatta/agentvet) - 在执行前验证 LLM 工具调用的参数。 - [agentguard](https://github.com/MukundaKatta/agentguard) - 专为使用工具的 agent 提供的网络出口防火墙。 - [agentcast](https://github.com/MukundaKatta/agentcast) - 针对结构化输出的验证与重试循环。 - [agentsnap](https://github.com/MukundaKatta/agentsnap) - 用于工具调用追踪的快照测试。 - [agentfit](https://github.com/MukundaKatta/agentfit) - 感知 token 的消息截断工具。 ## 背景阅读 - [OWASP LLM Top 10: LLM01 Prompt Injection](https://owasp.org/www-project-top-10-for-large-language-model-applications/) - 社区基线标准。 - [Simon Willison: Prompt injection](https://simonwillison.net/series/prompt-injection/) - 包含实践反馈的长期更新的博客系列。 - [NIST AI Risk Management Framework](https://www.nist.gov/itl/ai-risk-management-framework) - 政府视角下的 LLM 风险类别。 ## 许可证 [![CC0](https://licensebuttons.net/p/zero/1.0/88x31.png)](https://creativecommons.org/publicdomain/zero/1.0/) 在法律允许的范围内,维护者已放弃与本列表相关的所有版权及相关权利。
标签:DLL 劫持, IaC 扫描, Kubernetes, 大语言模型, 护栏, 提示词注入防御, 暗色界面, 逆向工具