---
title: "Zero credential leakage · airgap"
description: "Keep credentials out of your agent's context window: airgap redacts known key formats and high-entropy tokens locally before output is returned."
url: https://www.useairgap.dev/guides/secret-scrubbing
---

[All guides](https://www.useairgap.dev/guides)

# Zero credential leakage

Keep credentials out of your agent's context window: airgap redacts known key formats and high-entropy tokens locally before output is returned.

## Zero credential leakage

**Preventing context-window credential exfiltration:** Build scripts, failing tests, and debug traces regularly print database URLs, API tokens, or cloud environment variables to stdout. The moment those strings enter your coding agent's context window, they are sent to external LLM APIs and persisted in session transcripts.

> `redact secrets from this CI log so I can post it`

### How local regex + Shannon entropy scrubbing works

airgap runs `airgap_redact_secrets` locally inside the Rust binary on your machine — no text is sent to the cloud to be scrubbed. It runs two complementary passes and merges overlapping spans into a single match count:

1. **Structured pattern rules:** Matches known provider prefixes and formats including AWS access key IDs, GitHub tokens, OpenAI keys, Slack tokens and webhooks, Bearer authorization headers, JWTs, PEM private key blocks, and key-value credential assignments (`API_KEY=`, `PASSWORD=`, `SECRET=`).
2. **Exact configured-key replacement:** Automatically scrubs any configured GMI provider keys from sandbox logs so an accidental echo or error trace can never reveal your own credentials.
3. **Shannon entropy detection:** Measures character randomness across candidate tokens to catch high-entropy secrets (such as custom HMAC keys or vendor tokens) that do not follow a known prefix, replacing them with `[REDACTED]`.

### Where redaction runs automatically

| Tool | Automatic redaction | Notes |
| --- | --- | --- |
| `airgap_sandbox_run` | Yes (stdout + stderr) | Uploaded files are sent unchanged; returned logs are scrubbed |
| `airgap_verify_patch` | Yes (stdout + stderr) | Returned execution evidence and logs are scrubbed |
| `airgap_verify_pr` | Yes (PR text + logs) | PR title/body redacted before MaaS scan; test logs scrubbed on return |
| `airgap_audit_repo` | Yes (source before upload) | Audit snapshot is heuristically scrubbed before upload and inference |
| `airgap_redact_secrets` | On-demand local tool | Use on any local CI log, git diff, or env dump before sharing |

### Limitations to keep in mind

Heuristic secret scrubbing is a strong safety net, not a formal proof of redaction. Short or low-entropy passwords may not trigger entropy thresholds, while long random build hashes can occasionally be redacted as false positives. Never intentionally upload production secrets inside sandbox snapshots. See [Scrub logs before sharing](https://www.useairgap.dev/guides/scrub) for the direct MCP tool schema.

## Keep reading

[All 12 guides](https://www.useairgap.dev/guides)

### [The zero-trust MCP playbook](https://www.useairgap.dev/guides/team-playbook)

Routing rules plus client permissions for a whole team.

### [Verify a pull request](https://www.useairgap.dev/guides/verify-pr)

Scan, clone at the pinned SHA and run the tests in one call.
