defending-llms-with-guardrails
Was er macht
Dieses Tool ergänzt Anwendungen, die künstliche Intelligenz (KI) nutzen, um zusätzliche Sicherheitsebenen. Es prüft die Fragen, die an die KI gestellt werden, und die Antworten, die sie gibt, damit keine gefährlichen oder unangemessenen Informationen gesendet oder empfangen werden.
Wann du ihn nutzt
- ✓Wenn du eine KI-Anwendung im echten Alltag einsetzt.
- ✓Um Versuche zu blockieren, die KI auszutricksen (Jailbreaks).
- ✓Um zu verhindern, dass die KI vertrauliche Informationen preisgibt oder toxische Inhalte erzeugt.
Link zum Skill
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/defending-llms-with-guardrails/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Schütze meine KI-Anwendung vor schädlichen Prompts.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Es nutzt drei verschiedene Systeme (Llama Guard, NeMo Guardrails, LLM Guard), die zusammenarbeiten. Eines prüft die Inhalte, ein anderes steuert den Dialog und das dritte durchsucht Eingaben und Ausgaben nach bestimmten Problemen.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von 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
…
Häufige Fragen
Was sind „Jailbreaks“ und „Prompt Injection“?
„Jailbreaks“ sind Versuche, die KI dazu zu bringen, ihre Sicherheitsregeln zu ignorieren. „Prompt Injection“ bedeutet, dass jemand schädliche Befehle in den Prompt für die KI einschleust.
Welche schädlichen Inhalte werden blockiert?
Es blockiert toxische Inhalte, personenbezogene Daten (PII), Geheimnisse wie Passwörter oder Schlüssel und themenfremde Antworten. Außerdem werden Jailbreak- und Prompt-Injection-Versuche erkannt.
Muss ich alle drei Systeme (Llama Guard, NeMo, LLM Guard) nutzen?
Sie ergänzen sich und bieten unterschiedliche Arten von Schutz. Wenn du mehr als eines nutzt, erhöhst du die Sicherheit deiner Anwendung insgesamt.
Details
Originalbeschreibung des Autors
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
Beliebtheit
- GitHub-Sterne
- 35k
- Platz im Ranking
- #7775
- Lizenz
- Apache-2.0
- Aktualisiert
- 31.8.2026
Kommentare
- …
Weitere Skills aus diesem Repository
abusing-dpapi-for-credential-access
35kGibt deinem KI-Agenten fertige Anweisungen für eine bestimmte Aufgabe, damit er sie besser und schneller erledigt.
abusing-shadow-credentials-for-privesc
35kBringt deinem KI-Agenten bei, klare und gut strukturierte Texte zu schreiben.
achieving-cmmc-level-2-compliance
35kHilft deinem Agenten, eine Umgebung für CMMC-Level-2-Konformität vorzubereiten. Setzt Sicherheitsanforderungen um und verwaltet nötige Dokumentation.
acquiring-disk-image-with-dd-and-dcfldd
35kHilft deinem Agenten, exakte Festplattenkopien zu erstellen. Wichtig, damit bei Ermittlungen keine Informationen verloren gehen oder verändert werden.
Ähnliche Skills
add-model-provider
394kLässt deinen Agenten einen neuen KI-Modellanbieter mit sicheren Befehlen an OpenClaw anbinden, API-Schlüssel nicht im Klartext speichern und einen Live-Test starten.
acp-router
394kHilft deinem Agenten, eine Aufgabe über OpenClaw an einen Coding-Assistenten wie Claude Code oder Cursor zu senden, damit die Arbeit in diesem Tool läuft.
browser-automation
394kBringt deinem Agenten bei, Webseiten Schritt für Schritt zu steuern, einschließlich Anmeldungen, Tabs und Wiederherstellung, wenn eine Seite nicht mehr reagiert.