Sign inSign up

noxway/privacy-guard-proxy

By noxway

•Updated 7 months ago

Local proxy for Claude Code that masks PII and secrets before requests reach the Anthropic API now!

Image
Security
Machine learning & AI
0

1.5K

noxway/privacy-guard-proxy repository overview

⁠privacy-guard-proxy

Test Docker Hub Docker Image Version

privacy-guard-proxy is a local reverse proxy for Claude Code⁠ that masks sensitive data before it leaves your machine.

Email addresses, names, IBANs, API keys, IDs, addresses, and other secrets are replaced with placeholders like [EMAIL_1] or [IBAN_1] on the way to the Anthropic API. Detection runs fully in-process. No external redaction service is involved.

App screenshot

⁠Why use it?

  • Keep PII and secrets out of model requests by default
  • Run locally with no extra SaaS dependency
  • Use it as a drop-in proxy for Claude Code
  • Inspect detections, logs, and config in a built-in Web UI
  • Expose the same detector engine through a REST API

⁠How it works

Claude Code -> privacy-guard-proxy -> Anthropic API
              | masks PII + secrets |

Before a request is forwarded upstream, the proxy scans user messages, tool payloads, and file contents for sensitive data. Matching values are replaced with stable placeholders. Upstream responses are passed through unchanged.

⁠Quick start

⁠Local binary
cp config.example.json config.json
go build -o privacy-guard-proxy .
./privacy-guard-proxy

export ANTHROPIC_BASE_URL=http://127.0.0.1:9880
claude

By default:

  • Proxy: http://127.0.0.1:9880
  • Web UI + REST API: http://127.0.0.1:9881
⁠Docker Compose
cp config.example.json config.json
docker compose up -d

The compose setup exposes the same two ports and mounts config.json plus ./logs.

⁠What gets masked?

ContentMasked
User messagesYes
File contents returned by toolsYes
Tool inputs such as write/edit payloadsYes
System promptNo
Assistant responsesNo

⁠Web UI

If api_port is enabled, the browser UI is available at http://localhost:9881.

Web UI

First login:

  • Username: admin
  • Password: admin

You are forced to change the password on first login.

The UI lets you:

  • Manage one or more proxy instances
  • Choose detectors and whitelists per proxy
  • Enable dry_run mode to log findings without modifying requests
  • Manage REST API keys without storing plaintext secrets
  • Configure default detectors, default whitelist, and CORS
  • Inspect live proxy logs
  • Test detector behavior interactively

⁠REST API

The built-in API exposes the same detector engine used by the proxy.

# Anonymize text
curl http://localhost:9881/anonymize \
  -H "Content-Type: application/json" \
  -d '{"text":"Meine IBAN: DE89370400440532013000"}' | jq

# Full scan with findings and placeholder mapping
curl http://localhost:9881/scan \
  -H "Content-Type: application/json" \
  -d '{"text":"[email protected], +49 171 1234567"}' | jq

# Use selected detectors for this request only
curl http://localhost:9881/scan \
  -H "Content-Type: application/json" \
  -d '{"text":"...", "detectors":["EMAIL","IBAN","SECRET"]}' | jq

# Health and metrics
curl http://localhost:9881/health
curl http://localhost:9881/metrics

Authentication is optional. If no API keys are configured, requests are accepted without auth.

curl http://localhost:9881/scan \
  -H "X-Api-Key: pgk_..." \
  -H "Content-Type: application/json" \
  -d '{"text":"..."}'

Current limit:

  • /scan and /anonymize: 120 requests per minute
  • Limit is applied per API key, or per client IP when auth is disabled

⁠Configuration

Start from config.example.json⁠ and adjust as needed:

{
  "api_port": 9881,
  "api_keys": [],
  "default_detectors": [],
  "default_whitelist": [],
  "cors_origins": [],
  "ui_password_hash": "",
  "proxies": [
    {
      "type": "claude-code",
      "port": 9880,
      "upstream": "https://api.anthropic.com",
      "privacy_guard": {
        "url": "",
        "api_key": null,
        "detectors": [],
        "whitelist": [],
        "dry_run": false
      }
    }
  ]
}
FieldMeaning
api_portPort for Web UI and REST API. 0 disables both.
api_keysStored API key metadata and hashes for protecting /scan and /anonymize.
default_detectorsFallback detector list for API requests that do not specify detectors. Empty means all detectors.
default_whitelistGlobal terms that should never be masked by the REST API.
cors_originsAllowed browser origins for the REST API. Empty means CORS is off.
ui_password_hashSHA-256 hash of the UI password. Empty means initial admin/admin.
proxies[].typeRequest format. Use claude-code for Claude Code traffic.
proxies[].portLocal listening port of this proxy instance.
proxies[].upstreamUpstream Anthropic base URL.
proxies[].privacy_guard.urlReserved config field for compatibility.
proxies[].privacy_guard.api_keyOptional per-proxy upstream API key override.
proxies[].privacy_guard.detectorsEnabled detector types. Empty means all detectors.
proxies[].privacy_guard.whitelistTerms that should never be replaced for this proxy.
proxies[].privacy_guard.dry_runDetect and log findings without changing outgoing request bodies.

For /scan and /anonymize, the runtime whitelist is the combination of default_whitelist and any request-level whitelist.

Legacy configs using a top-level []Config array are still accepted.

⁠Supported detectors

TypeExampleValidation / logic
EMAIL[email protected]Regex-based
PHONE+49 171 1234567DACH-focused, at least 9 digits
IBANDE89 3704 0044 0532 0130 00MOD-97 checksum
CREDIT_CARD4111-1111-1111-1111Luhn check
TAX_ID86 095 742 719German tax ID validation
SOCIAL_SECURITY65 180675 B 003German social security format
KVNRA123456789German health insurance number validation
VAT_IDDE 123 456 789German VAT ID validation
PERSONAL_IDC22990047German passport / ID style patterns
LICENSE_PLATEM-AB 1234German plate formats
DRIVER_LICENSEB123456ABContext-aware driver's license detection
ADDRESSMusterstrasse 12, 80331 MuenchenDACH street + postal code + city
URL_SECRET?token=abc123Sensitive query parameter detection
SECRETAPI keys, JWTs, cloud tokensLarge built-in ruleset

⁠Typical use cases

  • Protect prompts and file snippets sent from Claude Code
  • Offer a local anonymization API for internal tooling
  • Run detector tests against sample text before rolling out changes
  • Operate in dry_run mode first to see what would be masked

⁠Development

go build -o privacy-guard-proxy .
go test ./...

Project layout:

internal/
├── api/        # Web UI + REST API
├── detector/   # PII and secret detection engine
└── proxy/      # Reverse proxy and masking pipeline
main.go         # Application entry point
config.json     # Runtime configuration

Frontend assets are vendored under internal/api/static/vendor/, so the Web UI does not depend on external CDNs at runtime.

Tag summary

Content type

Image

Digest

sha256:780edfe4d…

Size

7.4 MB

Last updated

7 months ago

docker pull noxway/privacy-guard-proxy