Lesson 30 Safety & Red Teaming
Theme:

Homework

Complete these tasks before Lesson 31. Work in a Python script or plain text. The goal is to develop practical safety engineering skills and adversarial thinking.

Task 1: Build a Threat Model

Goal: Apply threat modeling methodology to a realistic LLM application.

Instructions

Choose one of the following LLM-powered applications (or use one from your own work):

For your chosen application, document:

  1. Assets to protect: What data, instructions, or capabilities must not be exposed or misused? (List at least 5)
  2. Adversary profiles: Who might attack the system, and what are their motivations? (List at least 3 profiles)
  3. Top 5 risks: For each risk, state the vulnerability class (prompt injection, jailbreak, data extraction, hallucination), the attack scenario, the potential impact, and the recommended defense layer

Deliverable

A structured document (markdown, text, or code comments) in this format:

Application: [name]

Assets:
1. System prompt containing business logic
2. Customer PII in conversation history
3. ...

Adversary Profiles:
1. Curious user - wants to see system prompt out of interest
2. Malicious actor - wants to extract customer data
3. ...

Risk Register:
| # | Vulnerability     | Scenario                          | Impact   | Defense Layer        |
|---|-------------------|-----------------------------------|----------|----------------------|
| 1 | Prompt injection  | User injects "ignore rules" text  | High     | Input validation     |
| 2 | Data extraction   | User asks for other users' info   | Critical | Output filtering     |
| 3 | ...               | ...                               | ...      | ...                  |

Self-check

Task 2: Extend the Red Team Test Suite

Goal: Develop adversarial thinking by creating novel attack prompts that go beyond the examples in the lab.

Instructions

Write 5 new attack prompts that were not in the lab exercises. Each prompt should target a different evasion technique. Consider:

For each attack prompt:

  1. Write the prompt
  2. Identify the evasion technique used
  3. Run it through the validate_input() function from the lab
  4. Record whether it was caught or bypassed the filter
  5. If it bypassed the filter, write an updated regex or defense that would catch it

Deliverable

A Python script or table with your 5 attacks, results, and proposed fixes:

EXTENDED_ATTACKS = [
    {
        "prompt": "Your attack prompt here",
        "technique": "Evasion technique name",
        "caught_by_validator": True,  # or False
        "proposed_fix": "Description or regex pattern",
    },
    # ... 4 more
]

Self-check

Task 3: Design a Responsible Disclosure Process

Goal: Think through the practical and ethical aspects of reporting LLM safety vulnerabilities.

Instructions

Imagine you have discovered a prompt injection vulnerability in a publicly deployed LLM-powered chatbot operated by a major company. The vulnerability allows you to extract the full system prompt, including internal business rules and API keys embedded in the prompt.

Write a responsible disclosure plan (~300 words) that covers:

  1. Initial assessment: How would you verify the severity of the vulnerability without causing harm?
  2. Contact strategy: How would you find and contact the right person at the company? What channels would you use?
  3. Report contents: What information would you include in your disclosure report? What would you omit?
  4. Timeline: How long would you give the company to respond and remediate before considering public disclosure?
  5. Ethical boundaries: What actions would be unethical even in the name of security research? Where do you draw the line?

Deliverable

A written plan (~300 words) that addresses all 5 points above.

Self-check

📥 Reference Solution

⬇ lab_answer.py

Submission

There is no formal submission for this course. These tasks are for your own development. However:

Next lesson: Lesson 31 — Observability & Monitoring for LLM systems in production.