Data Loss Prevention (DLP)
Agent Action Firewall includes built-in DLP capabilities to detect, mask, or block sensitive data in agent actions before it reaches external systems.
How DLP Works
- Every action payload is scanned before policy evaluation
- Built-in and custom patterns detect sensitive data
- Configurable actions: mask, block, or flag
Built-in Detectors
| Detector | Pattern | Example Match |
|---|---|---|
| SSN (US) | \d{3}-\d{2}-\d{4} | 123-45-6789 |
| Credit Card | Luhn-validated 13-19 digits | 4111-1111-1111-1111 |
| Email Address | RFC 5322 compliant | user@example.com |
| Phone (US) | (\d{3}) \d{3}-\d{4} | (555) 123-4567 |
| API Key | Common formats | sk_live_xxx, AKIA... |
| AWS Secret | 40-char base64 | aws_secret_access_key |
| Private Key | PEM format | -----BEGIN RSA PRIVATE KEY----- |
| JWT | Base64.Base64.Base64 | eyJhbG... |
Configuration
Organization-Level Settings
await api.put('/dlp/settings', {
enabled: true,
default_action: 'mask', // 'mask' | 'block' | 'flag'
detectors: {
ssn: { enabled: true, action: 'block' },
credit_card: { enabled: true, action: 'mask' },
email: { enabled: true, action: 'flag' },
api_key: { enabled: true, action: 'block' }
}
});
Per-Policy Overrides
# Override DLP for specific actions
dlp_config = {
"enabled": false
} {
# Disable DLP for internal analytics pipeline
input.action.tool == "http_proxy"
contains(input.action.params.url, "internal-analytics.example.com")
}
Custom Patterns
Define organization-specific patterns:
await api.post('/dlp/patterns', {
name: 'employee_id',
description: 'Internal employee ID format',
pattern: 'EMP-[A-Z]{2}\\d{6}',
action: 'flag',
severity: 'medium',
examples: ['EMP-AB123456', 'EMP-XY789012']
});
Pattern Testing
Test patterns before deploying:
POST /api/v1/dlp/test
{
"pattern": "EMP-[A-Z]{2}\\d{6}",
"test_data": "Contact employee EMP-AB123456 for details"
}
# Response
{
"matches": [
{
"value": "EMP-AB123456",
"start": 17,
"end": 29
}
]
}
Masking Strategies
| Strategy | Before | After |
|---|---|---|
| Full | 4111111111111111 | **************** |
| Last4 | 4111111111111111 | ************1111 |
| First6Last4 | 4111111111111111 | 411111******1111 |
| Hash | secret123 | sha256:abc123... |
| Redact | My SSN is 123-45-6789 | My SSN is [REDACTED] |
Configure per detector:
await api.put('/dlp/detectors/credit_card', {
action: 'mask',
mask_strategy: 'last4',
audit_original: true // Store original in audit (encrypted)
});
DLP Events
All detections are logged:
{
"event_type": "dlp.detected",
"timestamp": "2024-01-15T10:30:00Z",
"action_request_id": "act-456",
"detections": [
{
"detector": "credit_card",
"field": "params.body.payment_info",
"action_taken": "mask",
"masked_value": "************4242"
}
]
}
Allowlists
Exclude known-safe values:
await api.post('/dlp/allowlist', {
detector: 'email',
values: [
'noreply@example.com',
'support@example.com'
],
reason: 'Internal service accounts'
});
// Or pattern-based allowlist
await api.post('/dlp/allowlist', {
detector: 'api_key',
patterns: [
'^test_.*', // Test keys
'^pk_test_' // Stripe test keys
],
reason: 'Test/development keys'
});
Scanning Locations
DLP scans these locations by default:
| Location | Scanned |
|---|---|
params.body | Yes |
params.headers | Yes (sensitive headers only) |
params.url | Yes (query strings) |
context | No (user metadata) |
Configure custom scan locations:
await api.put('/dlp/settings', {
scan_locations: [
'params.body',
'params.headers.Authorization',
'params.query',
'context.user_data' // Enable scanning context
]
});
Performance
DLP scanning adds minimal latency:
| Payload Size | Scan Time |
|---|---|
| 1 KB | <1ms |
| 10 KB | 1-2ms |
| 100 KB | 5-10ms |
| 1 MB | 50-100ms |
For large payloads, consider:
- Streaming scan mode (Pro+)
- Async scanning with webhook callback
- Sampling for bulk operations
Compliance
DLP helps with:
- PCI DSS: Credit card data detection and masking
- HIPAA: PHI detection (SSN, medical IDs)
- GDPR: PII detection and minimization
- SOC 2: Data handling controls
Best Practices
Tip: Start with 'flag' mode. Monitor detections before blocking to avoid false positives.
Tip: Use allowlists carefully. Only allowlist values you're certain are safe.
Tip: Review DLP logs regularly. Detection patterns reveal what sensitive data your agents are handling.
Tip: Test custom patterns thoroughly. False positives disrupt workflows; false negatives leak data.
Next Steps
- Anomaly Detection — Detect unusual agent behavior
- Audit Trail — Review DLP detection events