Skip to content
Back to log

OWASP LLM Top 10 risks and security controls

Chainabit's Chao · · 7 min read

In short

An overview of the risk categories in the OWASP LLM Top 10 and the security controls application developers can use for four of the risks.

The OWASP LLM Top 10 groups security risks in applications built with large language models into categories. The list covers a range of areas, from processing inputs given to the model to the disclosure of sensitive information, and from passing model outputs to other systems to the permissions granted to the model to perform actions.

Risk categories in the list

The first risk on the OWASP list is called Prompt Injection. This vulnerability arises when a prompt changes the model's behavior or output in an unintended way. The second category, Sensitive Information Disclosure, concerns the disclosure of sensitive information such as personal information, financial information, and confidential business data.

The third category, Supply Chain, covers how vulnerabilities in the LLM supply chain can affect the integrity of training data, models, and deployment. The fourth category, Data and Model Poisoning, describes the modification of pre-training, fine-tuning, or embedding data in ways that introduce vulnerabilities, backdoors, or bias.

The fifth category, Improper Output Handling, concerns insufficient validation and sanitization of LLM outputs before they are passed to other components or systems. The sixth category, Excessive Agency, refers to an LLM application's ability to perform harmful actions in response to unexpected or modified outputs.

The other categories on the list are called System Prompt Leakage, Vector and Embedding Weaknesses, Misinformation, and Unbounded Consumption. OWASP associates System Prompt Leakage with the risk of system prompts or instructions being disclosed, and Vector and Embedding Weaknesses with security risks in systems that use Retrieval Augmented Generation (RAG) with LLMs. Misinformation covers models producing incorrect information.

Prompt Injection: Input changing behavior

The OWASP Gen AI Security Project distinguishes two routes of input for Prompt Injection. In direct injection, the user's prompt input changes the model's behavior unexpectedly. This input may have been crafted by an attacker, or it may be input the user provided without realizing it.

In indirect injection, the model receives input from an external source, such as a website or file. When the model interprets instructions in this content, its behavior may change in an unintended way. The content does not need to be visible or readable to a human; it is enough for the model to process it.

In one of OWASP's examples, an attacker modifies a document in a repository used by a RAG application. When the user's query retrieves the modified content, malicious instructions in the document affect the model's output and misleading results are produced. In another example, an instruction embedded in an image changes the model's behavior when the image and text are processed together.

The impact of a successful injection depends on the application's business context and the scope of action given to the model. Possible consequences include the disclosure of sensitive information or system prompts, modification of outputs, unauthorized access to functions the model can access, and execution of commands in connected systems.

To reduce the impact, OWASP recommends specifying the model's role, capabilities, and limits in the system prompt. The expected output format can be clearly defined, and compliance with that format can be verified with deterministic code. Untrusted external content can also be separated from the user's prompt and clearly marked.

Permission control is another step. OWASP recommends that the application use its own API tokens for extended functions, that these functions be managed in code instead of being given to the model, and that the model's access be limited to the minimum necessary permissions. Human approval for privileged actions and regular attack testing to test trust boundaries are also among the recommendations.

Sensitive Information Disclosure: Disclosure of sensitive data

According to OWASP, sensitive information can include personally identifiable information (PII), financial details, health records, confidential business data, security credentials, and legal documents. LLM applications can disclose this information through their outputs. Possible consequences include unauthorized data access, privacy violations, and intellectual property infringement.

OWASP's explanation of sensitive information disclosure states that users may unintentionally provide sensitive information to the model and that this information may later appear in model output. In one of OWASP's example scenarios, insufficient data sanitization leads to a user receiving a response containing another user's personal data.

Turn this insight into action.

Use the mobile app to continue with guided workflows.

OWASP recommends applying data sanitization to prevent user data from entering the training model. This includes removing or masking sensitive content before it is used in training. Input validation can also be used to detect and filter potentially harmful or sensitive inputs.

In access controls, access to sensitive data is limited to what is necessary for the specific user or process. OWASP also recommends limiting the model's access to external data sources and securely managing data sanitization at runtime. Providing users with guidance on avoiding entering sensitive information is also among the recommended measures.

Providing clear policies on data storage, use, and deletion, and giving users the ability to opt out of having their data included in training, are also among OWASP's recommendations. Limiting the types of data that can be returned in the system prompt may help; however, OWASP states that these restrictions may not always be enforced and can be bypassed using methods such as Prompt Injection.

Improper Output Handling: Where output is used

OWASP defines the risk of Improper Output Handling as insufficient validation, sanitization, and handling of model output before it is passed to another component or system. Because content generated by the model can be influenced by prompt input, this can resemble giving users indirect access to additional functions.

In OWASP's examples, passing LLM output directly to a system shell can lead to remote code execution. JavaScript or Markdown generated by the model being interpreted by the browser can cause XSS. LLM-generated SQL queries executed without proper parameterization can lead to SQL injection.

Using output to construct a file path without sufficient sanitization can cause path traversal vulnerabilities. Content added to email templates without appropriate escaping can also lead to phishing attacks. OWASP lists a lack of appropriate output encoding for different contexts and insufficient input validation by third-party plugins among the conditions that increase the impact.

OWASP's output handling guidance recommends treating the model like any other user and applying input validation to model responses received by backend functions. Output encoding is performed according to the context in which it is used: OWASP gives HTML encoding for web content and SQL escaping for database queries as examples.

Using parameterized queries or prepared statements for database operations involving LLM output is also recommended. OWASP also recommends using Content Security Policy (CSP) to reduce the risk of XSS from LLM-generated content, and logging and monitoring to detect unusual output patterns.

Excessive Agency: Functionality, permissions, and autonomy

According to OWASP, an LLM system can call functions to perform actions in response to a prompt or interact with other systems through plugins. Excessive Agency refers to the possibility of harmful actions being performed in response to unexpected, ambiguous, or modified outputs from the model. OWASP groups the root causes as excessive functionality, excessive permissions, and excessive autonomy.

An example of excessive functionality is a plugin used to read documents that also includes functions for modifying and deleting documents. An example of excessive permissions is a plugin designed to read data connecting to a database with an identity that also has UPDATE, INSERT, and DELETE permissions. A high-impact deletion performed without user approval is an example of excessive autonomy.

OWASP recommends limiting the plugins made available to the model and the functions within those plugins to what is necessary. For example, if a plugin that summarizes emails only needs the ability to read them, it should not include functions for sending or deleting them. The permissions plugins have in other systems should also be limited to the minimum necessary.

Obtaining human approval before high-impact actions and enforcing authorization in the system where the action is performed, rather than leaving it to the model's decision, are also among OWASP's recommendations. All requests made to other systems through plugins should be validated against security policies.

Limits of the controls

OWASP states that it is unclear whether a fully reliable method exists for preventing Prompt Injection. Although RAG and fine-tuning aim to improve the relevance and accuracy of model outputs, they do not completely eliminate Prompt Injection vulnerabilities.

According to OWASP, logging and monitoring and limiting the frequency of actions for Excessive Agency help limit potential harm rather than prevent the risk. Monitoring aims to identify where unwanted actions are performed, while a limit on action frequency aims to reduce the number of unwanted actions that can be performed in a given period.

Ready to start?

Download the app and continue from your phone.

End of Entry