Why it matters
Model output follows instructions planted in its input (prompt injection), so treat it as untrusted user input.
How to fix it
Never run model output as a command. Parse it into a fixed structure (JSON into a struct, an allow-list of actions), pass values to SQL as query arguments, and let html/template escape it instead of converting it to template.HTML.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
package fixture
import (
"context"
"os/exec"
"github.com/openai/openai-go"
)
func runSuggested(ctx context.Context, client openai.Client, task string) error {
resp, err := client.Chat.Completions.New(ctx, openai.ChatCompletionNewParams{
Model: openai.ChatModelGPT4oMini,
Messages: []openai.ChatCompletionMessageParamUnion{openai.UserMessage(task)},
})
if err != nil {
return err
}
return exec.Command("sh", "-c", resp.Choices[0].Message.Content).Run()
}package fixture
import (
"context"
"os/exec"
"github.com/openai/openai-go"
)
var allowed = map[string][]string{"status": {"git", "status"}}
func runSuggested(ctx context.Context, client openai.Client, task string) error {
resp, err := client.Chat.Completions.New(ctx, openai.ChatCompletionNewParams{
Model: openai.ChatModelGPT4oMini,
Messages: []openai.ChatCompletionMessageParamUnion{openai.UserMessage(task)},
})
if err != nil {
return err
}
_, ok := allowed[resp.Choices[0].Message.Content]
if !ok {
return nil
}
return exec.Command("git", "status").Run()
}What TrustIvan reads
Runs on repository scans of Go source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
- CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
- CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
- CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
- OWASP Top 10 for LLM Applications LLM05:2025 Improper Output Handling
- OWASP Top 10 A03:2021 - Injection
Related checks
- Ai sdk use (Go)
GoSeverity: Low
trustivan-go-ai-sdk-use - Llm prompt injection system from request input (Go)
GoSeverity: Medium
trustivan-go-taint-llm-prompt-injection-system - Template HTML non literal (Go)
GoSeverity: Medium
trustivan-go-template-html-non-literal - CSRF insecure cookie (Go)
GoSeverity: Medium
trustivan-go-csrf-insecure-cookie - JWT hardcoded secret (Go)
GoSeverity: High
trustivan-go-jwt-hardcoded-secret - CORS wildcard credentials (Go)
GoSeverity: High
trustivan-go-cors-wildcard-credentials
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation