User input is not concatenated directly into prompt strings
Why it matters
Direct concatenation of user input into system prompt strings is the root cause of most real-world prompt injection attacks, classified as OWASP LLM01:2025 and tracked under MITRE ATLAS AML.T0051. When a user message is spliced into the same string as your instructions, an attacker can craft input that terminates your instructions and appends new ones—overriding safety constraints, extracting the system prompt, or pivoting to unintended behavior. CWE-1427 captures this structural failure precisely: the trust boundary between instructions and data collapses when they share the same string. Any application handling sensitive user data, performing agentic actions, or operating in a regulated environment (NIST AI RMF MEASURE 2.6) is exposed to full instruction override through nothing more than a well-crafted chat message.
Severity rationale
Critical because successful injection via concatenation hands the attacker complete control over the model's instruction set, enabling immediate system prompt override, data exfiltration, or safety bypass without any additional exploit steps.
Remediation
Place user content exclusively in a role: "user" message object—never inside the system message string. The structural separation is the defense; delimiters and quoting inside a concatenated string are not sufficient because they can be escaped.
// Correct: role separation enforces the instruction/data boundary
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
{ role: "system", content: FIXED_SYSTEM_PROMPT },
{ role: "user", content: userMessage } // never concatenated into system
]
})
Audit every file that constructs AI messages (look for template literals referencing req.body, params, or session values inside system-role strings) and refactor each call site to use the two-message pattern. The parameterized-templates check in this audit verifies that prompt construction is centralized so this fix holds across the codebase.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the AI Prompt Injection Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-1427 — Improper Neutralization of Input Used in AI/ML Prompt Injection
- owasp-llm:2025 · LLM01 — Prompt Injection
- mitre-atlas:v4 · AML.T0051 — LLM Prompt Injection
- nist-ai-rmf:1.0 · MEASURE 2.6 — Evaluate AI system trustworthiness and risk posture
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ai-prompt-injection·automated