> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.lakera.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.lakera.ai/_mcp/server.

# Integrating Red with AI Guardrails

Check Point AI Red Teaming and Check Point AI Guardrails work together to provide comprehensive AI security. Red identifies vulnerabilities through offensive testing, while AI Guardrails provides continuous real-time protection. This guide explains how to use Red findings to optimize your AI Guardrails deployment.

## The Red and AI Guardrails Security Lifecycle

```
┌─────────────────────────┐
│   AI Red Teaming        │ ─── Identify vulnerabilities through scanning
└────────┬────────────────┘
         │
         ▼
┌─────────────────────────┐
│        Analyze          │ ─── Review findings and understand attack patterns
└────────┬────────────────┘
         │
         ▼
┌─────────────────────────┐
│ Configure AI Guardrails │ ─── Set policies based on Red findings
└────────┬────────────────┘
         │
         ▼
┌─────────────────────────┐
│        Monitor          │ ─── Detect attacks in production
└────────┬────────────────┘
         │
         └──────────────► Repeat periodically
```

## Mapping Red Findings to AI Guardrails Defenses

### Security Category → Prompt Defense

If Red found vulnerabilities in the **Security** category (instruction override, prompt extraction, etc.):

1. Enable **Prompt Defense** in your AI Guardrails policy
2. Set threshold based on finding severity:
   * Critical/High findings → L4 (Paranoid)
   * Medium findings → L3 (Strict)
   * Low findings → L2 (Balanced)

```python
import requests
import os

def screen_with_guard(user_input: str) -> bool:
    """Screen user input with AI Guardrails before sending to LLM."""
    response = requests.post(
        "https://api.lakera.ai/v2/guard",
        json={
            "messages": [{"content": user_input, "role": "user"}],
            "project_id": "project-XXXXXXXXXXX"
        },
        headers={"Authorization": f"Bearer {os.getenv('LAKERA_GUARD_API_KEY')}"}
    )

    result = response.json()
    if result["flagged"]:
        # Block the interaction - potential prompt injection
        return False
    return True
```

### Safety Category → Content Moderation

If Red found vulnerabilities in the **Safety** category (harmful content generation):

1. Enable **Content Moderation** in your AI Guardrails policy
2. Screen both inputs AND outputs
3. Configure categories based on your Red findings

| Red Finding          | AI Guardrails Content Category |
| -------------------- | ------------------------------ |
| Hate Speech          | Hate                           |
| Violence / Extremism | Violence                       |
| Sexual Content       | Sexual                         |
| Self-Harm            | Self-Harm                      |
| Harassment           | Hate / Violence                |

### Responsible Category → Multiple Defenses

**Responsible** category findings may require multiple AI Guardrails defenses:

| Red Finding        | AI Guardrails Defense                  |
| ------------------ | -------------------------------------- |
| PII Exposure       | Data Leakage Prevention                |
| Misinformation     | Content Moderation + Application logic |
| Fraud Facilitation | Content Moderation                     |
| Specialized Advice | Custom policies                        |

## AI Guardrails Policy Configuration

Based on a typical Red scan, here's a recommended AI Guardrails configuration:

### For High Security Findings

```python
# Screen all user inputs before LLM
guard_response = requests.post(
    "https://api.lakera.ai/v2/guard",
    json={
        "messages": [
            {"content": system_prompt, "role": "system"},
            {"content": user_input, "role": "user"}
        ],
        "project_id": "project-XXXXXXXXXXX"
    },
    headers={"Authorization": f"Bearer {api_key}"}
)

if guard_response.json()["flagged"]:
    return "I cannot process that request."
```

### For High Safety Findings

```python
# Screen LLM outputs before showing to user
guard_response = requests.post(
    "https://api.lakera.ai/v2/guard",
    json={
        "messages": [
            {"content": user_input, "role": "user"},
            {"content": llm_response, "role": "assistant"}
        ],
        "project_id": "project-XXXXXXXXXXX"
    },
    headers={"Authorization": f"Bearer {api_key}"}
)

if guard_response.json()["flagged"]:
    return "I'm unable to provide that response."
```

### Complete Integration Pattern

```python
def secure_llm_interaction(user_input: str) -> str:
    # 1. Screen input
    input_check = guard_screen(user_input, role="user")
    if input_check["flagged"]:
        return "I cannot process that request."

    # 2. Get LLM response
    llm_response = call_llm(user_input)

    # 3. Screen output
    output_check = guard_screen(llm_response, role="assistant")
    if output_check["flagged"]:
        return "I'm unable to provide that response."

    return llm_response
```

## Monitoring and Iteration

After deploying AI Guardrails, monitor for attack patterns:

### Set Up Alerts

Configure alerts in the AI Guardrails Dashboard for:

* High volumes of flagged requests from single users
* New attack patterns matching Red findings
* Attempts to exploit specific vulnerabilities

### Review AI Guardrails Logs

Regularly review to identify:

* Attack trends and patterns
* False positive rates
* New attack vectors not covered by current policies

### Tune Thresholds

Start strict and relax if needed:

1. Begin with L4 (Paranoid) for defenses where Red found vulnerabilities
2. Monitor false positive rates in production
3. Adjust to L3 if false positives significantly impact user experience
4. Never go below L2 for categories where Red found issues

## Continuous Security Cycle

#### Initial Red Scan

Comprehensive vulnerability discovery across all categories.

#### Deploy AI Guardrails

Configure policies based on Red findings.

#### Monitor Production

Collect data on real-world attack attempts.

#### Tune Policies

Adjust thresholds based on false positive/negative rates.

#### Periodic Rescan

Run Red again to verify protections and find new vulnerabilities.

## Best Practices

### Defense Coverage

Ensure AI Guardrails covers all attack surfaces Red tested:

* User inputs (chat messages, form fields)
* External data (RAG sources, API responses, file uploads)
* Model outputs (before displaying to users)

### Layered Protection

Use AI Guardrails as one layer in defense-in-depth:

* **AI Guardrails** catches known attack patterns
* **System prompt hardening** provides baseline protection
* **Application-level validation** handles business logic
* **Monitoring** detects novel attacks

### Using Red's Compare Feature

After implementing AI Guardrails:

1. Run a follow-up Red scan
2. Use **Compare** to see before/after results
3. Verify risk scores decreased in targeted categories
4. Identify any remaining gaps

## Getting Started

1. Review your Red scan findings
2. Map each finding to the appropriate AI Guardrails defense
3. Create an AI Guardrails project and configure your policy
4. Integrate AI Guardrails into your application ([see Quickstart](/docs/quickstart))
5. Monitor and tune based on production data
6. Schedule periodic Red rescans

## Need Help?

* [Contact Check Point](https://www.lakera.ai/lakera-red#form) for help translating Red findings to AI Guardrails policies
* Review the [AI Guardrails documentation](/guard) for detailed configuration options
* Reach out to [support@lakera.ai](mailto:support@lakera.ai) for technical assistance