Skip to main content

Redaction

Shield automatically detects and redacts sensitive data in logs, alerts, and dashboard reports to protect privacy and comply with regulations.

Quick Start

Enable secret redaction:

{
"redaction": {
"enabled": true,
"mode": "secrets"
}
}

Now API keys, tokens, and passwords are automatically redacted:

In outbound bot messages (prevents leaks):

Bot tries to say: "Your API key is sk-1234567890abcdef"
User receives: "Your API key is sk-123...def"

In logs and alerts:

Before: API_KEY=sk-1234567890abcdef
After: API_KEY=sk-123...def
Critical Protection

This is your primary defense against bots accidentally leaking API keys, passwords, and other secrets to users!


Outbound Filtering + Redaction

Redaction works with outbound filtering modes:

Block Mode (Maximum Security)

{
"outboundMode": "block",
"redaction": {
"enabled": true,
"mode": "secrets"
}
}

If bot tries to leak a secret:

  1. Threat detected (e.g., API key in response)
  2. Message completely blocked
  3. User sees: "🛑 Message blocked by security filter"

Flag Mode (Redact & Allow)

{
"outboundMode": "flag",
"redaction": {
"enabled": true,
"mode": "secrets"
}
}

If bot tries to leak a secret:

  1. Threat detected
  2. Secret redacted in message
  3. User receives message with redaction: "Your key is sk-..."
  4. Warning logged for admin
{
"outboundMode": "flag",
"redaction": {
"enabled": true,
"mode": "secrets"
}
}

