Skip to content

[7.x] Add TaintedLlmPrompt issue type for prompt injection detection#11746

Merged
danog merged 8 commits intovimeo:masterfrom
alies-dev:add-tainted-llm-prompt-issue-type
Mar 26, 2026
Merged

[7.x] Add TaintedLlmPrompt issue type for prompt injection detection#11746
danog merged 8 commits intovimeo:masterfrom
alies-dev:add-tainted-llm-prompt-issue-type

Conversation

@alies-dev
Copy link
Copy Markdown
Contributor

@alies-dev alies-dev commented Mar 19, 2026

Adds a first-class TaintedLlmPrompt taint issue type for detecting prompt injection vulnerabilities — when user input flows unsanitized into LLM prompts (OWASP LLM01:2025).

Ref: psalm/psalm-plugin-laravel#484

Design decisions

  • Included in ALL_INPUT: LLM prompt injection is an input taint (user data → LLM), unlike USER_SECRET/SYSTEM_SECRET (sensitive data leaking out), so it belongs in ALL_INPUT.

Usage

/** @psalm-taint-sink llm_prompt $prompt */
function askLlm(string $prompt): string { /* ... */ }

askLlm($_GET['question']);                        // TaintedLlmPrompt
askLlm("Tell me about " . $_GET['topic']);        // TaintedLlmPrompt
askLlm("Summarize this document");                // OK

PS: once merged, it will be nice to release it (as new beta) ASAP, as I have some ideas for https://github.com/psalm/psalm-plugin-laravel to use it (the plugin already tagged as major 4.x and supports Psalm 7.x only)

alies-dev and others added 2 commits March 19, 2026 14:25
Add a first-class taint type for detecting when user input flows into
LLM prompts, enabling static detection of prompt injection vulnerabilities
(OWASP LLM01:2025).

Ref: psalm/psalm-plugin-laravel#484
@alies-dev alies-dev marked this pull request as draft March 19, 2026 13:30
@alies-dev alies-dev changed the title Add TaintedLlmPrompt issue type for prompt injection detection Add TaintedLlmPrompt issue type for prompt injection detection Mar 19, 2026
Fix DocumentationTest failures by adding the new issue type to config.xsd
and creating its documentation page.
@alies-dev alies-dev marked this pull request as ready for review March 19, 2026 13:49
Verify @psalm-taint-escape llm_prompt works and taint propagates
through intermediate function calls to LLM sinks.
alies-dev and others added 2 commits March 19, 2026 17:48
Place INPUT_LLM_PROMPT right after INPUT_EXTRACT and shift
USER_SECRET/SYSTEM_SECRET forward, so ALL_INPUT can use the
simple (1 << 17) - 1 formula.
@alies-dev alies-dev requested a review from danog March 19, 2026 20:24
alies-dev added a commit to psalm/psalm-plugin-laravel that referenced this pull request Mar 19, 2026
Detect LLM prompt injection and output injection vulnerabilities
in projects using laravel/ai v0.3.x (OWASP LLM01:2025).

Taint sources (LLM output is untrusted):
- TextResponse::$text via LlmOutputTaintHandler (property-level
  taint unsupported by Psalm annotations, handled programmatically)
- TextResponse::__toString() via stub annotation
- Tools\Request data access methods (string, integer, all, etc.)

Taint sinks (prompt injection detection):
- Promptable::prompt(), stream(), queue(), broadcast*()
- Laravel\Ai\agent() helper

Uses `html` as proxy taint type until vimeo/psalm#11746 merges
to add native TaintedLlmPrompt support.

Stubs in stubs/ai/0.3/ are loaded conditionally — only when
laravel/ai is installed and version matches major.minor.
@alies-dev alies-dev changed the title Add TaintedLlmPrompt issue type for prompt injection detection [7.x] Add TaintedLlmPrompt issue type for prompt injection detection Mar 21, 2026
@danog danog added the release:feature The PR will be included in 'Features' section of the release notes label Mar 26, 2026
@danog
Copy link
Copy Markdown
Collaborator

danog commented Mar 26, 2026

Thank you!

@danog danog merged commit 55bebb2 into vimeo:master Mar 26, 2026
56 of 61 checks passed
@alies-dev alies-dev deleted the add-tainted-llm-prompt-issue-type branch March 26, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:feature The PR will be included in 'Features' section of the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants