Skip to content

Actions: Add experimental queries for AI output validation CWE 1426#21678

Draft
data-douser wants to merge 2 commits intogithub:mainfrom
data-douser:codeql-actions-scs/cwe-1426
Draft

Actions: Add experimental queries for AI output validation CWE 1426#21678
data-douser wants to merge 2 commits intogithub:mainfrom
data-douser:codeql-actions-scs/cwe-1426

Conversation

@data-douser
Copy link
Copy Markdown
Contributor

Actions: Add experimental CWE-1426 improper AI output validation query

Description

Adds detection for improper validation of AI-generated output (CWE-1426) in GitHub Actions workflows where AI action output flows unsanitized into code execution sinks (run steps, subsequent AI prompts).

This is the complementary query to CWE-1427 (prompt injection). While CWE-1427 detects user-controlled data flowing into AI prompts, CWE-1426 detects AI-generated output flowing out of AI actions into executable contexts — enabling chained injection attacks where a successful prompt injection produces malicious AI output that executes as code in subsequent workflow steps.

New query

Query ID Severity Description
actions/improper-ai-output-handling/critical 9.0 (error) AI-generated output from inference actions flowing unsanitized to run: steps, MaD-defined code-injection sinks, or subsequent AI prompts in privileged contexts

New library and MaD models

  • ImproperValidationOfAiOutputQuery.qll: Defines AiInferenceOutputSource (identifies AI action step outputs via MaD ai-inference kind), ImproperAiOutputSink (run steps, code-injection sinks, AI inference sinks), and taint-tracking configuration.
  • ai_inference_actions.model.yml: 15 actionsSinkModel entries with kind ai-inference covering GitHub official (actions/ai-inference, github/ai-moderator), Anthropic (anthropics/claude-code-action), Google (google-github-actions/run-gemini-cli, google/gemini-code-assist-action), OpenAI, Warp, and community AI actions.

Variant analysis results

Validated through MRVA across 479 CodeQL actions databases and local analysis on 18 databases:

  • True positives confirmed on real-world repositories with AI action output flowing to run steps (e.g. anthropics/claude-code-action output interpolated into shell commands)
  • 0 false positives observed — safe patterns (AI output used only for comments, hardcoded prompts) correctly excluded

Test coverage

  • 6 test workflow fixtures: 4 vulnerable (AI output to shell execution, AI output chaining to second AI prompt, Claude output to run step, Gemini output piped to patch) and 2 safe (hardcoded prompt with no output use, AI output used only in github-script comment)
  • All tests passing

References

Add detection for improper validation of AI-generated output (CWE-1426)
in GitHub Actions workflows where AI action output flows unsanitized to
code execution sinks.

New query:
- ImproperValidationOfAiOutputCritical.ql: Detects AI-generated output
  flowing to run steps or subsequent AI prompts in privileged contexts
  (severity 9.0)

New library:
- ImproperValidationOfAiOutputQuery.qll: Taint tracking from AI action
  output references to code execution and AI inference sinks

MaD model (ai_inference_actions.model.yml):
- 15 AI actions identified as AI inference sources whose outputs should
  be treated as untrusted
@github-actions github-actions bot added documentation Actions Analysis of GitHub Actions labels Apr 9, 2026
@@ -0,0 +1 @@
experimental/Security/CWE-1426/ImproperValidationOfAiOutputCritical.ql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Actions Analysis of GitHub Actions documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants