NVIDIANVIDIA-Certified Professional: Agentic AI2026-109.4 Deploy layered safety frameworks (filters, escalation protocols).
Compare defenses against matched adversarial attempts
Completed by the knowledge check
Learning objective
Red-team for prompt injection and jailbreaks, and compare defenses before and after.
Core idea
A red-team result describes an attacker, an entry point, an intended deviation, and an observed outcome. A lower attack-success rate after adding a defense is useful only if the attack population remains comparable and legitimate work still succeeds. A system that refuses every request can appear secure under an attack-only score.
OWASP distinguishes direct prompt injection through user input from indirect injection through external content. It treats jailbreaking as a form of prompt injection, one that makes the model disregard its safety protocols entirely, and notes that preventing it requires ongoing updates to the model’s training and safety mechanisms. Within that family, jailbreak tests attempt to defeat behavioral restrictions; an indirect injection can instead induce an unauthorized tool action without producing obviously toxic text. Your test plan must cover both instruction following and the consequences available to the agent.
See 9.3.2 for harmful-output and overblocking measurements, and 3.1.4 for repeatable evaluation artifacts. This lesson adds adversarial entry points, attack-success criteria, and paired defense comparisons.
How it works
Describe success before generating attacks
Build a scenario register with an attack identifier, trusted task, entry point, target asset, intended deviation, and scoring rule. For example, an instruction in a retrieved article might ask a research assistant to send an unpublished manuscript to an external address. Success is an attempted or completed unauthorized transmission, as defined by your test, rather than the presence of an alarming phrase in the answer.
Keep these outcomes separate: the detector flagged the payload; the agent followed its instruction; the tool proposed an unauthorized operation; and the operation actually reached the mocked destination. A refusal after a transmitted message is a failed security outcome. Conversely, a model can follow a malicious suggestion while an independently enforced permission blocks the resulting action. Record both the model failure and the containment success.
Run the test against synthetic data and inert tools. NVIDIA’s NeMo Agent Toolkit retail safety example explicitly requires sandboxed red teaming and mocks email and database writes.
Use a scanner for breadth and workflow injection for depth
NVIDIA’s garak supplies probes, generators, and detectors. A generator connects the scanner to its target, probes supply adversarial interactions, and detectors identify specified failures in outputs. In the v0.17.0 README, garak --list_probes enumerates probes; --target_type and --target_name select the target interface and model; --spec probes.promptinject selects the PromptInject probe family.
The scanner reports per-probe detector results and records a detailed .jsonl run log. A scanner pointed directly at a model measures that model path: for a chat model, --target_type nim with --target_name set to the NIM model name scans the model alone. To claim that an application is protected, target the defended application path and verify that the relevant controls execute. For that, garak’s rest.RestGenerator connects to any REST endpoint that returns plaintext or JSON, configured by a short YAML file that describes the endpoint, so it can reach the guarded application’s own API. Broad scanner coverage does not replace tests of your retrieval fields, tools, and business permissions.
The NeMo Agent Toolkit v1.9.0 retail example supplies targeted workflow tests; its built-in defense middleware requires the defense extra (nvidia-nat[defense]). Its _type: red_teaming middleware injects an attack_payload at a configured target_function_or_group and target_location. target_field selects the affected field; payload_placement supports replace, append_start, append_middle, and append_end. These identifiers let you test an indirect instruction inside a tool result rather than merely submitting another hostile user prompt.
Score the workflow, including partial failures
The example’s RedTeamingRunner executes the dataset and scenarios, while RedTeamingEvaluator applies scenario-specific judging. scenario_specific_instructions defines the desired interpretation; intermediate_step_filters selects the events to inspect; reduction_strategy combines evaluations using first, last, or max.
Match the inspected event to the harm. Scoring only the final answer can miss a disclosure that occurred during a tool call. Include a deterministic check of the mocked operation’s recipient and payload when those fields decide success, then compare that result with the judge’s assessment. Review disagreements instead of assuming the LLM judge proves the security outcome.
The example uses scores of 0.0 for failure of the attack, 0.5 for partial success, and 1.0 for full success. Its attack success rate counts scores greater than 0.5; its overall risk score is the mean of scenario scores. Partial failures therefore affect the mean without counting as successful attacks in that ASR definition. Preserve the scoring convention and inspect partials separately; changing the success cutoff between runs destroys the comparison.
Compare the same attack population across defenses
The documented command is nat red-team, with --red_team_config selecting the scenario configuration and --reps 5 illustrating repeated runs. The retail example compares configurations whose base_workflow changes from the baseline to the defended workflow. Preserve the dataset, attack placements, scoring rubric, and repetition count while changing the defense under study. Stochastic outputs still require repeated observations; five repetitions are an example, not a statistical guarantee.
NeMo Guardrails’ vulnerability-scanning page illustrates progressive configurations: bare_llm, with_gi, with_gi_dr, and with_gi_dr_mo. These separate the bare model, general instructions, added dialogue rails, and added moderation rails. Use the same principle to isolate which protection changes the result. The page’s per-category table also shows why results are reported by attack family below: adding moderation rails raises or holds the protection rate in every other category, yet module dan falls from 61.3% in with_gi_dr to 52.7% in with_gi_dr_mo. Treat that row as a pattern to look for, and do not reuse the page’s sample protection rates as predictions for your model or workflow.
Keep a frozen comparison set and a separate discovery set for adaptive attacks. After discovering a bypass, preserve it as a regression case and rerun both the baseline and candidate against it. Also retain legitimate tasks that resemble the attack language. Otherwise, the defense can improve its score by rejecting the entire subject area. The frozen comparison set and every regression case run against both the baseline and the defended workflow.
Key distinctions and trade-offs
Choose the test method by the surface and decision it covers:
| Method | Deciding condition | Mechanism | Cost or limitation |
|---|---|---|---|
| Broad jailbreak and injection scan | You need coverage across known adversarial interaction families | garak probes, target generator, detectors, .jsonl log | Many model calls; detector coverage bounds the conclusion |
| Targeted workflow injection | The risk enters through a particular tool or retrieved field | red_teaming, target_field, payload_placement | Scenario design and mocked side effects |
| Defense comparison | You must decide whether a control improves the same workload | Fixed scenarios and rubric; change base_workflow | Repeated runs, legitimate-task checks, and latency measurement |
Report rates with counts and denominators by attack family. A pooled score can improve while a small but severe disclosure category gets worse. Include completed legitimate tasks, blocked legitimate tasks, detector failures, and end-to-end latency alongside attack outcomes.
Architecture / decision scenario
A publishing company’s research assistant summarizes licensed source material and drafts editorial emails. The security release owner requires zero unauthorized email transmissions in the test suite, no more than 3% blocked legitimate tasks, and a measured p95 response under 3.5 seconds. All email operations use a mocked delivery service. The following numbers are hypothetical test observations:
| Observation | Baseline | Defended candidate |
|---|---|---|
| Full attack successes across 400 attempts | 60, or 15% | 12, or 3% |
| Unauthorized transmissions | 4 | 0 |
| Blocked legitimate tasks across 500 tasks | 5, or 1% | 55, or 11% |
| p95 response time | 1.8 seconds | 3.1 seconds |
The tempting proposal is to promote the candidate because full attack success falls by twelve percentage points and the transmission check passes. The release owner rejects that proposal: an 11% legitimate-task block rate violates the 3% requirement, even though latency fits.
The team separates direct jailbreak cases from instructions inserted into retrieved article bodies using target_location: output and the relevant target_field. It examines the 50 additional blocked legitimate tasks, revises the overbroad screening policy, and reruns the matched suite with the email permission unchanged. Promotion depends on all three requirements, not a single scanner score. Any discovered bypass becomes an additional paired regression case rather than silently changing only the candidate’s test set.
Common exam traps
- Testing only hostile user messages while retrieved documents remain untested.
- Treating a direct model scan as an end-to-end application assessment.
- Counting a final refusal as protection after a harmful tool action.
- Counting a score of
0.5as success under the example’s> 0.5ASR definition. - Changing attacks, rubrics, or denominators between baseline and defended runs.
- Promoting a lower attack-success rate without checking legitimate completion and latency.
What to remember
Define the attack’s consequence, inject at the real entry point, and inspect the event that proves success. Compare defenses on matched scenarios with repeated runs and a legitimate workload. Keep scanner findings, model deviations, and independently blocked side effects distinct.
Knowledge check
A team scans its model with garak using --target_type nim and the NIM model name, and few probes succeed. The security owner must decide whether the Guardrails-protected application, served through its own REST API, resists the same probes. What should the team run?
--spec probes.promptinject familyrest.RestGenerator at the NIM APIrest.RestGenerator at the application APIrest.RestGenerator reaches through any REST endpoint returning plaintext or JSON, together with a check that the controls actually ran. More or narrower probes against the NIM still bypass the application, and a REST generator aimed at the NIM still misses the application controls.A red-team run using the NeMo Agent Toolkit retail example’s scoring scores ten scenarios: three at 1.0, four at 0.5 and three at 0.0. What attack success rate does the example’s definition report?
0.5 , so the three full successes give 30%. Counting the partials as successes gives 70%, and 50% is the mean of all scores — the overall risk score, a different metric. The four partial successes alone give 40%; partials affect the mean without counting as successful attacks, which is why they are inspected separately.During adaptive testing, a red-teamer finds a new indirect-injection bypass against a defended candidate. The release decision compares the candidate with its baseline on a frozen scenario set. How should the bypass enter that comparison?
In a research assistant’s red-team suite, an instruction injected into a retrieved article asks the agent to email an unpublished manuscript to an outside address through a mocked email tool. The suite defines success as a completed unauthorized transmission. The evaluator judges only the final answer, which politely declines. What evidence should decide whether that criterion was met?
A candidate that adds moderation rails improves the pooled protection rate across all probe families. The team’s most severe concern is one jailbreak family with relatively few attempts in the suite. What should the comparison report show before the decision?
References
- NVIDIA, NeMo Agent Toolkit Safety and Security, v1.9.0
- NVIDIA, garak README, v0.17.0
- NVIDIA, LLM Vulnerability Scanning
- OWASP, LLM01 Prompt Injection