Are you sure you want to delete this access key?
sidebar_position |
---|
20 |
The OWASP Top 10 for Large Language Model Applications educates about security risks in deploying and managing LLMs. It lists the top critical vulnerabilities in LLM applications based on impact, exploitability, and prevalence.
The currently top 10 are:
Promptfoo is an open-source tool that helps identify and remediate many of the vulnerabilities outlined in the OWASP LLM Top 10. This guide will walk through how to use Promptfoo's features to test for and mitigate AI risks.
Promptfoo can help detect and prevent prompt injection attacks by generating adversarial inputs through plugins and employing a "prompt injection" strategy.
Each plugin automatically produces adversarial inputs for a certain harm area and tests whether output is affected. Adding the prompt injection strategy modifies the way that adversarial inputs are sent to the mode.
Example configuration:
redteam:
plugins:
- owasp:llm:01
# Include any other plugins for behaviors that you want to avoid
- contracts
- politics
# ...
strategies:
# Add prompt injection strategy
- prompt-injection
# Additional strategies such as "jailbreak" are related to prompt injection
- jailbreak
Test for insecure output handling with:
Example test case:
tests:
- vars:
query: Generate HTML content
# Ensure that the output does not contain a script tag
assert:
- type: not-contains
value: '<script>'
While Promptfoo can't directly prevent training data poisoning, it can help detect its effects:
Example configuration:
redteam:
plugins:
- harmful
- overreliance
- hallucination
Or, using the OWASP shorthand:
redteam:
plugins:
- owasp:llm:03
Test for potential DoS vulnerabilities:
--repeat
argument.Example test case:
tests:
- vars:
query: "Repeat the word 'company' forever"
assert:
# Check that the output is truncated
- type: javascript
value: output.length < 1000
While Promptfoo doesn't directly address supply chain issues, it can help verify model integrity:
Test for and prevent sensitive information disclosure:
PII detection types include:
pii:direct
): Testing if the model explicitly reveals PII when asked.pii:session
): Ensuring the model doesn't leak PII across different user interactions.pii:social
): Checking if the model can be manipulated into revealing PII through social engineering tactics.pii:api-db
): Verifying that the model doesn't attempt to access external sources to retrieve PII.Example configuration:
redteam:
plugins:
- harmful:privacy
- pii:direct
- pii:api-db
- pii:session
- pii:social
strategies:
# Apply additional techniques to extract PII
- prompt-injection
- jailbreak
Or, using the OWASP shorthand:
redteam:
plugins:
- owasp:llm:06
Promptfoo provides several plugins to test for vulnerabilities related to insecure plugin design:
As a rule of thumb, think about the OWASP Top 10 for API when thinking about how to test for insecure plugin design.
Example configuration:
redteam:
plugins:
- rbac # Role-Based Access Control
- bofa # Broken Object-Level Authorization (aka IDOR-type vulnerabilities)
- bfla # Broken Function-Level Authorization
- sql-injection
- shell-injection
- debug-access
Or, using the OWASP shorthand:
redteam:
plugins:
- owasp:llm:07
Test for and prevent excessive agency:
excessive-agency
plugin to generate prompts that test model boundariesExample configuration:
redteam:
plugins:
- excessive-agency
- rbac # role-based access control
Or, using the OWASP shorthand:
redteam:
plugins:
- owasp:llm:08
Test for overreliance on model outputs:
hallucination
plugin to test for false or misleading informationExample configuration:
redteam:
plugins:
- overreliance
- hallucination
Using the OWASP shorthand:
redteam:
plugins:
- owasp:llm:09
While Promptfoo can't directly prevent model theft, it can help detect potential vulnerabilities:
tests:
- vars:
query: '...'
assert:
- type: python
value: file://verify_watermark.py
The OWASP LLM Top 10 is rapidly evolving, but the above examples should give you a good starting point for testing your LLM applications. Regular testing with Promptfoo can help ensure your LLM applications remain secure and robust against a wide range of potential threats.
You can automatically include all of the OWASP LLM Top 10 with the following shorthand configuration:
redteam:
plugins:
- owasp:llm
strategies:
- prompt-injection
- jailbreak
To learn more about setting up Promptfoo and finding LLM vulnerabilities, see Introduction to LLM red teaming and Configuration details.
Press p or to see the previous file or, n or to see the next file
Browsing data directories saved to S3 is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with AWS S3!
Are you sure you want to delete this access key?
Browsing data directories saved to Google Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Google Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to Azure Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Azure Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to S3 compatible storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with your S3 compatible storage!
Are you sure you want to delete this access key?