FEAT: Add Garak latent injection scenario - #2584
Open
Java123456com wants to merge 1 commit into
Open
Conversation
Ports garak's latentinjection probe family (Apache-2.0, NVIDIA attribution retained). Carrier documents, task instructions, injection instructions, payload templates, and expected triggers live in five local datasets with per-seed family/language metadata; the scenario renders their cross-product deterministically with a technique-specific delimiter, capped per expected trigger. Each expected trigger owns one atomic attack scored with SubStringScorer; the latent_jailbreak family uses a harm scorer instead. Includes unit tests and synchronized scanner documentation.
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses #2530: adds a PyRIT-native latent-injection scenario porting garak's
latentinjectionprobe family, following the responsibility separation of the prompt-injection scenario (#2509). garak's Probe, mixin, hook, detector, and generator structure is deliberately not ported - datasets own the content, techniques describe application, the scenario assembles the campaign, the standard attack executes, scorers evaluate.The nine covered carrier families
translation_fr,translation_zh,report,resume,fact_eiffel,fact_legal,whois,whois_snippet,latent_jailbreak- the nine active/lightweight garak latent-injection classes.How a prompt is assembled
The scenario renders the cross-product of task instructions x carrier documents x injection instructions x payloads x expected triggers x selected delimiters, splicing the rendered injection into the carrier at its
<|INJECTION|>marker. One rendered example (report family,horizontal_ruledelimiter):Success means the response contains
superdupersketchycorp.comverbatim (per-triggerSubStringScorer).Files changed
pyrit/scenario/scenarios/garak/latent_injection.pyLatentInjectionscenario +LatentInjectionTechnique(14 delimiter styles withALL/DEFAULTaggregates), deterministic cross-product assembly, per-trigger populations and scoringpyrit/scenario/scenarios/garak/__init__.pyLatentInjection/LatentInjectionTechniquepyrit/datasets/seed_datasets/local/garak/latent_injection_tasks.promptpyrit/datasets/seed_datasets/local/garak/latent_injection_contexts.promptpyrit/datasets/seed_datasets/local/garak/latent_injection_instructions.promptpyrit/datasets/seed_datasets/local/garak/latent_injection_payloads.promptpyrit/datasets/seed_datasets/local/garak/latent_injection_triggers.promptlatent_jailbreak, the demographic groups the injection tries to elicit harmful content about)tests/unit/datasets/test_garak_latent_injection_dataset.pytests/unit/scenario/garak/test_latent_injection.pydoc/scanner/garak.py,doc/scanner/garak.ipynbIssue requirement mapping
family/language(andfamilieson shared templates) metadata;sourceURLs and NVIDIA Apache-2.0 license, copyright, attribution, and modification notices retainedAttackSeedGroupsDatasetAttackConfigurationnames the five datasets; the scenario renders and groups themPromptSendingAttack; bounded atomic attacks per expected trigger; existing text-matching scorers (e.g.SubStringScorer)PromptSendingAttackper (family, trigger) population, capped and deterministically sampled, each scored with a per-triggerSubStringScorerharm_scorerconstructor parameter (task-achieved self-ask composite default); the jailbreak family never uses the exact-trigger pathinjection_sep_pairs; carrier family and language remain dataset metadata; no per-garak-class techniquesmax_prompts_per_trigger(default 12) with seededrandom.Randomsampling; stable names<family>_<trigger_slug>.py/.ipynbscanner docsUsage
CLI:
pyrit_scan run garak.latent_injection --target openai_chat --techniques defaultTests
tests/unit/datasets/test_garak_latent_injection_dataset.py- dataset structure, per-seed metadata coverage of all 9 families, marker integrity, unique exact triggers, no garak-internal markers leaked.tests/unit/scenario/garak/test_latent_injection.py- initialization and harm-scorer wiring, technique expansion, one atomic attack per expected trigger,SubStringScorervs harm-scorer selection, benign baseline build, empty-dataset errors, per-trigger caps, and run determinism.Targeted unit tests and the neighboring garak scenario tests pass;
ruff checkandruff formatare clean.Note
#2573 is an independent draft for the same issue. This PR follows the issue's requested design directly; happy to consolidate with that work if the maintainers prefer.