Skip to main content
This guide explains how to use TrueFoundry’s built-in Secrets Detection guardrail to protect sensitive credentials from being exposed in LLM interactions and MCP tool invocations.
Secrets Detection can be applied to all four guardrail hooks: LLM Input, LLM Output, MCP Pre Tool, and MCP Post Tool—providing comprehensive protection across your entire AI workflow.

What is Secrets Detection?

Secrets Detection is a built-in TrueFoundry guardrail that identifies and handles sensitive credentials and secrets in text content. It runs directly within the AI Gateway without requiring external API calls, providing fast and cost-effective secret detection.

Key Features

  1. Comprehensive Secret Recognition: Detects a wide range of sensitive credentials including:
    • AWS access keys and secret keys
    • API keys (OpenAI, Anthropic, Google, etc.)
    • JWT tokens and bearer tokens
    • Private keys (RSA, SSH, PGP)
    • Database connection strings
    • OAuth tokens and refresh tokens
    • Generic high-entropy strings that may be secrets
  2. Flexible Operation Modes:
    • Validate: Detect secrets and block requests/responses that contain them
    • Mutate: Detect secrets and redact them with configurable replacement text, allowing the request to continue
  3. Zero External Dependencies: Runs entirely within the AI Gateway with no external API calls, ensuring low latency and no additional costs.

Adding Secrets Detection Guardrail

To add Secrets Detection to your TrueFoundry setup, follow these steps:
1

Navigate to Guardrails

Go to the AI Gateway dashboard and navigate to the Guardrails section.
2

Create or Select a Guardrails Group

Create a new guardrails group or select an existing one where you want to add the Secrets Detection guardrail.
3

Add Secrets Detection Integration

Click on Add Guardrail and select Secrets Detection from the TrueFoundry Guardrails section.
TrueFoundry guardrail selection interface showing Secrets Detection option

Select Secrets Detection from TrueFoundry Guardrails

4

Configure the Guardrail

Fill in the configuration form:
  • Name: Enter a unique name for this guardrail configuration (e.g., secrets-detection)
  • Description: Optional description for this guardrail (default: “Detects likely credentials/secrets (AWS keys, API keys, JWT tokens, private keys)”)
  • Operation: Choose the operation mode:
    • validate: Detect and block requests containing secrets
    • mutate: Detect and redact secrets, allowing the request to continue
  • Redaction Text (for mutate mode): Text to replace detected secrets (default: ***REDACTED***)
5

Save the Configuration

Click Save to add the guardrail to your group.

Configuration Options

See Guardrails Overview for details on Operation Modes and Enforcing Strategy.

How It Works

Validate Mode

When configured in validate mode, the guardrail scans the content for secrets and blocks the request if any are detected. Example:

Mutate Mode

When configured in mutate mode, the guardrail scans the content for secrets and replaces them with the configured redaction text. Example:

Detected Secret Types

The Secrets Detection guardrail identifies a comprehensive set of secret patterns across multiple categories. Below is the complete list of detected secret types.

Cloud Provider Credentials

AI/ML Provider API Keys

Code Repository & Package Manager Tokens

Communication & Collaboration Platforms

Payment & E-Commerce

Database Connection Strings

Private Keys & Certificates

Authentication Tokens & Credentials

Other Services

Contextual Pattern Detection

In addition to specific patterns, Secrets Detection also identifies secrets based on contextual clues:
Contextual patterns help detect secrets that don’t follow a specific format but appear in contexts that suggest they are sensitive credentials.

Use Cases

Secrets Detection can be applied to any of the four guardrail hooks depending on your use case:

LLM Input Hook

Prevent users from accidentally sending sensitive credentials to LLMs:

LLM Output Hook

Ensure LLM responses don’t leak sensitive information:

MCP Tool Hooks

For maximum protection, apply Secrets Detection to all four hooks to catch secrets from user input, LLM output, and MCP tool results.

Best Practices

Use mutate mode to redact secrets while preserving request flow—useful for logging scenarios.
High-entropy strings (UUIDs, encoded data) may trigger false positives. Test with your specific data.