AI and LLM security

Direct prompt injection against AI applications

Instruction boundary: document, gate, model arranged to illustrate direct prompt injection against ai applications.

Prompt injection occurs when untrusted instructions influence an AI system beyond their intended authority. Understanding direct prompt injection against AI applications helps establish which security property the feature needs and where that property is actually enforced.

What does this involve?

An AI model can interpret instructions within information that the application intended to treat as data. The critical security boundary is the surrounding system: which private information it supplies and which actions it allows model-directed output to trigger.

LLM models are continuously evolving, as are the techniques used to prevent prompt injection attacks (such as prompt tuning, model finetuning, guardrails, multi-agent architectures, etc.). Consequently, many of the techniques described may become ineffective over time, or may only work against certain types of LLMs or in specific contexts.

A list of currently employed prompt injection payloads will be provided, which should be used as building blocks to develop custom attack vectors tailored to the specific verification scenario. Prompt injection techniques will make use of such payloads as building block to assess the security of a specific target LLM.

Why it matters

Consider a realistic failure: a user asks a customer assistant to ignore its task and invoke an unrelated privileged operation.

A strange response becomes a security issue when it discloses protected information, changes an authorised task or causes an unintended operation. The assessment should distinguish those consequences from cosmetic changes to the model's answer.

AI testing needs recorded model and application conditions because outputs can vary. The important evidence is the protected information, decision or tool operation affected in the deployed workflow.

How penetration testers check for it

Assess resulting data access and actions rather than judging success only by the model's wording.

  • Malicious intent. The instructions must conflict with the AI’s original system constraints. This is what makes it an attack.
  • Model fine-tuning: model fine-tuning is the process of further training a pre-trained Large Language Model (LLM) on a specific dataset to adapt its behaviour to a particular task or domain. Fine-tuning involves updating some or all of the model’s weights and can be executed also to enforce security or safety constraints.
  • Guardrails: in the context of Large Language Models, a guardrail refers to mechanisms implemented to guide and restrict the model’s output, usually to ensure it behaves safely and within desired operational boundaries. Guardrails usually try to prevent the generation of harmful, biased, or undesired content.
  • Available tools: in the context of Large Language Models, tools refer to external software components, APIs, or modules that the model can interact with or invoke to extend its capabilities beyond text generation. These tools can include databases, calculators and web browsers, but also scripts and system shells.
  • Repeat representative cases under recorded conditions.
  • Verify actual data access and consequential actions.

How to fix it

Keep model output outside trusted authority and enforce tool and data permissions independently.

  • Keep security decisions in trusted application controls.
  • Limit model context and tool permissions to the task.
  • Treat generated output as untrusted input to downstream systems.
  • Maintain regression cases for important trust boundaries.

No prompt wording can establish an absolute instruction boundary for every possible input. Layered application controls are needed so a model failure does not automatically become a protected action.

Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.

Read about our methodology or contact pentested.com to discuss your AI applications and agent workflows.

See your first test report this week.

Book a 30 minute demo. We will verify one of your targets with you and run a test against it, so you can judge the results on your own systems.

Book a demo