Skip to main content

What You’ll Learn

  • Why network deny-all (and the credential vault) — not PII redaction — is what stops API-key exfiltration
  • How to configure PIIConfig to redact structured PII (email, SSN, credit card) from outbound HTTP
  • How to test TCP blocking, HTTP exfiltration, and DNS exfiltration
  • How the edge proxy redacts structured PII from HTTP request bodies before forwarding

Prerequisites

  • Declaw running locally or in the cloud (see Deployment)
  • DECLAW_API_KEY and DECLAW_DOMAIN set in your environment
This example is available in Python. TypeScript support coming soon.

Security Configuration

The example uses two independent layers of protection:
Layer 1 — PII redaction: Intercepts outbound HTTP traffic and replaces detected structured PII (email, SSN, credit card) with placeholders like [REDACTED_EMAIL]. Note: API keys aren’t reliably redacted here — there’s no working api_key detector. To keep a key out of the sandbox entirely, use the Credential Vault, which injects it at the egress proxy so it never enters the VM. Active even if the network allow-list permits some outbound traffic. Layer 2 — Network deny-all: Blocks all outbound TCP connections. This is the layer that actually stops a stolen secret from leaving — even data the PII scanner doesn’t recognize (like an API key) cannot reach any destination.

PII Types Explained

Code Walkthrough

1. The credential collection script

This script represents untrusted code that has access to credentials and PII:

2. Three exfiltration attack vectors

The example tests three distinct exfiltration methods: TCP connectivity (basic):
HTTP exfiltration (simulated):
DNS exfiltration (encoding data in DNS queries):

3. Run all tests

Expected Output

How PII Redaction Works (edge proxy)

When the guardrails service is active and network access is permitted (for example, to call an LLM API), the proxy intercepts and redacts credentials from HTTP traffic:
This means even if you allow outbound traffic to specific domains (for example, api.openai.com), structured PII is stripped from outbound request bodies before they leave the sandbox. API keys and other secrets are not covered here — use the Credential Vault so a key is injected at the proxy and never enters the sandbox in the first place.

Defense Layers Combined

For maximum protection, combine all three. Network deny-all (or an allowlist) is what stops credential exfiltration; the credential vault keeps keys out of the VM entirely; PII redaction strips structured PII from allowed traffic.