Repository navigation
FIX Send the converted value from PromptShieldTarget - #3479
Open
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
Open
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
Conversation
PromptShieldTarget parsed and sent request.original_value, the prompt from before any request converter ran, so converters applied through the PromptNormalizer or an attack were silently ignored. It now sends converted_value like every other target. Fixes microsoft#3478 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Fixes #3478.
PromptShieldTarget._send_prompt_to_target_asyncparsed and sentrequest.original_value, the prompt from before any request converter ran. Every other target sendsconverted_value, so a converter applied throughPromptNormalizeror an attack was silently ignored: testing whether Prompt Shield catches a Base64 or leetspeak variant of an injection sent the plain original prompt instead. The<document>split was also done on the unconverted text.#3100 fixed the same problem in
PromptShieldScorer. This is the matching change in the target.Changes:
PromptShieldTargetpassesrequest.converted_valueto_input_parser, so bothuserPromptanddocumentscome from the converted text.A piece with no converter has
converted_value == original_value, so unconverted prompts are sent exactly as before.PromptShieldScoreris unaffected: it already puts the converted text into the piece it sends.Tests and Documentation
tests/unit/prompt_target/target/test_prompt_shield_target.py:send_prompt_asyncwith a piece whoseconverted_valuediffers fromoriginal_valuesends the parsed converted value, including its<document>part. A piece without a converted value still sends the original.PromptNormalizer.send_prompt_asyncwith aBase64Convertersends the Base64 text to Prompt Shield.mainthe two converted-value cases fail (the original prompt is sent); with this change they pass. The unconverted case passes on both.pytest tests/unit/prompt_target tests/unit/score: 6380 passed, 369 skipped.ruff check,ruff formatandty checkpass on the changed files.🤖 Generated with Claude Code