Join our Newsletter — 33% off our NHI Course
Home› FAQ› AI Security› What is the difference between prompt injection and…
AI Security

What is the difference between prompt injection and token expansion attacks in LLM security?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated November 2, 2026 Domain: AI Security

Prompt injection is an attempt to manipulate the model into ignoring its intended instructions and following attacker-controlled ones. Token expansion is different because the attacker abuses how certain Unicode inputs expand during processing, causing excessive or hidden content to consume resources. Both matter, but one targets behaviour while the other targets processing overhead.

How prompt injection differs from token expansion attacks

Prompt injection is a control problem: the attacker tries to override the model’s intended instructions and steer behaviour. Token expansion is a processing problem: the attacker supplies text that expands during normalisation or tokenisation so the system spends more resources than expected, or hides excessive content in the input path. The first targets decision-making, the second targets consumption and handling.

That distinction matters because the defensive question changes. Prompt injection is about instruction hierarchy, tool access, and whether untrusted text can influence model actions. Token expansion is about how input is parsed, counted, limited, and sanitised before it reaches the model. A system can be resilient to one and still fail badly on the other.

For LLM teams, the two should be treated as different abuse classes rather than variants of the same issue. Prompt injection is usually judged by whether the model follows malicious instructions or leaks context. Token expansion is usually judged by whether the input causes disproportionate cost, latency, truncation, or hidden content effects that undermine filtering and quota enforcement.

Where the attack surface is different

Prompt injection usually enters through user prompts, retrieved documents, web content, email-like content, or any other untrusted text the model can read. The attacker wants the model to treat that text as higher priority than the system’s own instructions. In practical terms, the abuse shows up when the model follows a hostile instruction, reveals hidden context, or takes an unauthorised action.

Token expansion attacks exploit the preprocessing path instead. The weakness is not that the model is persuaded, but that the content is transformed in a way that increases apparent length, masks the true payload, or burns through processing budgets. Defences need to focus on canonicalisation, Unicode handling, token counting, and input limits before the model ever sees the content.

One useful way to separate them is to ask whether the attacker needs the model to obey them. If yes, you are looking at prompt injection. If the attacker mainly needs the system to misread, overcount, or overprocess the input, you are dealing with token expansion behaviour.

Why both still matter in production

Prompt injection can turn a harmless looking input into data exposure, policy bypass, or unsafe tool use, especially in systems that let the model act on behalf of a user. Token expansion can degrade availability, inflate spend, and create blind spots in filtering or truncation logic. Both are security issues, but they sit at different layers of the stack and require different evidence when you assess them.

They also interact. A maliciously expanded input can make review harder, hide injected instructions inside long or awkwardly normalised text, or push important parts of the prompt beyond the model’s effective attention window. That means a system may need both instruction-safety controls and input-processing controls to be robust.

For a broader view of LLM attack patterns, the LLM Security Guide is a useful starting point, while the Top 10 LLM Deployment Mistakes page covers recurring failure modes such as prompt injection and excessive consumption.

Risk and Threat Considerations

Prompt injection creates integrity risk because the model may follow attacker-controlled instructions instead of the system’s intended policy. Token expansion creates availability and cost risk because malformed or adversarial input can force excessive processing, bypass practical limits, or obscure malicious content inside transformed text.

Failure mechanism: Prompt injection succeeds when untrusted content is given influence over instruction hierarchy or tool execution. Token expansion succeeds when normalisation, Unicode handling, or token counting allows the attacker to change how much content the system believes it is processing.

Impact: Prompt injection can cause disclosure, unsafe actions, or policy bypass. Token expansion can cause denial of service, cost blowouts, truncation errors, and weaker downstream inspection because the system no longer sees the input as the operator expected.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10 and MITRE ATT&CK address the attack and risk surface, while OWASP ASVS, NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP ASVSV4 — API and Web ServiceLLM inputs and outputs need request handling and validation discipline.
Recommendation — Validate untrusted input before it reaches model-facing services.
NIST SP 800-53 Rev 5SI-10 — Information Input ValidationBoth attack classes rely on weak handling of untrusted input.
SC-18 — Mobile CodeAdversarial text can carry executable intent through interpreted content paths.
Recommendation — Enforce strict validation and canonicalisation on model inputs. Constrain interpreted content paths that can alter system behaviour.
CIS Controls v816 — Application Software SecurityLLM applications need secure handling of inputs, limits, and unsafe behaviours.
Recommendation — Build explicit abuse testing for prompt and input-processing failures.
OWASP Agentic AI Top 10ASI01 — Agent Goal HijackPrompt injection is a direct route to steering agent behaviour away from intent.
Recommendation — Separate trusted instructions from untrusted text in agent workflows.
MITRE ATT&CKT1059 — Command and Scripting InterpreterPrompt manipulation often aims to induce execution-like behaviour through interpreted content.
Recommendation — Monitor for content paths that induce unintended execution or action.

Practitioner Guidance

What to verify: Test prompt injection resistance and token expansion behaviour separately. A model that refuses malicious instructions may still be vulnerable to resource abuse, and a well-sized input limit may still allow instruction override through retrieved or embedded text.

Decision rule: If the concern is model obedience, prioritise prompt isolation, instruction hierarchy, and tool-use boundaries. If the concern is input inflation or hidden content, prioritise canonicalisation, Unicode normalisation, strict length enforcement, and consistent token accounting before inference.

What good looks like: Untrusted text cannot override system instructions, and transformed input cannot evade size controls or create unexpected processing cost. The safest systems treat the two abuse paths as separate test cases, not as one generic “LLM prompt problem”.

Practitioner takeaway: The practical difference is operational, not just semantic: prompt injection changes what the model is told to do, while token expansion changes how the system processes what it receives.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 2, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org