Skip to content

fluree info prints OAuth2 client_secret in plaintext — ConfigValue redacts Debug but not Serialize #1497

Closed

Description

@aaj3f

Summary

fluree iceberg info <gs> and fluree info <gs> print the full graph-source config as pretty JSON to stdout — including catalog.auth.client_secret, i.e. the raw Snowflake PAT / OAuth2 client secret.

ConfigValue has a carefully hand-written redacting Debug impl, but the redaction only covers Debug. Serialize is derived, so every JSON print path bypasses it. The presence of the redacting Debug actively gives false assurance that the type is safe to print.

Evidence

The print sites (each dumps the whole config via serde_json::to_string_pretty):

  • fluree-db-cli/src/commands/iceberg.rs:571-575
  • fluree-db-cli/src/commands/iceberg.rs:602-605
  • fluree-db-cli/src/commands/info.rs:200
  • fluree-db-cli/src/commands/info.rs:232

The type:

  • fluree-db-iceberg/src/config_value.rs:45-62 — #[derive(Clone, Deserialize, Serialize, PartialEq, Eq)] + #[serde(untagged)] on enum ConfigValue { Literal(String), Dynamic { .. } }. Untagged + Literal(String) ⇒ serializes to the bare secret string.

  • fluree-db-iceberg/src/config_value.rs:64-68 — the redacting Debug, whose own doc comment states the intent:

    Redacting Debug: ConfigValue carries auth secrets (bearer tokens, OAuth2 client secrets), so a {:?} in a log or error must never leak them. The environment-variable name is shown (it aids debugging and is not secret); the literal value and any inline default are redacted.

So the invariant the Debug impl asserts ("must never leak them") is not upheld on the Serialize path.

Reproduction

Verified live at a8de70e0f:

$ fluree iceberg map my-gs \
    --catalog-uri https://<acct>.snowflakecomputing.com/polaris/api/catalog \
    --oauth2-token-url https://<acct>.snowflakecomputing.com/polaris/api/catalog/v1/oauth/tokens \
    --oauth2-client-secret "$PAT" \
    --oauth2-scope session:role:ICEBERG_READER \
    --r2rml customer.ttl --warehouse LAB --s3-region us-east-2

$ fluree info my-gs
Configuration:
{
  "catalog": {
    "type": "rest",
    "auth": {
      "type": "oauth2_client_credentials",
      "client_id": "",
      "client_secret": "eyJraWQiOi...<FULL PAT IN PLAINTEXT>",
      "scope": "session:role:ICEBERG_READER",
      ...

Impact

  • The PAT / client secret is echoed to the terminal, and thence to shell scrollback, script logs, and CI job output.
  • Affects AuthConfig::Bearer { token } identically — same ConfigValue, same path.
  • fluree info is a natural "what is this graph source?" command, so it is likely to be run and pasted into issues/support threads by users who have no reason to expect it emits a live credential.
  • Anything that persists or forwards the serialized config inherits the same exposure; the CLI printer is the surface found so far, not necessarily the only one.

Suggested fix

The bug is that redaction lives in the wrong place — a print-site fix would leave the next JSON path exposed. Preferred: make the type safe, so no caller can leak it.

Options, roughly in order of preference:

  1. Custom Serialize for ConfigValue mirroring the Debug impl (emit "<redacted>" for Literal, keep env_var names). Fixes every current and future print path at once. Requires a separate, explicit path for round-tripping the real value where persistence genuinely needs it — a #[serde(serialize_with = ...)] escape hatch on the persisted struct, or a distinct ConfigValueOwned/unredacted() accessor used only by the storage writer.
  2. Redact at the print sites (all four above) by walking the JSON and blanking known secret keys. Cheaper, but fails open on the next new print site and re-creates the denylist-vs-allowlist problem.
  3. Serialize-side allowlist on a dedicated display DTO for info.

Option 1 is the one that makes the Debug impl's stated invariant actually true. Worth checking whether the persisted graph-source record itself stores the secret in plaintext — if so that is a related but distinct issue.

Notes

Found while smoke-testing Snowflake Horizon + customer-managed S3 at a8de70e0f. The PAT exposed during that testing was ICEBERG_READER-restricted and has been revoked.

Activity

  1. aaj3f commented on Jul 15, 2026

    @aaj3f
    ContributorAuthor

    Correction from implementation grounding (DB session, eee643572): Option 1 (redacting Serialize) is not implementable as stated — it breaks a CI-locked contract.

    The persistence path stores IcebergGsConfig::to_json() (derived Serialize) verbatim into GraphSourceRecord.config, and query-time auth re-reads it; ledger_info.rs:2758-2762 explicitly asserts the stored JSON contains the secret ("storage serialization must be lossless"), as do routes/iceberg.rs:770,773 and cli/iceberg.rs:873. A redacting Serialize would persist "[redacted]" and break every catalog auth at query time.

    What actually exists: every server emit path already redacts through a fail-closed, allowlist-based JSON-tree redactor (redact_graph_source_config, ledger_info.rs:1038; SECRET_CONFIG_KEYS :981-991; exhaustive per-variant canary test at :2797). The only unpatched leaks are the two local CLI print sites — cli/commands/info.rs:203/:235 and cli/commands/iceberg.rs:574/:605. The remote CLI paths echo the server's already-redacted config and are safe.

    So the fix landing here is: export the existing redactor from fluree-db-api and route those two local print sites through it (fail-closed, same allowlist, canary-tested), rather than making the type's Serialize lossy. The "next new print site fails open" residual is real but mitigated: the type-level fix that actually closes it is ConfigValue::SecretRef (db#1500 §3) — once the stored form is a reference, there is no secret in the config to leak on any print path, which is the disease-level fix per fluree/solo#782.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions