Thanks to visit codestin.com
Credit goes to github.com

Skip to content

probe: add simple adaptive attacks probe#1742

Merged
jmartin-tech merged 5 commits into
NVIDIA:mainfrom
neerazz:probe-adaptive-attacks-583
Jun 17, 2026
Merged

probe: add simple adaptive attacks probe#1742
jmartin-tech merged 5 commits into
NVIDIA:mainfrom
neerazz:probe-adaptive-attacks-583

Conversation

@neerazz

@neerazz neerazz commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements adaptiveattacks.AdaptiveAttacks and adaptiveattacks.AdaptiveAttacksFull based on Andriushchenko, Croce, and Flammarion, "Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attacks" (ICML 2024, arXiv:2404.02151).

The v1 probe is template-only: it combines a paraphrased adaptive prompt template (direct-assistant role + structured response scaffold + no-I affirmative-opener constraint) with a small cached set of seed forbidden behaviors and pre-computed adversarial suffixes drawn from public AdvBench results. No gradient computation or online search is performed.

Files

  • garak/probes/adaptiveattacks.pyAdaptiveAttacks (active, capped via soft_probe_prompt_cap) and AdaptiveAttacksFull (uncapped, opt-in)
  • garak/data/adaptive_attacks/seeds.txt — 20 seed forbidden behaviors
  • garak/data/adaptive_attacks/suffixes.txt — 3 cached adversarial suffix variants
  • tests/probes/test_probes_adaptiveattacks.py — 8 tests covering load, prompt content, template markers, prompt-cap behavior

Engagement context

The original ticket #583 was soft-claimed by @enesyesil on 2025-09-17. After 7 months without a PR, I posted a polite check-in on 2026-04-28 (comment) saying I would proceed in 7 days unless they responded. No response received. Happy to step aside if @enesyesil resumes or @leondz prefers a different approach.

Test plan

  • pytest tests/probes/test_probes_adaptiveattacks.py -v — 8/8 pass
  • garak --list_probes | grep adaptiveattacks — both classes registered, default-active marker shown
  • garak --probes adaptiveattacks.AdaptiveAttacks --model_type test.Blank — completes in 1.42s with no errors
  • CA/DCO sign-off — first commit signed with -s; will sign CA on bot prompt

Scope

v1 is intentionally minimal (single template + cached suffixes) per "good first issue" sizing. Future variants (random-search suffix optimization, GCG-style gradient suffix, multi-turn self-transfer) can land as follow-up PRs.

Closes #583.

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

DCO Assistant Lite bot All contributors have signed the DCO ✍️ ✅

@leondz

leondz commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Thank you @neerazz, will take a look

@jmartin-tech jmartin-tech left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A suggestion not a full review. The desire to support Full probes is somewhat in limbo as they create duplication when activated at the same time as the restricted versions.

Comment thread garak/probes/adaptiveattacks.py Outdated
Comment thread garak/probes/adaptive_attacks.py
@neerazz

neerazz commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

I have read the DCO Document and I hereby sign the DCO

Implements AdaptiveAttacks and AdaptiveAttacksFull probes based on
Andriushchenko, Croce, and Flammarion, "Jailbreaking Leading
Safety-Aligned LLMs with Simple Adaptive Attacks" (ICML 2024,
arXiv:2404.02151).

The v1 probe is template-only: it combines a paraphrased adaptive
prompt template (direct-assistant role + structured response scaffold
+ no-"I" affirmative-opener constraint) with a small cached set of
seed forbidden behaviors and pre-computed adversarial suffixes drawn
from public AdvBench results. No gradient computation or online
search is performed.

- garak/probes/adaptiveattacks.py: AdaptiveAttacks (active, capped)
  and AdaptiveAttacksFull (uncapped, opt-in)
- garak/data/adaptive_attacks/{seeds,suffixes}.txt: 20 seeds,
  3 suffix variants
