Recommended resources
The freely available resources this lesson will direct you to.
- LLM Vulnerability Scanning with garak. Tutorial: Test your own chat bots!www.youtube.com
- AI Model Penetration: Testing LLMs for Prompt Injection & Jailbreakswww.youtube.com
- Promptfoo vs Garak: Choosing the Right LLM Red Teaming Toolwww.promptfoo.dev
- The Automation Advantage in AI Red Teaming - Dreadnodedreadnode.io
Hello! In our previous lessons, we delved deep into the craft of manual prompt engineering, culminating in a sophisticated multi-turn social engineering attack. You learned how creativity, context, and conversation can be used to bypass an LLM's safeguards.
This approach, often called "red teaming," is crucial for discovering novel and complex vulnerabilities. However, it's not scalable. Just as in traditional application security, you wouldn't rely solely on manual penetration tests; you'd also use automated scanners to check for known issues at scale.
Today, we shift our focus from the artisanal to the industrial. This lesson addresses the learning outcome: Explain the role of automated scanners like Garak in an LLM security testing workflow. We'll explore why automation is indispensable, what tools like Garak do, and how they fit into a comprehensive security strategy.
The Problem of Scale: Why Manual Testing Isn't Enough
The attack surface of an LLM is language itself—an almost infinite space of inputs. Manually testing every potential vulnerability is impossible. This challenge is compounded by the rapid proliferation of models.
To understand why we need to automate, let's draw a parallel to traditional application security, a domain you're very familiar with from your SRE and infrastructure background.
AI Model Penetration: Testing LLMs for Prompt Injection & Jailbreaks
This video from IBM Technology, 'AI Model Penetration: Testing LLMs for Prompt Injection & Jailbreaks,' effectively frames the problem. It highlights the vastness of the LLM landscape and draws an excellent analogy to traditional SAST and DAST.
Please watch from 01:01 to 05:51. Pay attention to three key points: The difference between the attack surface of a traditional app and an LLM. The infeasibility of manually inspecting the millions of available models. The parallel drawn between Static/Dynamic Application Security Testing (SAST/DAST) and the methods for testing LLMs. This analogy is central to understanding the role of automated scanners.
As the video explained, we need tools that can systematically probe our LLM applications for known weaknesses, similar to how a DAST scanner like OWASP ZAP or Burp Suite tests a running web application for vulnerabilities like SQL injection or XSS. This is precisely the role that automated LLM vulnerability scanners play.
Introducing Garak: An Automated LLM Vulnerability Scanner
Garak (Generative AI Red-teaming & Assessment Kit) is an open-source tool designed specifically for this purpose. Its philosophy is to provide a comprehensive library of pre-defined, research-backed attacks to test LLM endpoints for known weaknesses.
Garak's Architecture: Probes, Generators, and Detectors
At its core, Garak is built on a modular architecture consisting of three main components. Understanding these is key to understanding its role.

-
Probes: These are the attacks. A probe is a module that generates a list of prompts designed to test for a specific vulnerability class (e.g., prompt injection, toxicity, data leakage). Garak comes with a large library of probes covering many categories from the OWASP Top 10 for LLMs.
-
Generators: This is the "connector" to your target. A generator knows how to communicate with a specific LLM or application. For your project, you'll be using Garak's
restgenerator to target your FastAPI endpoint. This is analogous to configuring a monitoring agent or a DAST scanner to point at the correct API. -
Detectors: These are the "evaluators." After a probe sends a prompt and gets a response, a detector analyzes that response to determine if the attack was successful. For example, a
Jailbreakdetector might look for keywords indicating the model ignored its instructions.
This entire process is automated. Garak iterates through its probes, sends prompts via the generator, and uses detectors to log hits (successful attacks).

