Repository navigation
FIX: Detect modern frontier chat template delimiters in StaticPromptInjectionScorer (#4041) - #4042
Merged
Roman Lutz (romanlutz) merged 4 commits intoNov 10, 2026
Conversation
Support U+2581 and space-separated sentence and tool tokens, including singular call/output boundaries and tool separators. Add isolated token and malformed-boundary regressions. Co-authored-by: Copilot App <[email protected]>
Roman Lutz (romanlutz)
approved these changes
Nov 9, 2026
Co-authored-by: Copilot App <[email protected]>
…-4041 Co-authored-by: Copilot App <[email protected]>
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
StaticPromptInjectionScorerdetects prompt injection attacks across several subcategories using static regex patterns. For chat template delimiter attacks,"Chat Template Injection"previously covered Llama 2, ChatML, Llama 3, Gemma, and Phi, but missed delimiters from several widely evaluated open-weights frontier model families:<|Thought|>), and tool call markers (<|tool calls begin|>,<|tool outputs begin|>), matching both fullwidth\uFF5Cand ASCII pipe|.<|START_OF_TURN_TOKEN|>,<|END_OF_TURN_TOKEN|>) and role headers (<|SYSTEM_TOKEN|>,<|USER_TOKEN|>,<|CHATBOT_TOKEN|>).[AVAILABLE_TOOLS],[TOOL_CALLS],[TOOL_RESULTS]).Key changes:
"Chat Template Injection"regex pattern inStaticPromptInjectionScorer._DEFAULT_PATTERNSto detect DeepSeek, Cohere Command R, and Mistral turn/tool delimiters.tests/unit/score/regex/test_static_prompt_injection_scorer.pycovering positive detections, lowercase variants, and attribution rationales."available tools"or"tool calls"do not trigger false positives.Closes #4041