Early AccessThe LLM Sandbox is Early Access. Ask your HiddenLayer representative for more information.
Prompt Injection
The following steps will use the prompt injection example to help explain the LLM Sandbox features. You can try the other examples to become familiar with the policy configuration settings.- In the Console, go to Runtime Security > LLM Sandbox.
-
Click OWASP Scenarios. A list of available OWASP examples displays.

- Select LLM01: Prompt Injection. A pre-defined prompt is entered.
-
Click the analyze button (paper airplane icon).

-
The prompt is sent to Runtime Security to be analyzed.
-
The policy settings for Prompt and Output are set to Alert Only. Therefore:
- Runtime Security will send the prompt to the ML model
- The ML model will process the prompt and return the output to Runtime Security
- Runtime Security will send the output to the AI Security Platform
-
Latency data is provided. The Runtime Security Detection Latency is the amount of time for Runtime Security to process the request. The Upstream LLM Latency is the amount of time for the model to generate the response.
- If Runtime Security blocks the input, the latency could be zero.
Example PromptsFor demonstration purposes, the example prompts are unsafe and will trigger a detection. -
The policy settings for Prompt and Output are set to Alert Only. Therefore:
-
Click Detections to display more details about the detection.

- Click View Model, then click the Runtime Security tab to display a list of incidents for the Sandbox.
-
Click the green arrow to display inference information about the incident.
- The Incident Details contains overview information and short descriptions of the incident.
- The Inferences tab lists all of the events and their related detection category. Clicking the green arrow for an event displays an Interaction Details window.
- The MITRE ATLAS tab shows the tactics and techniques related to the incident.

-
Go back to the LLM Sandbox, then click Advanced Policy Settings. The policy settings expand to display all of the policy settings.

-
For the LLM Denial of Service policy setting, select Block Denial of Service.

-
Select OWASP Scenarios, select LLM10: Unbounded Consumption, then click the analyze button (paper airplane icon). With the policy set to Alert and Block for prompt injection, the unsafe prompt is not sent to the ML model.

- Click View Model to see the LLM Sandbox model artifacts.
Custom Entity
Using a Custom Entity, you can add data strings, like words or numbers, to prevent data leakage of personally identifiable information (PII). After creating a custom entity, Runtime Security can alert or alert and block this data. The LLM Sandbox allows you to create one custom entity. With your own Runtime Security instance, you can add multiple custom entities to your policy configuration. A custom entity pattern uses regular expressions (regex patterns). For more information about regular expressions, see this Python document. To test regex, check out regex101.Initial Prompt AnalysisThe first time a prompt is submitted that includes a custom entity pattern, the initial analysis may take longer than normal. Subsequent submissions including the same custom entity pattern will see expected response times.

Individual Data Strings
You can add individual data strings, like words or numbers, to the custom entity pattern and the LLM Sandbox will alert or block prompts with any of these data strings. Use the following example to try out the Custom Entity feature in the LLM Sandbox.- In the LLM Sandbox, click Advanced Policy Settings.
- Enter the example Custom Entity Name.
-
Enter the Custom Entity Pattern.
Valid Python Regular ExpressionThe Custom Entity Pattern needs to be a valid Python Regular Expression.
- Type a prompt that includes one of the strings from the Custom Entity Pattern.
- Click Analyze to run the prompt.
- Click View Detections to see what Runtime Security detected. In the image below, you will see the Custom Entity Name under Details. This lets you know what triggered the detection. Also in the example image below, there is a Prompt Injection. This is because the prompt used included a word that triggered Prompt Injection.
- By default, Redact PII is set to Don’t Redact. If you want to see the LLM Sandbox redact the prompt, set Redact PII to Redact. Redact PII is under Advanced Policy Settings.
- If you want to block any prompts that include the custom entity pattern, set Data Leakage to Alert and Block. Data Leakage is under Basic Policy Settings.
Custom Entity PatternThe custom entity pattern must be precise. Adding spaces, quotation marks, or other characters can cause unexpected results.
Policy Settings
The policy settings control what the LLM Sandbox does when you submit a prompt. This allows you to only get Alerts or to Alert and Block specific types of prompts.Alerts and Blocks
This applies to most policy settings.Basic Policy Settings
Prompt
The prompt that is sent to the ML Model.Output
The output from the ML Model based on the prompt.Advanced Policy Settings
Prompt Injection
LLM Denial of Service
Data Leakage
Redact output before sending to the caller.Custom Entities
For examples, see Custom Entity.Detection Category Severity
Language Detection
Supported Languages
Policy Configuration
Generates a.env file example that you can use.
Generate Policy Configuration
- On the LLM Sandbox page, make any changes you want to the Advanced Policy Settings for Prompt Policies and Output Policies.
-
Under Policy Configuration, make sure Server is selected.

-
Click Generate Policy Configuration. You can download or copy the server code. The downloaded file has a
.envfile extension.
- Close the Policy Configuration Server Code window.
- Under Policy Configuration, select Client.
-
Click Generate Policy Configuration. The client code is available in Python and JavaScript. You can download or copy the client code.

- Close the Policy Configuration Client Code window.