To get a feel for how these pieces come together in practice, the following video provides a concise overview.
LLM Vulnerability Scanning with garak. Tutorial: Test your own chat bots!
The video 'LLM Vulnerability Scanning with garak' gives a quick, practical overview of Garak's structure and purpose.
Watch the first 1 minute and 46 seconds. The speaker provides a clear, high-level explanation of Garak's architecture and its library of probes and detectors.
Garak's Role in a Security Testing Workflow
So, where does a tool like Garak fit in your end-to-end security process? It serves several critical functions that complement manual red teaming.
Promptfoo vs Garak: Choosing the Right LLM Red Teaming Tool
The article 'Promptfoo vs Garak' provides an excellent comparison of two different philosophies in LLM testing. While its goal is to compare tools, it gives us a very clear definition of Garak's intended role.
Please read the following sections: 'Two Different Security Testing Philosophies': This explains Garak's focus on a library of pre-defined attacks. 'Garak’s Curated Attack Library': This details the nature of its probes. 'Integration Into Development Workflows': Note the description of Garak for 'one-off audits.' 'Making the Right Choice': This final summary clearly states Garak's primary use case. \nFocus on how Garak is positioned as a tool for validating against known exploits.
Based on this, we can define Garak's role in a professional workflow as follows:
- Baseline Vulnerability Assessment: Before any manual testing, run Garak to get a baseline report of the application's resilience against a wide range of common, known attacks. This is your initial "health check."
- Regression Testing in CI/CD: Since you have a strong DevOps background, you can see the immediate value here. Garak scans can be integrated into a CI/CD pipeline to ensure that new code changes, model updates, or prompt modifications haven't introduced new vulnerabilities or re-opened old ones. It acts as an automated security gate.
- Benchmarking: Use Garak to compare the security posture of different models (e.g., Llama 3 vs. Phi-3) or different system prompts with the same model. The standardized reports allow for objective, data-driven comparisons.
- Security Audits: Garak provides a systematic, repeatable way to conduct an audit of an LLM application, generating evidence (logs and reports) that can be used for compliance and risk assessment.
Trade-offs: Automation vs. Manual Red Teaming
Your goal is to understand the trade-offs at each layer, and the choice between automated scanning and manual testing is a classic one. Neither is a silver bullet; they are complementary.
The Automation Advantage in AI Red Teaming
A recent research paper, summarized in the article 'The Automation Advantage in AI Red Teaming,' provides hard data on the effectiveness of automated versus manual attacks. This is crucial for understanding the trade-offs.
Read the article, paying close attention to these key findings: The core result: Automated attacks have a significantly higher success rate than manual ones. The 'adoption paradox': Despite being more effective, automation is underutilized. The 'time-efficiency tradeoff': Manual attacks can be faster for simple challenges, but automation scales far better for complex ones and runs autonomously. The final conclusion: The optimal strategy is a hybrid approach combining human creativity with automated execution.
Let's synthesize this into a clear table of trade-offs for your consulting demo:
| Feature | Automated Scanning (Garak) | Manual Red Teaming |
|---|---|---|
| Scope | Breadth. Tests a wide range of known vulnerabilities systematically. | Depth. Focuses on finding novel, context-specific vulnerabilities. |
| Effectiveness | Higher success rate on problems that can be solved systematically or via brute-force variations. | Essential for complex, multi-step attacks (like the social engineering attack from our last lesson) that require human intuition. |
| Speed & Scale | Fast and highly scalable. Can run thousands of tests autonomously. Ideal for CI/CD. | Slow and resource-intensive. Does not scale easily. |
| Repeatability | 100% repeatable. Guarantees consistent testing across environments and over time. | Dependent on the skill and approach of the individual tester. Hard to reproduce consistently. |
| Cost | Low marginal cost per test run after initial setup. | High cost per engagement due to the need for specialized human expertise. |
The key takeaway for your demo is that relying only on manual testing is like only having a star penetration tester but no automated security scanners for your web servers. You'll miss the basics. Relying only on automation is like having scanners but no one to find the clever business logic flaws. You need both.
Conclusion
In this lesson, we established the critical role of automated scanners in any serious LLM security workflow. They provide the breadth, scale, and repeatability that manual testing cannot.
Key Takeaways:
- Automated scanners are necessary to address the massive attack surface of LLMs and the infeasibility of purely manual testing.
- Garak is an open-source scanner that uses a library of pre-defined probes to test for known vulnerabilities.
- Its architecture consists of Probes (attacks), Generators (connectors), and Detectors (evaluators).
- In a security workflow, Garak is used for baseline scanning, regression testing, benchmarking, and auditing.
- The optimal security strategy is a hybrid approach, combining the breadth and speed of automated scanners like Garak with the depth and creativity of manual red teaming.
Next Up:
Now that you understand the why and what of Garak, our next lesson will focus on the how. You will install and configure Garak to target your local Ollama-backed chatbot, taking the first practical step into automated LLM security testing.