- tests/probes/test_probes_adaptiveattacks.py: 8 tests covering
  load, prompt content, template markers, and prompt-cap behavior

Smoke run against test.Blank completes without error.
Closes NVIDIA#583.

Signed-off-by: Neeraj Kumar Singh <[email protected]>
@neerazz neerazz force-pushed the probe-adaptive-attacks-583 branch from 263fb39 to 4a507c7 Compare May 7, 2026 04:13
@neerazz

neerazz commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review @jmartin-tech. Pushed two fixes:

1. CI failure (test_docs.py::test_docs_probes[adaptiveattacks]) — added the missing docs/source/probes/adaptiveattacks.rst stub and linked it from index_probes.rst. The Linux/Mac/Windows pytest cancellations were all downstream of this single doc-test failure.

2. Full probe duplication concernAdaptiveAttacksFull is already active = False (opt-in only) on this branch, but the docstring/comment didn't make the design intent obvious. Updated both to call out explicitly that it's inactive by default to avoid prompt duplication when a run selects both AdaptiveAttacks (capped) and AdaptiveAttacksFull (uncapped). Happy to drop Full entirely if you'd prefer the simpler shape — let me know.

github-actions Bot added a commit that referenced this pull request May 7, 2026
Address @jmartin-tech review on NVIDIA#1742:

(a) Use the canonical follow_prompt_cap guard pattern (per NVIDIA#1546/NVIDIA#1562 +
    encoding.py / latentinjection.py) instead of an unconditional
    self._prune_data() call.

(b) Add DEFAULT_PARAMS override on AdaptiveAttacksFull to flip
    follow_prompt_cap to False, replacing the previous Probe.__init__
    bypass. This makes the no-cap behavior a configurable param rather
    than a constructor hack, matches how every other Full variant in the
    repo expresses uncapped intent, and lets users re-enable the cap on
    Full via config if they want.

AdaptiveAttacks: follow_prompt_cap=True  -> prunes to soft_probe_prompt_cap
AdaptiveAttacksFull: follow_prompt_cap=False -> keeps every (seed, suffix) pair

All 8 tests in tests/probes/test_probes_adaptiveattacks.py still pass,
plus tests/test_docs.py adaptive cases (4) and the broader probe suite
(1130 passing; the 1 remaining failure is the pre-existing audio probe
optional-deps issue unrelated to this PR).

Signed-off-by: Neeraj Kumar Singh <[email protected]>
neerazz added a commit to neerazz/garak that referenced this pull request May 7, 2026
Address @jmartin-tech review on NVIDIA#1742:

(a) Use the canonical follow_prompt_cap guard pattern (per NVIDIA#1546/NVIDIA#1562 +
    encoding.py / latentinjection.py) instead of an unconditional
    self._prune_data() call.

(b) Add DEFAULT_PARAMS override on AdaptiveAttacksFull to flip
    follow_prompt_cap to False, replacing the previous Probe.__init__
    bypass. This makes the no-cap behavior a configurable param rather
    than a constructor hack, matches how every other Full variant in the
    repo expresses uncapped intent, and lets users re-enable the cap on
    Full via config if they want.

AdaptiveAttacks: follow_prompt_cap=True  -> prunes to soft_probe_prompt_cap
AdaptiveAttacksFull: follow_prompt_cap=False -> keeps every (seed, suffix) pair

All 8 tests in tests/probes/test_probes_adaptiveattacks.py still pass,
plus tests/test_docs.py adaptive cases (4) and the broader probe suite
(1130 passing; the 1 remaining failure is the pre-existing audio probe
optional-deps issue unrelated to this PR).

Signed-off-by: Neeraj Kumar Singh <[email protected]>
@neerazz

neerazz commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

