Skip to main content
The LLM Sandbox is a demo environment to test the functionality of HiddenLayer’s AI Runtime Security. This is available in the HiddenLayer Console. You can enable policy settings, then send prompts and see the results. There are some preconfigured test examples to help you get started. The LLM Sandbox can generate a policy configuration based on the settings you have enabled. With this generated policy configuration, you can copy it into your container settings or application code. For more information about how Runtime Security functions, see the Runtime Security Overview.
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.
  1. In the Console, go to Runtime Security > LLM Sandbox.
  2. Click OWASP Scenarios. A list of available OWASP examples displays.
    Select Example Scenario
  3. Select LLM01: Prompt Injection. A pre-defined prompt is entered.
  4. Click the analyze button (paper airplane icon).
    Analyze Prompt Injection
  5. 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.
  6. Click Detections to display more details about the detection.
    View Detections
  7. Click View Model, then click the Runtime Security tab to display a list of incidents for the Sandbox.
  8. 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.
    View Inference Information
  9. Go back to the LLM Sandbox, then click Advanced Policy Settings. The policy settings expand to display all of the policy settings.
    Advanced Policy Settings
  10. For the LLM Denial of Service policy setting, select Block Denial of Service.
    Block Denial of Service
  11. 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.
    OWASP LLM10 Results
  12. 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.
Custom Entity

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.
  1. In the LLM Sandbox, click Advanced Policy Settings.
  2. Enter the example Custom Entity Name.
  3. Enter the Custom Entity Pattern.
    Valid Python Regular ExpressionThe Custom Entity Pattern needs to be a valid Python Regular Expression.
  4. Type a prompt that includes one of the strings from the Custom Entity Pattern.
  5. Click Analyze to run the prompt.
  6. 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.
  7. 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.
  8. 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.
Example Custom Entity Name
Example Custom Entity Pattern
Example Prompt Submission
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

  1. On the LLM Sandbox page, make any changes you want to the Advanced Policy Settings for Prompt Policies and Output Policies.
  2. Under Policy Configuration, make sure Server is selected.
    Select Server for Policy Configuration
  3. Click Generate Policy Configuration. You can download or copy the server code. The downloaded file has a .env file extension.
    Generate Policy Configuration for Server
  4. Close the Policy Configuration Server Code window.
  5. Under Policy Configuration, select Client.
  6. Click Generate Policy Configuration. The client code is available in Python and JavaScript. You can download or copy the client code.
    Generate Policy Configuration for Client
  7. Close the Policy Configuration Client Code window.