mirror of
https://github.com/github/codeql.git
synced 2026-06-29 16:47:09 +02:00
This pull request introduces a new CodeQL query for detecting prompt injection vulnerabilities in Python code targeting AI prompting APIs such as agents and openai. The changes includes a new experimental query, new taint flow and type models, a customizable dataflow configuration, documentation, and comprehensive test coverage.
21 lines
605 B
Plaintext
21 lines
605 B
Plaintext
/**
|
|
* @name Prompt injection
|
|
* @kind path-problem
|
|
* @problem.severity error
|
|
* @security-severity 5.0
|
|
* @precision high
|
|
* @id py/prompt-injection
|
|
* @tags security
|
|
* experimental
|
|
* external/cwe/cwe-1427
|
|
*/
|
|
|
|
import python
|
|
import experimental.semmle.python.security.dataflow.PromptInjectionQuery
|
|
import PromptInjectionFlow::PathGraph
|
|
|
|
from PromptInjectionFlow::PathNode source, PromptInjectionFlow::PathNode sink
|
|
where PromptInjectionFlow::flowPath(source, sink)
|
|
select sink.getNode(), source, sink, "This prompt construction depends on a $@.", source.getNode(),
|
|
"user-provided value"
|