← source on GitHub ↗

Secret redaction (layered pipeline)

Layered detection + masking of secret-shaped content in everything that flows through the agent — tool results, the provider context, and user prompts — so secrets never reach the LLM, the transcript, or the session JSONL (issue #24).

Two systems run side by side:

Layers

Priority order (higher wins overlaps): registered (exact values) → path (credential files) → credential (DOM form-field values) → vendor (GitHub/AWS/OpenAI/JWT/…) → prefix (indexOf pre-screen feeding vendor) → pem → asn1 → connection → context (password/secret key names) → entropy → pii (off by default). Output markers are [REDACTED:<kind>], idempotent, and line-count preserving. Allowlisted shapes (Git SHAs, UUIDs) and data: base64 URLs survive.

Markers are single shell tokens (gh-1952): every whitespace run in a kind label renders as - ([REDACTED:GitHub-Token]), so a marker that leaks into a shell string can never split into several argv items.

Redaction is display-only (gh-1952)

Turning redaction on never changes what a child process receives: the bash tool's argv is byte-identical with redaction ON vs OFF for every non-secret value. The only execution rewrite is the approval-layer shape interceptor (issue #1408), bounded to recognized vendor token shapes — ordinary compile-time defines (--dart-define=K=V, -DK=V, and the quoted/space-spelled forms) are exempt from the entropy heuristic altogether; registered and vendor-shaped secrets still match inside defines (the carve-out never outranks a real layer).

The carve-out is bound so it cannot silence the entropy net (gh-1952 review): the FLAG forms are exempt unconditionally, but a bare K=V token is exempt only when its value side is not itself entropy-class — a KEY=<random> assignment (printenv/CI-log output) and a padded-base64 token (…==) stay masked. Appended tool-call arguments are masked on the record-write path too: the session JSONL never carries raw secrets in toolCalls[].arguments, while the executed argv and the provider context keep the original bytes.

Config (redact: in ~/.fah/config.yaml or project .fah/config.yaml)

redact:
  enabled: true        # master switch (default true)
  blockMode: false     # ALSO deny read/bash touching credential files
  layers:
    pii: true          # per-layer overrides
    entropy: false
  allowlist:           # regexes whose full match suppress redaction
    - '[0-9a-f]{40}'
  toolAllow: [read]    # hook-level policy: only these tools get redacted
  toolDeny: [write]    # never redacted (wins over toolAllow)

Defaults are never written back to the config file. enabled: false keeps the pipeline unattached entirely.

Semantics

CLI

/redact — status (on/off, blockMode, registered secret count, session match count). Subcommands: on|off, block on|off, stats (matches per layer and per tool), layers (per-layer toggle state).