Why flag + redaction?

  • Bot can still respond (doesn't break conversation)
  • Secrets are automatically masked
  • Admin gets alerted
  • User experience isn't disrupted

Redaction Modes

Mode: secrets

Redacts API keys, tokens, passwords, and credentials.

{
"redaction": {
"mode": "secrets"
}
}

What's redacted:

  • OpenAI keys (sk-...)
  • GitHub tokens (ghp_..., github_pat_...)
  • AWS keys (AKIA...)
  • Google API keys
  • JWT tokens
  • OAuth tokens
  • Bearer tokens
  • Private keys (PEM, SSH)
  • Database passwords
  • Slack tokens
  • Telegram bot tokens

Mode: pii

Redacts Personally Identifiable Information.

{
"redaction": {
"mode": "pii"
}
}

What's redacted:

  • Email addresses
  • Phone numbers (international formats)
  • Credit card numbers
  • Social Security Numbers (SSN)
  • IP addresses
  • Physical addresses
  • Names (when detected as PII)

Mode: all

Redacts both secrets AND PII.

{
"redaction": {
"mode": "all"
}
}

Most comprehensive protection. Recommended for healthcare, finance, legal.

Mode: custom

Choose exactly what to redact using includeTypes and excludeTypes.

{
"redaction": {
"mode": "custom",
"includeTypes": ["openai_keys", "emails", "phone_numbers"]
}
}

Only redacts the specified types.

Mode: off

Disable redaction completely.

{
"redaction": {
"enabled": false
}
}
Privacy Risk

Logs may contain sensitive user data and credentials. Only disable redaction in controlled environments.


Redaction Types

Secrets

TypeExampleRedacted
openai_keyssk-1234567890abcdefsk-123...def
github_keysghp_a1b2c3d4e5f6g7h8ghp_a1b...h8
aws_keysAKIAIOSFODNN7EXAMPLEAKIA...PLE
google_keysAIzaSyD-abc123AIza...123
jwt_tokenseyJhbGciOiJIUzI1...eyJh...***
private_keys-----BEGIN RSA...***PEM KEY***
slack_tokensxoxb-1234-5678xoxb-***
telegram_tokens123456:ABC-DEF...123456:***

PII (Personal Information)

TypeExampleRedacted
emailsuser@example.com***@***.com
phone_numbers+1-555-123-4567+1-***-***-4567
credit_cards4532 1234 5678 90104532 **** **** 9010
ssn123-45-6789***-**-6789
ip_addresses192.168.1.100192.168.*.*

Smart Masking

Shield preserves enough information for debugging while protecting sensitive parts.

Configurable Masking

{
"redaction": {
"keepStart": 6,
"keepEnd": 4
}
}

Example:

  • Original: sk-1234567890abcdef
  • keepStart: 6, keepEnd: 4sk-123...cdef
  • keepStart: 8, keepEnd: 8sk-12345...abcdef
  • keepStart: 0, keepEnd: 0***

Default Values

Data TypeDefault Masking
API KeysKeep 6 start, 4 end
EmailsKeep domain
PhoneKeep country code, last 4
Credit CardsKeep first 4, last 4
IP AddressesKeep first 2 octets

Include/Exclude Types

Include Only Specific Types

{
"redaction": {
"mode": "custom",
"includeTypes": [
"openai_keys",
"github_keys",
"emails"
]
}
}

Only these three types are redacted. Everything else passes through.

Exclude Specific Types

{
"redaction": {
"mode": "all",
"excludeTypes": [
"ip_addresses",
"phone_numbers"
]
}
}

Redacts everything EXCEPT IP addresses and phone numbers.


Custom Patterns

Add your own redaction patterns using regex:

{
"redaction": {
"customPatterns": [
{
"name": "employee_id",
"pattern": "EMP-\\d{6}",
"replacement": "EMP-***",
"description": "Company employee IDs"
},
{
"name": "internal_token",
"pattern": "MYAPP_[A-Z0-9]{32}",
"replacement": "MYAPP_***",
"description": "Internal app tokens"
}
]
}
}

Example:

  • Original: Employee EMP-123456 accessed system
  • Redacted: Employee EMP-*** accessed system

Where Redaction Applies

✅ Outbound Bot Messages

Most important: Redacts secrets in bot responses before sending to users.

Example:

Bot attempts to say: "Your API key is sk-1234567890abcdef"
User receives: "Your API key is sk-***...***"

This is the PRIMARY purpose - preventing your bot from accidentally leaking secrets!

✅ Logs and Alerts

  • Security logs on disk
  • Dashboard alerts
  • Backend API submissions
  • Email notifications
  • Webhook payloads
  • Exported data

Example log entry:

[2026-02-04 14:32:15] Message: "My token is sk-***...***"

⚠️ NOT Redacted (Intentional)

Inbound user messages (real-time):

  • Bot sees full message to process correctly
  • Only logs/alerts are redacted
  • Threat detection needs full context

Why? The bot must see the full message to:

  • Understand user intent
  • Detect if it's a secret being leaked
  • Respond appropriately

But if the user's message contains secrets, those ARE redacted in logs.


Compliance Use Cases

GDPR Compliance

{
"redaction": {
"enabled": true,
"mode": "all",
"includeTypes": [
"emails",
"phone_numbers",
"ip_addresses",
"credit_cards"
]
}
}

Redacts all PII from logs for European users.

HIPAA Compliance (Healthcare)

{
"redaction": {
"enabled": true,
"mode": "all",
"customPatterns": [
{
"name": "medical_record",
"pattern": "MRN-\\d{8}",
"replacement": "MRN-***"
},
{
"name": "patient_id",
"pattern": "PT-\\d{6}",
"replacement": "PT-***"
}
]
}
}

PCI-DSS (Payment Cards)

{
"redaction": {
"enabled": true,
"includeTypes": [
"credit_cards",
"cvv_codes"
],
"keepStart": 4,
"keepEnd": 4
}
}

Performance Impact

Redaction is fast:

  • Latency: < 1ms per message
  • CPU: Negligible
  • Memory: ~5 MB for regex patterns

No noticeable impact on message processing speed.


Testing Redaction

Test what gets redacted:

Via Dashboard

  1. Go to dashboard.securecheck.io
  2. Click "Alerts"
  3. View a recent alert
  4. Check if sensitive data is masked

Via Logs

grep "Alert" ~/.securecheck/shield/logs/security-*.log

Look for redacted values (e.g., sk-123...def).

Via Shield Command

/shield test sk-1234567890abcdef was leaked

Check if the key is masked in the response.


Troubleshooting

Data Not Being Redacted

Problem: Still seeing secrets in logs

Solutions:

  1. Verify enabled: true
  2. Check correct mode is set
  3. Restart OpenClaw after config change
  4. Test with /shield validate

Over-Redaction

Problem: Too much data being masked

Solutions:

  1. Use custom mode with specific includeTypes
  2. Add to excludeTypes
  3. Adjust keepStart / keepEnd to show more

Custom Pattern Not Working

Problem: Custom regex not matching

Solutions:

  1. Test regex at regex101.com
  2. Escape special characters: \\., \\(, \\)
  3. Check logs for regex errors
  4. Validate JSON syntax

Best Practices

  1. Start with secrets mode - Catches most sensitive data
  2. Add custom patterns for proprietary identifiers
  3. Test thoroughly before production
  4. Keep enough context for debugging (don't mask everything)
  5. Document patterns with clear descriptions
  6. Regular audits of logs to ensure redaction works

Complete Example

{
"redaction": {
"enabled": true,
"mode": "all",

"// Masking": "",
"keepStart": 6,
"keepEnd": 4,

"// Exclusions": "",
"excludeTypes": ["ip_addresses"],

"// Custom Patterns": "",
"customPatterns": [
{
"name": "api_key",
"pattern": "MYAPP-[A-Z0-9]{32}",
"replacement": "MYAPP-***",
"description": "Internal API keys"
},
{
"name": "order_id",
"pattern": "ORD-\\d{10}",
"replacement": "ORD-***",
"description": "Order numbers"
}
]
}
}

Next Steps