Skip to content

JS Prompt Injection - Add some more sinks and reclassify legacy API#22012

Merged
BazookaMusic merged 2 commits into
mainfrom
bazookamusic/js-prompt-injection-sinks
Jun 19, 2026
Merged

JS Prompt Injection - Add some more sinks and reclassify legacy API#22012
BazookaMusic merged 2 commits into
mainfrom
bazookamusic/js-prompt-injection-sinks

Conversation

@BazookaMusic

Copy link
Copy Markdown
Contributor

As I was porting #21780 to python, I figured out I missed some models from legacy APIs and some newer methods since I first started working on it.

This PR completes the coverage.

It also removes a wrong classification:

  • ["openai.Client", "Member[completions].Member[create].Argument[0].Member[prompt]", "system-prompt-injection"]

This is the legacy API for calling an LLM and was used before the concept of using a system prompt. It is already classified as "user-prompt-injection" correctly.

Models covered

Framework API method Kind Legacy
OpenAI videos.create / edit / extend / remix user-prompt-injection No
OpenAI beta.realtime.sessions.create system-prompt-injection No
OpenAI completions.create (reclassified) user-prompt-injection Yes
Anthropic completions.create user-prompt-injection Yes
Google GenAI caches.create (config.systemInstruction) system-prompt-injection No
Google GenAI caches.create (config.contents) user-prompt-injection No

Add missing system/user prompt-injection sinks across the OpenAI,
Anthropic, and Google GenAI JavaScript models:

- OpenAI videos.create/edit/extend/remix prompts (user)
- OpenAI beta.realtime.sessions.create instructions (system)
- Anthropic legacy completions.create prompt (user)
- Google GenAI caches.create config.systemInstruction (system)
- Google GenAI caches.create config.contents (user)

Also reclassify the OpenAI legacy completions.create prompt from
system-prompt-injection to user-prompt-injection: the legacy
/v1/completions endpoint takes a single free-form prompt with no role
separation, so it is the text-in/text-out equivalent of a user message.

Note: videos.remix takes the prompt in Argument[1] (remix(videoID, body)),
and Google GenAI caches.create nests both contents and systemInstruction
under config, so the model entries differ slightly from a naive mapping.

Add corresponding test cases with inline annotations and regenerate the
.expected files.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BazookaMusic BazookaMusic marked this pull request as ready for review June 19, 2026 09:24
@BazookaMusic BazookaMusic requested a review from a team as a code owner June 19, 2026 09:24
Copilot AI review requested due to automatic review settings June 19, 2026 09:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the JavaScript prompt-injection threat models and corresponding tests for several AI SDKs, adding coverage for newly identified sink locations and correcting the classification of OpenAI’s legacy completions.create prompt field (system → user).

Changes:

  • Added new sink models for OpenAI videos (Sora) prompts and OpenAI beta.realtime.sessions.create instructions.
  • Added sink models for Anthropic legacy completions.create prompts and Google GenAI caches.create config.contents / config.systemInstruction.
  • Updated CWE-1427 system/user prompt-injection tests, expected outputs, and added a change note documenting the analysis-impacting changes.
Show a summary per file
File Description
javascript/ql/lib/ext/openai.model.yml Removes the legacy completions system-sink classification; adds OpenAI realtime instructions system sink and Sora video prompt user sinks.
javascript/ql/lib/ext/anthropic.model.yml Adds a user-prompt-injection sink for legacy completions.create prompt.
javascript/ql/lib/ext/google-genai.model.yml Adds caches.create sinks for both config.systemInstruction (system) and config.contents (user).
javascript/ql/lib/change-notes/2026-06-18-prompt-injection-sinks.md Documents the new sinks and the OpenAI legacy completions reclassification.
javascript/ql/test/Security/CWE-1427/UserPromptInjection/openai_user_test.js Adds Sora videos API user-prompt sink test cases.
javascript/ql/test/Security/CWE-1427/UserPromptInjection/gemini_user_test.js Adds Google GenAI caches.create user-prompt sink test case (config.contents).
javascript/ql/test/Security/CWE-1427/UserPromptInjection/anthropic_user_test.js Adds Anthropic legacy completions.create user-prompt sink test case.
javascript/ql/test/Security/CWE-1427/UserPromptInjection/UserPromptInjection.expected Updates expected results for the added/shifted user-prompt sink cases.
javascript/ql/test/Security/CWE-1427/SystemPromptInjection/openai_test.js Removes the legacy completions prompt system-sink expectation and adds realtime instructions system-sink test case.
javascript/ql/test/Security/CWE-1427/SystemPromptInjection/gemini_test.js Adds Google GenAI caches.create system-prompt sink test case (config.systemInstruction).
javascript/ql/test/Security/CWE-1427/SystemPromptInjection/SystemPromptInjection.expected Updates expected results for the added/shifted system-prompt sink cases.

Copilot's findings

  • Files reviewed: 11/11 changed files
  • Comments generated: 0

@asgerf asgerf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@BazookaMusic

Copy link
Copy Markdown
Contributor Author

DCA looks ok

@BazookaMusic BazookaMusic merged commit d86ec1a into main Jun 19, 2026
20 checks passed
@BazookaMusic BazookaMusic deleted the bazookamusic/js-prompt-injection-sinks branch June 19, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants