Skip to content

DRAFT: POC Decomposition Attack - #4817

Open
jbolor21 wants to merge 2 commits into
microsoft:mainfrom
jbolor21:jbolor/decomp_v2
Open

jbolor21 wants to merge 2 commits into
microsoft:mainfrom
jbolor21:jbolor/decomp_v2

Conversation

@jbolor21

@jbolor21 jbolor21 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

POC of decomposition attack - don't review yet :)
Attn Behnam (@behnam-o) for early implementation of design for Decomposition Attack

TODO
ran notebook for testing
used local visualization for result analysis and testing

Copilot AI balanced review requested due to automatic review settings December 3, 2026 02:53

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

Resumed decomposition runs can fail or execute changed requests because child requests are reloaded from mutable datasets rather than snapshotted when planning. Separately, the parent does not record supplied converters, so attacks using different converters receive identical identifiers and evaluation hashes, undermining result identity and resume checks.

9 open issues
What changed in this PR

Adds a proof-of-concept objective-decomposition workflow to PyRIT’s dataset, attack, and scenario components.

Changes:

  • Generates and stores objective decompositions as reusable datasets.
  • Executes steps separately, recombines responses, and compares results with direct and single-prompt controls.
  • Adds configurable prompts, scoring checks, public exports, and a tutorial.
File Description
pyrit/​scenario/​scenarios/​airt/​decomposition.py Adds the scenario and root-only dataset selection.
pyrit/​scenario/​scenarios/​airt/​__init__.py Exports decomposition scenario types.
pyrit/​models/​seeds/​objective_decomposition_config.py Defines generation configuration.
pyrit/​models/​seeds/​__init__.py Exports the configuration model.
pyrit/​models/​__init__.py Exposes configuration through the public API.
pyrit/​executor/​promptgen/​objective_decomposition_generator.py Generates and validates decomposition plans.
pyrit/​executor/​promptgen/​__init__.py Exports generation components.
pyrit/​executor/​attack/​compound/​recombiner.py Adds concatenation and model-assisted recombination.
pyrit/​executor/​attack/​compound/​decomposition_attack.py Executes and scores saved decompositions.
pyrit/​executor/​attack/​compound/​__init__.py Exports compound attack components.
pyrit/​executor/​attack/​__init__.py Exposes decomposition attack APIs.
pyrit/​datasets/​seed_datasets/​generated/​objective_decomposition_provider.py Packages generated plans as seed trees.
pyrit/​datasets/​seed_datasets/​generated/​__init__.py Exports the dataset provider.
pyrit/​datasets/​executors/​promptgen/​objective_decomposition_generator.yaml Defines planning instructions and response schema.
pyrit/​datasets/​executors/​decomposition/​steps_in_one_prompt.yaml Defines the single-prompt control.
pyrit/​datasets/​executors/​decomposition/​combine_system_prompt.yaml Defines recombination grounding rules.
pyrit/​datasets/​executors/​decomposition/​combine_prompt.yaml Templates recombination evidence.
pyrit/​datasets/​executors/​decomposition/​added_knowledge_question.yaml Defines the added-knowledge scoring rubric.
pyrit/​datasets/​__init__.py Exposes the provider publicly.
doc/​myst.yml Adds tutorial navigation.
doc/​code/​executor/​9_decomposition.py Adds the tutorial’s Python source.
doc/​code/​executor/​9_decomposition.ipynb Adds the notebook and example outputs.
doc/​code/​executor/​0_executor.md Links the tutorial from the executor guide.

Review effort: Balanced

params_type=DecompositionAttackParameters,
logger=logger,
)
self._scoring_config = attack_scoring_config

async def _perform_async(self, *, context: DecompositionAttackContext) -> DecompositionAttackResult:
assert context.params.root_objective_id is not None
tree = await self._load_decomposition_async(root_id=context.params.root_objective_id)
self._one_prompt_attack = PromptSendingAttack(
objective_target=objective_target,
attack_converter_config=attack_converter_config,
attack_scoring_config=AttackScoringConfig(objective_scorer=objective_scorer),
Comment on lines +388 to +391
if piece is not None and piece.is_blocked():
return DecompositionStepResult(
step=step, result=child, status=DecompositionStepStatus.BLOCKED, text=self.BLOCKED_MARKER
)
if self._added_knowledge_scorer is not None:
scores = await self._added_knowledge_scorer.score_text_async(answer, objective=replies)
if scores:
added = bool(scores[0].get_value())
context._error_result_metadata[self.CHILD_ATTACK_RESULT_IDS_KEY] = child_ids
execution = await AttackExecutor(max_concurrency=1).execute_attack_from_seed_groups_async(
attack=self._one_prompt_attack,
seed_groups=[seed_group],
Comment on lines +244 to +248
response = await self._normalizer.send_prompt_async(
message=Message.from_prompt(prompt=self._render(objective=objective, path=path), role="user"),
target=self._target,
conversation_id=conversation_id,
)
``max_total`` counts original objectives, each with all its steps.
"""

VERSION: int = 1
Raises:
ValueError: If the selected datasets hold no saved decompositions.
"""
roots = [group for group in context.seed_groups if is_decomposition_root(group.objective)]

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.

2 participants