Skip to content

Commit d11e4d3

Browse files
thebongyRishit Bansal
andauthored
[AI Gateway] Add documentation for DLP on AI Gateway (#24778)
Co-authored-by: Rishit Bansal <[email protected]>
1 parent 9ade45d commit d11e4d3

File tree

3 files changed

+280
-8
lines changed

3 files changed

+280
-8
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
pcx_content_type: concept
3+
title: Data Loss Prevention (DLP)
4+
sidebar:
5+
order: 5
6+
group:
7+
badge: Beta
8+
---
9+
10+
import { Feature } from "~/components";
11+
12+
13+
Data Loss Prevention (DLP) for AI Gateway helps protect your organization from inadvertent exposure of sensitive data through AI interactions. By integrating with Cloudflare's proven DLP technology, AI Gateway can scan both incoming prompts and outgoing AI responses for sensitive information, ensuring your AI applications maintain security and compliance standards.
14+
15+
## How it works
16+
17+
AI Gateway DLP leverages the same powerful detection engines used in [Cloudflare's Data Loss Prevention](/cloudflare-one/policies/data-loss-prevention/) solution to scan AI traffic in real-time. The system analyzes both user prompts sent to AI models and responses received from AI providers, identifying sensitive data patterns and taking appropriate protective actions.
18+
19+
20+
## Key benefits
21+
22+
- **Prevent data leakage**: Stop sensitive information from being inadvertently shared with AI providers or exposed in AI responses
23+
- **Maintain compliance**: Help meet regulatory requirements like GDPR, HIPAA, and PCI DSS
24+
- **Consistent protection**: Apply the same DLP policies across all AI providers and models
25+
- **Audit visibility**: Comprehensive logging and reporting for security and compliance teams
26+
- **Zero-code integration**: Enable protection without modifying existing AI applications
27+
28+
## Supported AI traffic
29+
30+
AI Gateway DLP can scan:
31+
32+
- **User prompts** - Content submitted to AI models, including text, code, and structured data
33+
- **AI responses** - Output generated by AI models before being returned to users
34+
35+
The system works with all AI providers supported by AI Gateway, providing consistent protection regardless of which models or services you use.
36+
37+
## Integration with Cloudflare DLP
38+
39+
AI Gateway DLP uses the same detection profiles and policies as Cloudflare's enterprise DLP solution. This means:
40+
41+
- **Unified management** - Configure DLP policies once and apply them across web traffic, email, SaaS applications, and AI interactions
42+
- **Consistent detection** - The same sensitive data patterns are detected across all channels
43+
- **Centralized reporting** - All DLP events appear in the same dashboard and logs
44+
- **Shared profiles** - Reuse existing DLP detection profiles for AI traffic
45+
46+
For more information about Cloudflare's DLP capabilities, refer to the [Data Loss Prevention documentation](/cloudflare-one/policies/data-loss-prevention/).
47+
48+
## Getting started
49+
50+
To enable DLP for your AI Gateway:
51+
52+
1. [Set up DLP policies](/ai-gateway/features/dlp/set-up-dlp/) for your AI Gateway
53+
2. Configure detection profiles and response actions
54+
3. Monitor DLP events through the Cloudflare dashboard
55+
56+
## Related resources
57+
58+
- [Set up DLP for AI Gateway](/ai-gateway/features/dlp/set-up-dlp/)
59+
- [Cloudflare Data Loss Prevention](/cloudflare-one/policies/data-loss-prevention/)
60+
- [AI Gateway Security Features](/ai-gateway/features/guardrails/)
61+
- [DLP Detection Profiles](/cloudflare-one/policies/data-loss-prevention/dlp-profiles/)
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
---
2+
pcx_content_type: how-to
3+
title: Set up Data Loss Prevention (DLP)
4+
sidebar:
5+
order: 2
6+
---
7+
8+
Add Data Loss Prevention (DLP) to any AI Gateway to start scanning AI prompts and responses for sensitive data.
9+
10+
## Prerequisites
11+
12+
- An existing [AI Gateway](/ai-gateway/get-started/)
13+
14+
## Enable DLP for AI Gateway
15+
16+
1. Log into the [Cloudflare dashboard](https://dash.cloudflare.com/) and select your account.
17+
2. Go to **AI** > **AI Gateway**.
18+
3. Select a gateway where you want to enable DLP.
19+
4. Go to the **Firewall** tab.
20+
5. Toggle **Data Loss Prevention (DLP)** to **On**.
21+
22+
## Add DLP policies
23+
24+
After enabling DLP, you can create policies to define how sensitive data should be handled:
25+
26+
1. Under the DLP section, click **Add Policy**.
27+
2. Configure the following fields for each policy:
28+
- **Policy ID**: Enter a unique name for this policy (e.g., "Block-PII-Requests")
29+
- **DLP Profiles**: Select the DLP profiles to check against. AI requests/responses will be checked against each of the selected profiles. Available profiles include:
30+
- **Financial Information** - Credit cards, bank accounts, routing numbers
31+
- **Personal Identifiable Information (PII)** - Names, addresses, phone numbers
32+
- **Government Identifiers** - SSNs, passport numbers, driver's licenses
33+
- **Healthcare Information** - Medical record numbers, patient data
34+
- **Custom Profiles** - Organization-specific data patterns
35+
36+
:::note
37+
DLP profiles can be created and managed in the [Zero Trust DLP dashboard](/cloudflare-one/policies/data-loss-prevention/dlp-profiles/).
38+
:::
39+
40+
- **Action**: Choose the action to take when any of the selected profiles match:
41+
- **Flag** - Record the detection for audit purposes without blocking
42+
- **Block** - Prevent the request/response from proceeding
43+
44+
- **Check**: Select what to scan:
45+
- **Request** - Scan user prompts sent to AI providers
46+
- **Response** - Scan AI model responses before returning to users
47+
- **Both** - Scan both requests and responses
48+
49+
3. Click **Save** to save your policy configuration.
50+
51+
## Manage DLP policies
52+
53+
You can create multiple DLP policies with different configurations:
54+
55+
- **Add multiple policies**: Click **Add Policy** to create additional policies with different profile combinations or actions
56+
- **Enable/disable policies**: Use the toggle next to each policy to individually enable or disable them without deleting the configuration
57+
- **Edit policies**: Click on any existing policy to modify its settings
58+
- **Save changes**: Always click **Save** after making any changes to apply them
59+
60+
## Test your configuration
61+
62+
After configuring DLP settings:
63+
64+
1. Make a test AI request through your gateway that contains sample sensitive data.
65+
2. Check the **AI Gateway Logs** to verify DLP scanning is working.
66+
3. Review the detection results and adjust profiles or actions as needed.
67+
68+
## Monitor DLP events
69+
70+
### Viewing DLP logs in AI Gateway
71+
72+
DLP events are integrated into your AI Gateway logs:
73+
74+
1. Go to **AI** > **AI Gateway** > your gateway > **Logs**.
75+
2. Click on any log entry to view detailed information. For requests where DLP policies were triggered, additional details are included:
76+
- **DLP Action Taken**: Shows whether the action was "Flag" or "Block"
77+
- **DLP Policies Matched**: Detailed information about each policy that matched, including:
78+
- Which DLP profiles triggered within each policy
79+
- Whether the match occurred in the request or response
80+
- Specific entries that matched within each DLP profile
81+
82+
### Filter DLP events
83+
84+
To view only DLP-related requests:
85+
86+
1. On the **Logs** tab, click **Add Filter**.
87+
2. Select **DLP Action** from the filter options.
88+
3. Choose to filter by:
89+
- **FLAG** - Show only requests where sensitive data was flagged
90+
- **BLOCK** - Show only requests that were blocked due to DLP policies
91+
92+
93+
## Error handling
94+
95+
When DLP policies are triggered, your application will receive additional information through response headers and error codes.
96+
97+
### DLP response header
98+
99+
When a request matches DLP policies (whether flagged or blocked), an additional `cf-aig-dlp` header is returned containing detailed information about the match:
100+
101+
#### Header schema
102+
103+
```json
104+
{
105+
"findings": [
106+
{
107+
"profile": {
108+
"context": {},
109+
"entry_ids": ["string"],
110+
"profile_id": "string"
111+
},
112+
"policy_ids": ["string"],
113+
"check": "REQUEST" | "RESPONSE"
114+
}
115+
],
116+
"action": "BLOCK" | "FLAG"
117+
}
118+
```
119+
120+
#### Example header value
121+
122+
```json
123+
{
124+
"findings": [
125+
{
126+
"profile": {
127+
"context": {},
128+
"entry_ids": ["a1b2c3d4-e5f6-7890-abcd-ef1234567890", "f7e8d9c0-b1a2-3456-789a-bcdef0123456"],
129+
"profile_id": "12345678-90ab-cdef-1234-567890abcdef"
130+
},
131+
"policy_ids": ["block_financial_data"],
132+
"check": "REQUEST"
133+
}
134+
],
135+
"action": "BLOCK"
136+
}
137+
```
138+
139+
Use this header to programmatically detect which DLP profiles and entries were matched, which policies triggered, and whether the match occurred in the request or response.
140+
141+
### Error codes for blocked requests
142+
143+
When DLP blocks a request, your application will receive structured error responses:
144+
145+
- **Request blocked by DLP**
146+
- `"code": 2029`
147+
- `"message": "Request content blocked due to DLP policy violations"`
148+
149+
- **Response blocked by DLP**
150+
- `"code": 2030`
151+
- `"message": "Response content blocked due to DLP policy violations"`
152+
153+
Handle these errors in your application:
154+
155+
```js
156+
try {
157+
const res = await env.AI.run('@cf/meta/llama-3.1-8b-instruct', {
158+
prompt: userInput
159+
}, {
160+
gateway: {id: 'your-gateway-id'}
161+
})
162+
return Response.json(res)
163+
} catch (e) {
164+
if ((e as Error).message.includes('2029')) {
165+
return new Response('Request contains sensitive data and cannot be processed.')
166+
}
167+
if ((e as Error).message.includes('2030')) {
168+
return new Response('AI response was blocked due to sensitive content.')
169+
}
170+
return new Response('AI request failed')
171+
}
172+
```
173+
174+
## Best practices
175+
176+
- **Start with flagging**: Begin with "Flag" actions to understand what data is being detected before implementing blocking
177+
- **Tune confidence levels**: Adjust detection sensitivity based on your false positive tolerance
178+
- **Use appropriate profiles**: Select DLP profiles that match your data protection requirements
179+
- **Monitor regularly**: Review DLP events to ensure policies are working as expected
180+
- **Test thoroughly**: Validate DLP behavior with sample sensitive data before production deployment
181+
182+
## Troubleshooting
183+
184+
### DLP not triggering
185+
186+
- Verify DLP toggle is enabled for your gateway
187+
- Ensure selected DLP profiles are appropriate for your test data
188+
- Confirm confidence levels aren't set too high
189+
190+
### Unexpected blocking
191+
192+
- Review DLP logs to see which profiles triggered
193+
- Consider lowering confidence levels for problematic profiles
194+
- Test with different sample data to understand detection patterns
195+
- Adjust profile selections if needed
196+
197+
For additional support with DLP configuration, refer to the [Cloudflare Data Loss Prevention documentation](/cloudflare-one/policies/data-loss-prevention/) or contact your Cloudflare support team.

src/content/docs/ai-gateway/features/index.mdx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ Deploy AI applications safely with real-time content moderation. Automatically d
7070

7171
</Feature>
7272

73+
<Feature header="Data Loss Prevention (DLP)" href="/ai-gateway/features/dlp/">
74+
75+
Protect your organization from inadvertent exposure of sensitive data through AI interactions. Scan prompts and responses for PII, financial data, and other sensitive information.
76+
77+
**Key benefits:**
78+
79+
- Real-time scanning of AI prompts and responses
80+
- Detection of PII, financial, healthcare, and custom data patterns
81+
- Configurable actions: flag or block sensitive content
82+
- Integration with Cloudflare's enterprise DLP solution
83+
- Compliance support for GDPR, HIPAA, and PCI DSS
84+
85+
</Feature>
86+
7387
<Feature header="Authentication" href="/ai-gateway/configuration/authentication/">
7488

7589
Secure your AI Gateway with token-based authentication. Control access to your gateways and protect against unauthorized usage.
@@ -157,19 +171,19 @@ Override default pricing with your negotiated rates or custom cost models. Apply
157171

158172
## Feature Comparison by Use Case
159173

160-
| Use Case | Recommended Features |
161-
| -------------------------- | ------------------------------------------- |
162-
| **Cost Optimization** | Caching, Rate Limiting, Custom Costs |
163-
| **High Availability** | Fallbacks using Dynamic Routing |
164-
| **Security & Compliance** | Guardrails, Authentication, BYOK, Logging |
165-
| **Performance Monitoring** | Analytics, Logging, Custom Metadata |
166-
| **A/B Testing** | Dynamic Routing, Custom Metadata, Analytics |
174+
| Use Case | Recommended Features |
175+
| -------------------------- | ----------------------------------------------- |
176+
| **Cost Optimization** | Caching, Rate Limiting, Custom Costs |
177+
| **High Availability** | Fallbacks using Dynamic Routing |
178+
| **Security & Compliance** | Guardrails, DLP, Authentication, BYOK, Logging |
179+
| **Performance Monitoring** | Analytics, Logging, Custom Metadata |
180+
| **A/B Testing** | Dynamic Routing, Custom Metadata, Analytics |
167181

168182
## Getting Started with Features
169183

170184
1. **Start with the basics**: Enable [Caching](/ai-gateway/features/caching/) and [Analytics](/ai-gateway/observability/analytics/) for immediate benefits
171185
2. **Add reliability**: Configure Fallbacks and Rate Limiting using [Dynamic routing](/ai-gateway/features/dynamic-routing/)
172-
3. **Enhance security**: Implement [Guardrails](/ai-gateway/features/guardrails/) and [Authentication](/ai-gateway/configuration/authentication/)
186+
3. **Enhance security**: Implement [Guardrails](/ai-gateway/features/guardrails/), [DLP](/ai-gateway/features/dlp/), and [Authentication](/ai-gateway/configuration/authentication/)
173187

174188
---
175189

0 commit comments

Comments
 (0)