keepcalculator

06 Numbers and Powers

LLM Security: The Full Attack Surface Explained

Card No. 06·50312 · Updated · Standard formula, shown below

LLM security extends well beyond prompt injection: it includes the model, its training and data, the application around it, connected tools, and the people and systems that operate it. Prompt injection is one important threat, but a secure deployment needs controls across the full path from input to output and any action the system can take.

What the LLM attack surface includes

An LLM application is usually more than a model answering a message. It may combine a chat interface, application code, system instructions, retrieval from documents, user accounts, databases, and tools such as search or email. Each component introduces different risks. A weakness in the model may produce unsafe text; a weakness in the surrounding application may expose private records or perform an unintended action.

It helps to distinguish the model from the system using it. A model can generate a harmful or misleading response, but whether that response becomes a security incident often depends on what data it can access, what the application trusts, and what actions it is authorized to perform.

  • Inputs: user messages, uploaded files, retrieved documents, and data supplied by external services.
  • Model and instructions: the model’s learned behavior, system prompts, and any fine-tuning or configuration.
  • Application and integrations: code that assembles context, manages sessions, calls tools, and handles responses.
  • Outputs and operations: generated text, database queries, messages, code, or other actions triggered by the application.
  • People and infrastructure: developers, operators, access controls, logging, deployment settings, and third-party providers.

Prompt injection and untrusted content

Prompt injection occurs when text supplied to an LLM attempts to override or manipulate its intended instructions. It can arrive directly in a user message or indirectly through a web page, email, uploaded document, or search result that the application retrieves. For example, a document might contain text telling the assistant to reveal confidential context or to ignore its normal task.

The key difficulty is that models process instructions and ordinary content as language, and may not reliably treat a boundary described in a prompt as a security boundary. Labeling a document “untrusted” or telling the model to ignore hostile instructions can help guide behavior, but it is not a dependable substitute for access controls and application-level checks.

Prompt injection is also not the same as a conventional software exploit. It may manipulate model behavior without exploiting a memory-safety flaw or bypassing a login. The consequences become more serious when the model has access to sensitive information or tools. A read-only assistant that summarizes public pages has a different risk profile from one that can send mail or modify records.

Data exposure, privacy, and retrieval

LLM systems can reveal information through more than a direct request to “show the secret.” Sensitive data might enter a prompt through conversation history, retrieved documents, logs, analytics, or a tool response. If authorization is missing or applied only after retrieval, a user may receive material they should not be able to access.

Retrieval-augmented generation (RAG) searches a collection of documents and gives selected passages to a model to support its answer. It does not automatically enforce document permissions. A sound design checks that the requester may access each source before placing its content in the model’s context, and preserves those permissions when documents are indexed, updated, and deleted.

  • Keep secrets, credentials, and unnecessary personal data out of prompts and model context.
  • Apply authorization in trusted application code, not by asking the model whether a user is allowed.
  • Limit retention of prompts and outputs, and protect logs because they can contain sensitive content.
  • Test retrieval with users who have different permissions, including attempts to infer restricted information.

Tools, permissions, and consequential actions

When an LLM can call tools, the application creates an action surface. Tools may read files, query services, create tickets, execute code, or send communications. A model-generated tool request should be treated as an untrusted proposal, not as proof that an action is appropriate.

Use least privilege: give each tool only the access it needs, and separate read operations from changes where practical. Validate arguments against a strict schema, check the user’s authorization in application code, and require confirmation for consequential or difficult-to-reverse actions. For instance, an assistant may draft an email automatically, while sending it requires a person’s approval.

Tool design also matters. A generic tool that accepts arbitrary commands is harder to constrain than a narrow function with a small set of validated inputs. Rate limits, audit trails, timeouts, and clear failure handling can reduce the impact of mistakes or abuse. These measures do not make model decisions infallible; they limit what a wrong decision can do.

Other risks beyond prompt injection

Security reviews should account for threats that do not depend on an attacker changing the prompt. Training data can be poisoned, model behavior can be manipulated through fine-tuning, and exposed model endpoints can be abused for resource consumption or automated probing. Supply-chain risks may arise from third-party models, libraries, plugins, datasets, and hosted services.

Generated content creates another category of risk. An answer may be inaccurate, fabricated, biased, or unsafe to use as code or operational guidance. That is not always a security vulnerability, but it can become one when a system treats generated text as trusted input—for example, executing a generated query without validation or rendering untrusted output in a way that creates a conventional web vulnerability.

Abuse can also target availability and cost: repeated or unusually large requests may consume compute, exhaust quotas, or degrade service. Rate limiting, usage monitoring, input-size limits, and sensible resource budgets help address these operational threats. No single filter covers all of these categories.

Building and testing layered defenses

Start by mapping what the system can see and do. Identify data sources, user roles, model providers, tool calls, storage, and downstream systems. Then consider misuse cases: a user seeking another person’s records, hostile instructions embedded in a retrieved page, or a model producing a tool call with an invalid target.

  1. Reduce access: minimize sensitive context and give tools narrowly scoped permissions.
  2. Enforce boundaries in code: authenticate users, authorize each data access, validate inputs, and check proposed actions outside the model.
  3. Handle outputs cautiously: encode or validate generated content for its destination; never assume fluent text is correct or safe to execute.
  4. Test realistic attack paths: include direct and indirect prompt injection, data-access boundaries, malformed tool arguments, and repeated requests.
  5. Monitor and respond: record security-relevant events with appropriate privacy protections, define escalation procedures, and reassess after changes.

Testing should include the whole application, not just a model’s responses to a list of adversarial prompts. A prompt filter may block some attempts but can miss paraphrases or new attack patterns. Conversely, a model may produce an unsafe suggestion that causes no harm because the application correctly denies the action. Evaluate both behavior and enforcement.

Frequently Asked Questions

Is prompt injection the same as jailbreaks?
They overlap but are not identical terms. A jailbreak commonly describes an attempt to get a model to disregard restrictions through its instructions or conversation. Prompt injection also covers hostile instructions embedded in external content that a system retrieves or processes.

Can a system prompt prevent data leaks?
No. Instructions can influence responses, but they are not an access-control mechanism. Restrict data before it reaches the model, enforce permissions in application code, and limit what the model and its tools can access.

Does using RAG make an LLM more secure?
Not by itself. RAG can ground answers in selected sources, but it can also introduce sensitive or malicious content. Permission checks, source management, and defenses against untrusted retrieved instructions remain necessary.

Should an LLM be allowed to use tools?
That depends on the task and the consequences of mistakes. If tools are needed, constrain their permissions and inputs, check authorization independently, and add human confirmation for consequential actions.

How should an organization begin an LLM security review?
Map data flows, user permissions, model providers, and available tools. Identify sensitive information and consequential actions, then test realistic misuse scenarios and verify that controls outside the model prevent unauthorized access or changes.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →