Skip to content

FEAT: Add DRAConverter (disguise-and-reconstruction from garak) - #4659

Open
Seung-wa Akpan (seung-waedet) wants to merge 2 commits into
microsoft:mainfrom
seung-waedet:feat/4639-dra-converter
Open

Seung-wa Akpan (seung-waedet) wants to merge 2 commits into
microsoft:mainfrom
seung-waedet:feat/4639-dra-converter

Conversation

@seung-waedet

Copy link
Copy Markdown
Contributor

Description

Adds DRAConverter and DRATemplate, ported from garak's DRA probe (Liu et al., USENIX Security 2024). The converter spells the lowercased prompt one letter per line inside harmless phrases, then adds a word guide and instructions to rebuild the request and answer it. Fixes #4639.

  • Takes an optional DRATemplate, garak's three truncation settings with garak's defaults, and an optional seed. With no template, each conversion picks one from the seeded stream, as AskToDecodeConverter does.
  • The templates, letter map, 14 tools and 204 flagged words are in pyrit/datasets/converters/dra_converter*.yaml, generated by a script from garak at f1c99df.
  • Differences from garak: the word guide uses the lowercased prompt, so "Bomb" is cut like "bomb"; a cut never starts at index 0, so a small benign_keep_ratio can't send an empty "" hint; and the stray space in tail hints is gone.
  • Attribution for garak (Apache-2.0) and LLM-DRA (MIT) in the file headers, garak-provenance.json and THIRD_PARTY_NOTICES.txt.
  • Docs: a DRA section in the text-to-text converters page, the 0_converters table row, and liu2024dra in the bibliography. converter_identifier_samples.py gets a DRAConverter.template sample so the contract test doesn't pass it the generic string samples.

Not ported: the harmful_behaviors payloads, the paper's retry loop, DRAAdvanced with Detoxify, and garak's prompt cap.

Port garak's DRA probe as a seeded text converter. The prompt is spelled
one letter per line inside harmless phrases, followed by a word guide and
an answer-forcing template. Templates, letter map, tool phrases, and the
204 flagged words are packaged as YAML generated from garak f1c99df.

Fixes microsoft#4639
Copilot AI balanced review requested due to automatic review settings November 26, 2026 10:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The template cache is not preloaded during construction, so the first async conversion synchronously reads and parses YAML on the event-loop thread.

1 open issue
What changed in this PR

Adds DRAConverter to PyRIT’s text-to-text converter library, addressing #4639 with a single-shot implementation adapted from garak.

Changes:

  • Adds configurable templates, word truncation settings, seeded randomness, and lazy public exports.
  • Adds packaged data, unit tests, and identifier contract samples.
  • Updates documentation, research citations, and third-party attribution.
File Description
third_party/​garak-provenance.json Records upstream sources and revision.
THIRD_PARTY_NOTICES.txt Adds LLM-DRA attribution and license.
tests/​unit/​registry/​converter_identifier_samples.py Supplies template enum samples.
tests/​unit/​converter/​test_dra_converter.py Tests conversion, settings, randomness, and identifiers.
pyrit/​datasets/​converters/​dra_converter.yaml Adds four templates.
pyrit/​datasets/​converters/​dra_converter_words.yaml Adds character phrases, tools, and flagged words.
pyrit/​converter/​dra_converter.py Implements the converter and template enum.
pyrit/​converter/​__init__.py Exposes both symbols through lazy exports.
doc/​references.bib Adds the research citation.
doc/​code/​converters/​1_text_to_text_converters.py Adds a usage example.
doc/​code/​converters/​1_text_to_text_converters.ipynb Adds the matching example and saved output.
doc/​code/​converters/​0_converters.ipynb Lists the converter’s supported modalities.
doc/​bibliography.md Includes the new citation key.

Review effort: Balanced

self._benign_keep_ratio = benign_keep_ratio
self._benign_full_word_probability = benign_full_word_probability
self._seed = seed
self._words = _load_words()

This branch has not been deployed

No deployments
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.

FEAT: Add DRAConverter (disguise-and-reconstruction jailbreak from garak)

2 participants