Cyberlium

AI › Module 3 › Lesson 3

BeginnerModule 3Lesson 3/5

Defenses Named

Defenses named literacy lists input validation, output filtering, privilege separation, and human review — map controls on YOUR $AI_LAB toy integration.

15 min+40 XP3 quiz
Module progress3 of 5

Visual · t32_defenses_named

Injection defenses literacy. $AI_LAB only. Original Cyberlium.

Opening

No single silver bullet — literacy names layered defenses so you harden toys you own before production copilots.

Prompt injection defenses include: strong system prompts with explicit untrusted zones, input sanitization and length limits, output filtering and schema validation, least-privilege tool permissions, retrieval source allowlists, monitoring for injection patterns, and human-in-the-loop for high-risk actions. Defense in depth beats one 'do not jailbreak' line. Cyberlium maps defense layers on YOUR $AI_LAB toy chatbot — paper control matrix before live changes. Next: Injection Lab.

1. Defense layers (named)

Input: validate format, strip known injection phrases, cap length. Output: block secrets patterns, enforce JSON schema, redact PII. Tools: allowlist functions, deny file paths outside scope. Process: log prompts, alert on override phrases, require approval for sensitive ops.

On $AI_LAB, write defense matrix — four layers with one control each for toy chatbot.

Command guide

Try these commands — Defense layers (named)

═══ TOOLS & WEBSITES ═══ Browse / read these (authorized learning only — stay in YOUR lab / program scope)

OWASP LLM Top 10 mitigations — https://owasp.org/www-project-top-10-for-large-language-model-applications/ OpenAI safety best practices — https://platform.openai.com/docs/guides/safety-best-practices NIST AI RMF — https://www.nist.gov/itl/ai-risk-management-framework

═══ INSTALL ═══

Linux (Debian/Ubuntu):

Command — copy this

sudo apt install python3

macOS:

Command — copy this

brew install python3

Windows: Download https://python.org/downloads/

═══ LINUX / macOS ═══

Command — copy this

export AI_LAB=${AI_LAB:-$HOME/cyberlium-lab/t32-ai}
cat > "$AI_LAB/injection/defenses-checklist.md" <<'EOF'
# Prompt Injection Defenses — YOUR app notes
- [ ] System prompt: least privilege instructions, no secrets
- [ ] Input validation: length limits, pattern blocklists
- [ ] Output validation: refuse policy violations, no raw HTML/JS
- [ ] Tool sandbox: allowlisted actions, no arbitrary shell
- [ ] RAG hygiene: trusted sources, content sanitization
- [ ] Human review for high-risk actions
Apply to YOUR designs — not as attack recipes vs stranger SaaS
EOF

Command — copy this

grep '\[ \]' "$AI_LAB/injection/defenses-checklist.md"

Primary tools to practice this lesson: grep, python3. Reference sites: OWASP LLM Top 10 mitigations (https://owasp.org/www-project-top-10-for-large-language-model-applications/); OpenAI safety best practices (https://platform.openai.com/docs/guides/safety-best-practices); NIST AI RMF (https://www.nist.gov/itl/ai-risk-management-framework). Run every command in the box — install first, then the usage lines — only on YOUR lab / program scope.

2. Why layered defenses reduce injection success

Models evolve — static blocklists fail alone. Combining input guard, output filter, and tool least privilege limits blast radius when one layer fails. Red teams test on scoped toys with written ROE — not stranger prod.

Students prioritize controls by risk on lab toy — employer prod changes need ticket.

3. Literacy ≠ false confidence

Forbidden: claiming 'our system prompt is enough' without output or tool guards. Allowed: defenses named card — four layers mapped to $AI_LAB toy with gap note.

Ship: injection defenses card for YOUR lab toy. Next: Injection Lab.

4. What you ship: injection defenses card for $AI_LAB

Four defense layers with controls and one gap. $AI_LAB named. chmod 600.

5. What you record before the next lesson

Date. Defenses card. $AI_LAB named. File t32-m03-l03-defenses-named.txt chmod 600.

6. Wrong vs right: stranger SaaS vs YOUR toy LLM

Worked failure — same MSF word, opposite target. Right never needs a café Wi-Fi or classmate laptop.

  • Wrong

    Rely on system prompt alone. Skip tool permission review on lab toy.

  • Right

    Write injection defenses card for YOUR $AI_LAB toy. Next: Injection Lab.

Mission: map injection defenses on YOUR lab toy

1) List input, output, tool, process layers. 2) Assign one control per layer. 3) Note one gap and fix intent. 4) chmod 600.

Stuck? Ask Cyberlium AI Mentor

Human review for wire transfers beats another prompt paragraph.

Knowledge Check

1

APPLY: Output filtering primarily:

Multiple choice

Knowledge Check

2

APPLY: True or False: Least-privilege tool permissions limit injection blast radius.

True or False

Knowledge Check

3

APPLY: Defenses named literacy on Cyberlium uses:

Multiple choice

← Previous

Answer all 3 knowledge checks to continue. (0/3 answered)