defending-llms-with-guardrails
Что он делает
Этот инструмент добавляет слои защиты в приложения, которые используют искусственный интеллект (ИИ). Он проверяет вопросы, которые задают ИИ, и ответы, которые он выдает, чтобы не допустить отправки или получения опасной или неуместной информации.
Когда использовать
- ✓Когда вы запускаете приложение с ИИ для реальных пользователей.
- ✓Чтобы блокировать попытки обмануть ИИ (джейлбрейки).
- ✓Чтобы ИИ не раскрывал конфиденциальные данные и не генерировал токсичный контент.
Ссылка на скилл
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/defending-llms-with-guardrails/SKILL.mdСкопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.
Как использовать
Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.
Готовое сообщение для вставки
Для Claude Code, Codex или Cursor: запустите в папке проекта, и скилл установится.
Скачайте SKILL.md и положите его в папку скиллов вашего агента.
Пример запроса к вашему ИИ
“Защити мое приложение с ИИ от вредоносных промптов.”
5 новых скиллов в неделю. 1 минута чтения.
Как это работает
Инструмент использует три системы (Llama Guard, NeMo Guardrails, LLM Guard), которые работают вместе. Одна проверяет содержимое, другая контролирует диалог, а третья сканирует входящие и исходящие данные на наличие определенных проблем.
Технический текст (оригинальный SKILL.md)
Оригинальный текст автора на английском, прямо с GitHub.
Defending LLMs with Guardrails
Defensive scope: This skill describes runtime defenses for production LLM applications. The example jailbreak/injection payloads exist only to validate that guardrails block them. Test against systems you own or are authorized to assess.
Overview
Large language model (LLM) applications are exposed to adversarial input (jailbreaks, prompt injection, toxic content) and can emit unsafe, biased, or sensitive output. A guardrail is a runtime control that inspects and constrains the data flowing into and out of an LLM. Three production-grade, open-source guardrail systems dominate the ecosystem and are complementary rather than mutually exclusive:
- Llama Guard 3 (Meta) — a Llama-3.1-8B model fine-tuned as a safety classifier. Given a prompt or a response, it emits
safeorunsafeplus the violated MLCommons hazard categories (S1–S14). It is the strongest semantic content-safety classifier of the three and supports prompt classification, response classification, and tool-call/code-interpreter classification across 8 languages. - NeMo Guardrails (NVIDIA) — a programmable dialogue-rail framework. You define
input,output,dialog,retrieval, andexecutionrails in aconfig.ymlplus Colang (.co) flows. It can call external models (including Llama Guard) as actions, enforce topical boundaries, and add fact-checking/jailbreak-detection rails. - LLM Guard (Protect AI) — a scanner pipeline with 15 input scanners and 20 output scanners (PromptInjection, Toxicity, Anonymize/Deanonymize, Secrets, BanTopics, Sensitive, Regex, etc.). It returns a sanitized string, a validity flag, and a risk score per scanner, making it ideal for a deterministic pre/post pipeline.
This skill maps to MITRE ATLAS AML.T0054 — LLM Jailbreak: the guardrail layer is the mitigation that detects and blocks jailbreak/injection attempts before they reach (or after they leave) the model.
When to Use
- When deploying an LLM/RAG/agent application to production and needing a runtime safety layer.
- When you must block jailbreaks and prompt injection (OWASP LLM01) before they reach the model.
- When you must moderate model output for toxicity, PII leakage, secrets, or off-topic responses.
- When validating that a guardrail configuration actually blocks a corpus of known-bad payloads.
- When layering defense-in-depth: a deterministic scanner (LLM Guard) plus a semantic classifier (Llama Guard) plus dialog rails (NeMo).
Prerequisites
- Python 3.9+ (LLM Guard requires 3.9+; Llama Guard via transformers requires
transformers>=4.43). - GPU recommended for Llama Guard 3 8B (CPU works for the 1B variant or quantized builds).
- A Hugging Face account with accepted Meta Llama license to download
meta-llama/Llama-Guard-3-8B.
# LLM Guard
python -m pip install llm-guard
# NeMo Guardrails
python -m pip install nemoguardrails
# Llama Guard via Hugging Face transformers
python -m pip install "transformers>=4.43" torch accelerate huggingface_hub
huggingface-cli login # accept the Meta Llama license first on the model page
Objectives
- Run Llama Guard 3 as a prompt and response safety classifier and parse its category output.
- Build an LLM Guard input/output scanner pipeline with PromptInjection, Toxicity, Secrets, and Anonymize scanners.
- Author a NeMo Guardrails
config.ymlplus Colang flows with input/output/jailbreak rails. - Wire Llama Guard into NeMo as a content-safety check.
- Validate the combined stack against a corpus of jailbreak and injection payloads.
MITRE ATT&CK Mapping
| ID | Tactic | Official Technique Name | Role in this skill |
|---|---|---|---|
| AML.T0054 | ATLAS: Defense Evasion / Impact | LLM Jailbreak | Guardrails detect and block the jailbreak attempt this technique describes |
| AML.T0051 | ATLAS: Initial Access | LLM Prompt Injection | Input rails / PromptInjection scanner block direct injection |
| AML.T0051.001 | ATLAS: Initial Access | LLM Prompt Injection: Indirect | Retrieval/input scanning blocks injection in retrieved content |
| AML.T0057 | ATLAS: Exfiltration | LLM Data Leakage | Output scanners (Sensitive, Secrets, Deanonymize) block leakage |
Workflow
Step 1: Classify prompts and responses with Llama Guard 3
…
Частые вопросы
Что такое «джейлбрейк» и «prompt injection»?
«Джейлбрейк» это попытка заставить ИИ игнорировать его правила безопасности. «Prompt injection» (внедрение промпта) это когда в промпт для ИИ вставляют вредоносные команды.
Какой вредоносный контент блокируется?
Инструмент блокирует токсичный контент, персональные данные (PII), секреты и ответы не по теме, а также попытки джейлбрейка и prompt injection.
Нужно ли использовать все три системы (Llama Guard, NeMo, LLM Guard)?
Они дополняют друг друга и обеспечивают разные виды защиты. Использование нескольких систем повышает общую безопасность вашего приложения.
Подробности
Оригинальное описание автора
Deploys Llama Guard 3 safety classification, NeMo Guardrails programmable dialogue rails, and LLM Guard input/output scanner pipelines as complementary runtime defenses that inspect and constrain LLM prompts and responses. Use when adding a production runtime safety layer to an LLM, RAG, or agent application to block jailbreaks, prompt injection (OWASP LLM01), toxic content, or sensitive-data leak
Популярность
- Звёзды на GitHub
- 35k
- Место в рейтинге
- #7775
- Лицензия
- Apache-2.0
- Обновлён
- 31.08.2026
Комментарии
- …
Другие скиллы из этого репозитория
abusing-dpapi-for-credential-access
35kДаёт ИИ-агенту готовые инструкции для конкретной задачи, чтобы он делал её лучше и быстрее.
abusing-shadow-credentials-for-privesc
35kУчит ИИ-агента писать ясные структурированные тексты.
achieving-cmmc-level-2-compliance
35kПомогает агенту подготовить среду к соответствию CMMC уровня 2.
acquiring-disk-image-with-dd-and-dcfldd
35kПомогает агенту создавать точные копии дисков для расследований.
Похожие скиллы
add-model-provider
394kПомогает агенту подключить нового провайдера ИИ-моделей к OpenClaw безопасными командами, хранить ключи API не в открытом виде и провести живой тест.
acp-router
394kПомогает агенту передать задачу инструменту для программирования, например Claude Code или Cursor, через OpenClaw, чтобы работа шла в этом инструменте.
browser-automation
394kУчит агента пошагово управлять веб-страницами: входить в аккаунты, работать с вкладками и восстанавливаться, если страница перестала отвечать.