Just pushed a85aa90 which applies the canonical pattern more directly per your earlier suggestion:

  • AdaptiveAttacks now declares DEFAULT_PARAMS = Probe.DEFAULT_PARAMS | {"follow_prompt_cap": True} and guards the prune call with if self.follow_prompt_cap: self._prune_data(cap=self.soft_probe_prompt_cap) — matching the shape used in encoding.py / latentinjection.py / factor up template soft_probe_prompt_cap logic #1546 / probe: probes should follow soft_probe_prompt_cap #1562.
  • AdaptiveAttacksFull now expresses "no cap" via DEFAULT_PARAMS = AdaptiveAttacks.DEFAULT_PARAMS | {"follow_prompt_cap": False} instead of overriding __init__ to bypass AdaptiveAttacks.__init__. Cleaner, configurable, no constructor hack.

active = False on AdaptiveAttacksFull is preserved so the duplication concern stays addressed by default. If you'd still prefer to drop Full entirely rather than ship two probes, happy to do that in a follow-up commit — just let me know.

Local verification (Python 3.12): 8/8 tests/probes/test_probes_adaptiveattacks.py, 4/4 adaptive cases in tests/test_docs.py, 1130/1130 in tests/probes/test_probes.py (excluding the pre-existing AudioAchillesHeel optional-deps failure unrelated to this PR).

