Files
codeql/python/ql/lib/semmle/python/frameworks/langchain.model.yml
Sotiris Dragonas db493ef30a Python: port prompt injection queries (system + user) from JS PR #21953
Replace the experimental py/prompt-injection query with two queries mirroring
the JavaScript split:
- py/system-prompt-injection (system prompt / tool description / developer prompt)
- py/user-prompt-injection (user-role prompt)

Supports OpenAI (+Agents), Anthropic, Google GenAI, LangChain and OpenRouter
via MaD models plus role-filtered framework sinks that MaD cannot express.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-18 13:52:51 +03:00

32 lines
2.0 KiB
YAML

extensions:
- addsTo:
pack: codeql/python-all
extensible: sinkModel
data:
# Message constructors. The first positional argument or the `content` keyword
# carries the message text.
- ['langchain_core.messages', 'Member[SystemMessage].Argument[0]', 'system-prompt-injection']
- ['langchain_core.messages', 'Member[SystemMessage].Argument[content:]', 'system-prompt-injection']
- ['langchain.schema', 'Member[SystemMessage].Argument[0]', 'system-prompt-injection']
- ['langchain.schema', 'Member[SystemMessage].Argument[content:]', 'system-prompt-injection']
- ['langchain_core.messages', 'Member[HumanMessage].Argument[0]', 'user-prompt-injection']
- ['langchain_core.messages', 'Member[HumanMessage].Argument[content:]', 'user-prompt-injection']
- ['langchain.schema', 'Member[HumanMessage].Argument[0]', 'user-prompt-injection']
- ['langchain.schema', 'Member[HumanMessage].Argument[content:]', 'user-prompt-injection']
# Invoking a chat model with user input.
- ['LangChainChatModel', 'Member[invoke,stream,predict,call].Argument[0]', 'user-prompt-injection']
- ['LangChainChatModel', 'Member[batch].Argument[0].ListElement', 'user-prompt-injection']
- addsTo:
pack: codeql/python-all
extensible: typeModel
data:
- ['LangChainChatModel', 'langchain_openai', 'Member[ChatOpenAI,AzureChatOpenAI].ReturnValue']
- ['LangChainChatModel', 'langchain_anthropic', 'Member[ChatAnthropic].ReturnValue']
- ['LangChainChatModel', 'langchain_google_genai', 'Member[ChatGoogleGenerativeAI].ReturnValue']
- ['LangChainChatModel', 'langchain_mistralai', 'Member[ChatMistralAI].ReturnValue']
- ['LangChainChatModel', 'langchain_groq', 'Member[ChatGroq].ReturnValue']
- ['LangChainChatModel', 'langchain_cohere', 'Member[ChatCohere].ReturnValue']
- ['LangChainChatModel', 'langchain_ollama', 'Member[ChatOllama].ReturnValue']
- ['LangChainChatModel', 'langchain_aws', 'Member[ChatBedrock,ChatBedrockConverse].ReturnValue']