Skip to content

Commit c7d99a1

Browse files
authored
Merge branch 'knewbury01/add-prompt-injection-query-python' into prompt-injection
2 parents 4117252 + b4275e8 commit c7d99a1

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

python/ql/lib/semmle/python/Frameworks.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ private import semmle.python.frameworks.Multidict
5454
private import semmle.python.frameworks.Mysql
5555
private import semmle.python.frameworks.MySQLdb
5656
private import semmle.python.frameworks.Numpy
57+
private import semmle.python.frameworks.OpenAI
5758
private import semmle.python.frameworks.Opml
5859
private import semmle.python.frameworks.Oracledb
5960
private import semmle.python.frameworks.Pandas
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Provides classes modeling security-relevant aspects of the `openAI`Agents SDK package.
3+
* See https://github.com/openai/openai-agents-python.
4+
*/
5+
6+
private import python
7+
private import semmle.python.ApiGraphs
8+
9+
/**
10+
* Provides models for Agent (instances of the `agents.Agent` class).
11+
*
12+
* See https://github.com/openai/openai-agents-python.
13+
*/
14+
module Agent {
15+
/** Gets a reference to the `agents.Agent` class. */
16+
API::Node classRef() { result = API::moduleImport("agents").getMember("Agent") }
17+
18+
/** Gets a reference to a potential property of `agents.Agent` called instructions which refers to the system prompt. */
19+
API::Node sink() { result = classRef().getACall().getKeywordParameter("instructions") }
20+
}

python/ql/src/Security/CWE-1427/PromptInjection.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* @name Prompt injection
3+
* @description User input used in developer message and or system prompt can allow for Prompt Injection attacks.
34
* @kind path-problem
45
* @problem.severity error
56
* @security-severity 5.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
query: Security/CWE-1427/PromptInjection.ql
2-
postprocess: utils/test/InlineExpectationsTestQuery.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

0 commit comments

Comments
 (0)