Skip to content

FIX Send the converted value from PromptShieldTarget - #3479

Open
Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
microsoft:mainfrom
ShivamSharma43:fix/prompt-shield-target-converted-value
Open

Shivam Sharma (ShivamSharma43) wants to merge 1 commit into
microsoft:mainfrom
ShivamSharma43:fix/prompt-shield-target-converted-value

Conversation

@ShivamSharma43

Copy link
Copy Markdown
Contributor

Description

Fixes #3478.

PromptShieldTarget._send_prompt_to_target_async parsed and sent request.original_value, the prompt from before any request converter ran. Every other target sends converted_value, so a converter applied through PromptNormalizer or 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:

  • PromptShieldTarget passes request.converted_value to _input_parser, so both userPrompt and documents come from the converted text.
  • The docstring says the converted text is parsed.

A piece with no converter has converted_value == original_value, so unconverted prompts are sent exactly as before. PromptShieldScorer is unaffected: it already puts the converted text into the piece it sends.

Tests and Documentation

  • New tests in tests/unit/prompt_target/target/test_prompt_shield_target.py:
    • send_prompt_async with a piece whose converted_value differs from original_value sends the parsed converted value, including its <document> part. A piece without a converted value still sends the original.
    • PromptNormalizer.send_prompt_async with a Base64Converter sends the Base64 text to Prompt Shield.
  • On main the 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 format and ty check pass on the changed files.
  • No documentation changes beyond the docstring.

🤖 Generated with Claude Code

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>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 11:22

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

BUG: PromptShieldTarget sends the prompt from before conversion, so request converters are ignored

2 participants