Skip to content

security(secrets): SecretSet misses a known value inside a larger base64 payload, hex and other common encodings #681

Closed

Description

@ajianaz

Found in the #594 security audit. Severity: medium. Status: confirmed (failing tests).

Affected code

crates/tole-core/src/secrets.rs:354 forms(): needles are the raw value, its JSON-escaped form (serde's escaping), base64 standard/URL-safe of the value ALONE (offset 0, no padding) and percent-encoding.

Problem

Base64 output depends on the byte offset mod 3 and on the bytes around the value, so a known secret inside a larger base64 payload is not matched. That is the common case, not an edge case:

  • HTTP Basic base64("x-access-token:" + token) and git credential helpers,
  • ~/.docker/config.json "auth": base64("user:" + token),
  • base64 .env, Kubernetes manifests of whole env files.
    Also missed: hex (xxd -p, od), JSON \/ and \uXXXX escapes produced by other encoders (Python ensure_ascii, PHP), and a value split by a zero-width character. Each of these reaches the provider, the log and every sink as is, and the web_fetch "URL carries a known secret" refusal is bypassed the same way.

Scenario

The agent runs cat ~/.docker/config.json or git config --get-regexp http.*extraheader while debugging CI; the Basic token holding GITHUB_TOKEN goes to the provider and into the durable log unredacted, although tole knows the value.

Reproduction

Scratch tests crates/tole-core/tests/audit_594.rs::base64_of_an_embedded_secret_is_redacted (fails: Authorization: Basic dXNlcjpnaHBf... passes unchanged) and ::hex_and_json_unicode_escape_forms_are_redacted (missed: hex, \/ escape, zero-width split).

Suggested fix

  • Base64: add the three shifted encodings (encode "x"+v, "xx"+v, drop the leading chars whose bits depend on the prefix and the trailing partial group) for standard and URL-safe alphabets: 6 extra needles per secret, still a byte scan.
  • Add lower/upper hex needles.
  • Normalize before matching: strip zero-width/format characters (-, , ), unescape \/ and \uXXXX in a scan copy with an offset map, or add those escaped forms as needles.
  • Document what remains (arbitrary transforms) as the residual the shape detector (feat: shared shape-detector ruleset with uteke for unknown secrets #597) cannot close either.

Activity

  1. added
    bug
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions