# leaks Provider-bound secret redaction for Pi. `leaks` redacts secrets before provider requests. Local Pi behavior stays transparent when placeholders round-trip exactly. ## Install / load Loaded through the root pi-ext package. See [../../README.md](../../README.md). ## Threat model Provider sees placeholders, not classified secret values. Pi keeps restore mappings in memory only. Mappings are lost on process exit, reload, new session, or `/leaks clear`. `leaks` does not stop tool exfiltration, malicious model behavior, prompt injection, or unsafe commands. Use Pi permissions, sandboxing, and tool policy for that. ## Placeholder model Provider text uses this shape: ```text __LEAK_[_...]_[_N]__ ``` Examples use fake metadata only: ```text __LEAK_STRIPE_LIVE_SECRET_KEY_STRIPE_TOKEN_8f31aa77c901__ __LEAK_DATABASE_URL_DB_PASSWORD_POSTGRES_URL_ba29d4ff8810__ ``` The digest is HMAC12 with a random in-memory key. Tags are safe metadata. Secret length, prefix, suffix, alphabet, and entropy are not encoded. ## Commands / tools / settings Commands: - `/leaks status` reports safe counters and labels. - `/leaks reload` reloads settings and dotenv/env learning. - `/leaks test ` redacts local diagnostic text. - `/leaks clear` clears volatile placeholder mappings after confirmation. Tools: none. Settings: only custom regex rules are accepted. ```json { "leaks": { "regex": [{ "pattern": "foo_[A-Za-z0-9]{32}", "label": "FOO_TOKEN" }] } } ``` Labels must match `[A-Z0-9_]{1,64}`. Invalid or missing labels fall back to `CUSTOM_REGEX` and warn. Flags and unsupported fields are ignored with warnings. Unsafe patterns are rejected. Rejected settings: `enabled`, `keywords`, `exclude`, `secretFiles`. They are intentionally not compatibility features. ## Behavior Built-ins are always active. They cover high-confidence AI, VCS, package, cloud, payment, messaging, webhook, mail, auth, OAuth, JWT, cookie, session, database, cache, private-key, and sensitive-assignment patterns. Dotenv learning reads only cwd files: - `.env` - `.env.local` - `.env.*.local` Process environment values use the same classifier. Status collapses process env names to `ENV_KEY`. URLs, query params, headers, cookies, and assignments preserve safe structure. Only secret components are redacted. JWTs and private-key material redact as whole logical values. Public keys and certificates stay visible. Provider-bound context and provider request payloads are redacted on copied values. Original local objects are not mutated. Provider authentication headers are preserved. Tool-call args and finalized assistant messages are restored locally when they contain exact placeholders. Restore only matches complete placeholders. Traversal is bounded. Cycles are preserved. Primitive and callable values pass through. Detector failures fail open and warn once. Mappings and learned values are capped at 8192 entries. Overflow placeholders may not be restorable. ## False-positive policy Metadata stays visible aggressively. No entropy-only redaction. Names, hosts, domains, ordinary URLs, refs, branch names, package names, IDs, codenames, env references, public keys, and certificates stay visible unless a custom regex explicitly matches them. ## Limitations Out of scope: - image, audio, binary, OCR redaction - semantic secret-byte editing - homomorphic encryption - symbolic secret transforms - arbitrary DLP/privacy redaction - tool sandboxing - permission enforcement - repository secret scanning - git history cleanup