Repository navigation
FIX: Accept only shipped template names in PersuasionConverter and ImagePromptStyleConverter - #4590
Open
varunj-msft wants to merge 1 commit into
Open
varunj-msft wants to merge 1 commit into
varunj-msft wants to merge 1 commit into
Conversation
…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.
Contributor
There was a problem hiding this comment.
🟢 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
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.
Description
PersuasionConverterandImagePromptStyleConverterjoin 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. ThroughPOST /api/convertersthat's a file on the server:PersuasionConvertersends the file'svalueas the system prompt to its converter target, which the caller chooses. It's the same kind of gap asLocalRefusalClassifierScorer.model_idon #4051, and saving converters (#4051) would keep such an entry across restarts.persuasion_technique,filter_name, andImagePromptStyleConverter.list_available_variationsnow accept only the names of the shipped files, checked before any path is built, asload_assert_judge_presetdoes. Any other name gets the sameValueErroran unknown name got before.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.