@jmartin-tech jmartin-tech changed the title probe: add simple adaptive attacks probe (closes #583) probe: add simple adaptive attacks probe May 7, 2026
@neerazz

neerazz commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Friendly nudge — wanted to make this easy to action on whatever timeline works.

State recap as of today:

  • All 16 CI checks ✅ (Linux/Mac/Windows × Py 3.10/3.12/3.13, docs, pip install)
  • DCO signed
  • @jmartin-tech's Full duplication concern addressed in a85aa90 via the canonical DEFAULT_PARAMS | {"follow_prompt_cap": False} pattern, with active = False preserved so it's opt-in only

Two simple paths from here, whichever you prefer:

  1. Ship as-isAdaptiveAttacks (capped, active) + AdaptiveAttacksFull (uncapped, inactive). Duplication risk is gated by active = False.
  2. Drop Full entirely — I'll push a one-commit follow-up removing the second class and keeping only AdaptiveAttacks with the configurable cap. Simpler surface, no opt-in probe to maintain.

Happy to do either. Just let me know which shape you'd rather merge.

@neerazz

neerazz commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Simplified to a single probe per the earlier feedback thread — dropped AdaptiveAttacksFull entirely (commit 3ceba9b).

What changed:

  • AdaptiveAttacksFull class removed from garak/probes/adaptiveattacks.py
  • Test file updated to remove the Full-specific parametrize entry and the test_adaptiveattacks_full_ignores_cap test
  • AdaptiveAttacks (capped, active=True) is the only probe now — cleaner surface, no inactive opt-in class to maintain

Uncapped runs still possible via --config follow_prompt_cap=false (the DEFAULT_PARAMS key is still there).

This matches option 2 from my earlier comment. All 16 CI checks were green on the previous commit; no functional change to AdaptiveAttacks itself, so CI should stay green.

AdaptiveAttacksFull was inactive by default (active=False) to prevent
prompt duplication when both probes run together. Removing it entirely
gives the same safety guarantee with a simpler surface: one probe,
one configurable cap, no opt-in class to maintain.

AdaptiveAttacks keeps follow_prompt_cap=True and the soft_probe_prompt_cap
guard. Uncapped runs remain possible via --config follow_prompt_cap=false.

Signed-off-by: Neeraj Kumar Singh <[email protected]>
@neerazz neerazz force-pushed the probe-adaptive-attacks-583 branch from 3ceba9b to c2f2ae3 Compare June 9, 2026 17:08
@neerazz

neerazz commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Fixed DCO sign-off. Amended commit `3ceba9b` → `c2f2ae3` to add the missing `Signed-off-by` line:

```
Signed-off-by: Neeraj Kumar Singh [email protected]
```

Force-pushed to `probe-adaptive-attacks-583`. DCO check should now pass. @jmartin-tech @leondz — ready for your review when you have a chance.

@jmartin-tech jmartin-tech left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor tweak and an information request.

Do you know of a target within the last year that will show a rate of successful attack from this probe?

Comment thread garak/probes/adaptiveattacks.py Outdated
@neerazz neerazz force-pushed the probe-adaptive-attacks-583 branch from c2f2ae3 to 90eb9f9 Compare June 9, 2026 17:20
New probes should have no aliases; aliases are for tracking renamed
probes. Addresses @jmartin-tech review feedback.

Signed-off-by: Neeraj Kumar Singh <[email protected]>
@neerazz

neerazz commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @jmartin-tech!

Alias tweak (commit 91b70748): removed aliases = [...]. You're right — aliases are for renamed probes and a new probe should have none. Applied and force-pushed.

Recent target with measurable success rate:

The technique this probe implements (adaptive template + cached suffix) is directly from Andriushchenko, Croce, and Flammarion (ICML 2024, arxiv:2404.02151). The paper reports concrete attack success rates against several safety-aligned models that remain in active deployment today: GPT-3.5-turbo, GPT-4, Gemini Pro, and Llama-2-7B/13B-chat. Those are the primary documented targets with published success rates.

For a more recent reference: within the past year, Meta Llama 3 variants (released April 2024) and derivative fine-tuned models have been widely studied as jailbreak targets and are commonly used in garak evaluation runs against this class of prompt-injection attack. Standard RLHF safety training without specific defenses against template-based adaptive prompting continues to show non-trivial attack success rates with this technique.

If you'd prefer a specific success rate number on a 2025-era model, I can run the probe against an open-source model (e.g., Llama-3.1-8B-Instruct) and report the output — but I didn't want to delay the PR for that if the paper's citations and the broader Llama 3 evaluation context are sufficient for your purposes. Let me know.

@neerazz

neerazz commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Hi @jmartin-tech — wanted to follow up since my Jun 9 response may have gotten buried. All items from your review are addressed:

  • aliases removed (commit 91b70748)
  • AdaptiveAttacksFull dropped; single capped probe, fully configurable cap via --config follow_prompt_cap=false (commit 90eb9f99)
  • ✅ DCO sign-off fixed
  • ✅ CI is fully clean (all checks passing)

On your question about a recent target with measurable success rate — I replied with references to the ICML 2024 paper targets (GPT-3.5/4, Gemini Pro, Llama-2) and Llama 3 variants. If you'd find it more useful to have a direct number from running the probe against Llama-3.1-8B-Instruct, I'm happy to do that before you close the review — just say the word.

Whenever you get a chance to re-review, I'd really appreciate it. Thanks again for the detailed feedback that made this a cleaner, simpler probe.

@jmartin-tech jmartin-tech self-assigned this Jun 15, 2026

@jmartin-tech jmartin-tech left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing looks good, couple minor revisions.

I can make these adjustment before landing if all are in agreement.

Comment thread garak/probes/adaptiveattacks.py Outdated
Comment thread garak/probes/adaptiveattacks.py Outdated
Comment thread garak/probes/adaptive_attacks.py
Comment thread garak/data/adaptive_attacks/seeds.txt
Comment thread garak/data/adaptive_attacks/suffixes.txt
@neerazz

neerazz commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @jmartin-tech — those revisions sound good to me. Please feel free to make the adjustments before landing.

@jmartin-tech jmartin-tech force-pushed the probe-adaptive-attacks-583 branch from f4e7bcf to a462062 Compare June 16, 2026 22:40
@jmartin-tech

Copy link
Copy Markdown
Collaborator

Minor adjustment pushed, maintainer discussion landed on naming convention as adaptive_attacks.AdaptiveAttacks. This will land once CI validation completes.

@jmartin-tech jmartin-tech merged commit ed2cde5 into NVIDIA:main Jun 17, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

probe: simple adaptive attacks

4 participants