Merged
Conversation
mbaluda
requested changes
Apr 2, 2026
Contributor
mbaluda
left a comment
There was a problem hiding this comment.
Please add test cases for the Anthropic models
yoff
previously approved these changes
Apr 7, 2026
Contributor
yoff
left a comment
There was a problem hiding this comment.
LGTM so far. I assume you will take it out of draft when you want a final review.
0208d67 to
25a8aa9
Compare
Contributor
Author
|
Apologies for letting this PR linger. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends Python prompt-injection modeling and tests to cover additional LLM SDK call patterns (OpenAI responses + chat.completions, and Anthropic messages APIs), ensuring the query flags user-controlled data flowing into these prompt construction sinks.
Changes:
- Added new OpenAI prompt-injection sinks for
chat.completions.create(messages[].content)andresponses.create(input/instructions). - Introduced Anthropic prompt-injection sink modeling (system prompts + message content) plus corresponding type modeling.
- Expanded the CWE-1427 PromptInjection query test suite and updated expected results accordingly.
Show a summary per file
| File | Description |
|---|---|
| python/ql/test/experimental/query-tests/Security/CWE-1427-PromptInjection/openai_test.py | Adds an additional alert annotation to validate responses.create(input=[...]) modeling. |
| python/ql/test/experimental/query-tests/Security/CWE-1427-PromptInjection/anthropic_test.py | New test coverage for Anthropic SDK prompt sinks (system, messages[].content) across sync/async/beta APIs. |
| python/ql/test/experimental/query-tests/Security/CWE-1427-PromptInjection/PromptInjection.expected | Updates expected results to include new Anthropic/OpenAI sink findings and paths. |
| python/ql/lib/semmle/python/frameworks/openai.model.yml | Adds OpenAI sink models for chat completions message content and responses API inputs/instructions. |
| python/ql/lib/semmle/python/frameworks/anthropic.model.yml | New Anthropic sink + type models to support prompt-injection detection. |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 0
mbaluda
approved these changes
Apr 29, 2026
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.
I have a few repos where I'd like the prompt injection to trigger, and I've verified that it at least finds new sources for these:
For more info on these repos, see:
https://github.com/dsp-testing/xpi-000