Skip to content

FIX: Accept only shipped template names in PersuasionConverter and ImagePromptStyleConverter - #4590

Open
varunj-msft wants to merge 1 commit into
microsoft:mainfrom
varunj-msft:varunj-msft/13178-Converter-Template-Names
Open

varunj-msft wants to merge 1 commit into
microsoft:mainfrom
varunj-msft:varunj-msft/13178-Converter-Template-Names

Conversation

@varunj-msft

Copy link
Copy Markdown
Contributor

Description

PersuasionConverter and ImagePromptStyleConverter join the name they're given onto their folder of shipped YAML files, so a name that's a full path or contains .. reads another YAML file on the machine running PyRIT. Through POST /api/converters that's a file on the server: PersuasionConverter sends the file's value as the system prompt to its converter target, which the caller chooses. It's the same kind of gap as LocalRefusalClassifierScorer.model_id on #4051, and saving converters (#4051) would keep such an entry across restarts.

  • persuasion_technique, filter_name, and ImagePromptStyleConverter.list_available_variations now accept only the names of the shipped files, checked before any path is built, as load_assert_judge_preset does. Any other name gets the same ValueError an unknown name got before.
  • A custom style file still goes in ImagePromptStyleConverter.filter_path, which Python code and initializers can set and the API refuses, as before.

Every documented technique and filter name works as before, and the converters' identifiers don't change.

…omptStyleConverter

Both joined the name they're given onto a folder of shipped YAML files, so an absolute path or one with
'..' read another YAML file on this machine: PersuasionConverter sent its value to the converter target
as the system prompt. A name now has to be one of the shipped files, as load_assert_judge_preset
requires. Custom style files still go in ImagePromptStyleConverter's filter_path.

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.

🟢 Approval recommended

No active review issues are recorded for the template-name path traversal hardening.

No open issues 🎉

What changed in this PR

Closes a template-name path traversal gap in PyRIT’s persuasion and image-style converters, including those created through the backend API.

Changes:

  • Restricts persuasion techniques, image filters, and variation lookups to shipped template names before constructing file paths.
  • Preserves explicit custom style loading through filter_path.
  • Adds regression tests for invalid names, traversal paths, absolute paths, and failed API creation without registration.
File Description
tests/​unit/​converter/​test_persuasion_converter.py Tests rejection of unknown techniques and path-based selectors.
tests/​unit/​converter/​test_image_prompt_style_converter.py Tests rejection of paths and non-filter templates.
tests/​unit/​backend/​test_converter_service.py Verifies rejected selectors leave no registered converter.
pyrit/​converter/​persuasion_converter.py Validates technique names against shipped YAML templates.
pyrit/​converter/​image_prompt_style_converter.py Validates built-in filter names in construction and variation lookup.

Review effort: Balanced

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.

3 participants