Skip to content

fix: redact sensitive env values from surfaced adapter stderr (defense-in-depth for config-as-secret pattern) #301

Closed

Description

@jflowers

Summary

Follow-up from PR #300 review (divisor-adversary assessment): the internal/aireport subprocess adapters surface up to 512 bytes of AI-CLI stderr in error messages (see formatStderrSuffix / maxAdapterStderrBytes in internal/aireport/adapter.go). The cap bounds volume but does not scrub content.

Risk

With the config-as-single-secret pattern introduced by the reusable gaze AI report workflow (the entire strict-JSON opencode config — including the literal apiKey — arrives as OPENCODE_CONFIG_CONTENT), GitHub's automatic secret masking registers only the full JSON document, not the embedded key. If a pinned opencode-ai release ever echoed config fragments to stderr (e.g., in a JSON parse error), a substring containing the bare apiKey could appear unmasked in CI logs. Today gaze itself never reads, logs, or writes the config (pure env passthrough; runSubprocess never sets cmd.Env), and there is no observed echo behavior at [email protected] — this is a defense-in-depth concern, not a demonstrated leak.

Proposed work (needs an OpenSpec change)

  1. Scrub surfaced stderr snippets against sensitive inherited env-var values before embedding them in errors — gaze is the process that passes the environment to the child, so it can redact values of vars matching *KEY* / *TOKEN* / *SECRET* / *CONFIG_CONTENT* (or all inherited env values above a length threshold). JSON-pattern scrubbing was evaluated and rejected as brittle.
  2. Optionally document an org-level mitigation for CI consumers: register the bare API key as a second secret (e.g. opencode-api-key) referenced in an unused env var of the report step, so GitHub masks verbatim occurrences anywhere in logs.
  3. Verify multiline-secret masking reliability (the canonical config is pretty-printed multiline JSON; GitHub's multiline masking has historically been unreliable), and prefer a single-line strict-JSON secret shape in docs if so.

References

  • PR feat: provider-agnostic reusable gaze AI report workflow #300 review feedback (pre-existing residual finding)
  • internal/aireport/adapter.go (runSubprocess, formatStderrSuffix, maxAdapterStderrBytes)
  • internal/aireport/adapter_opencode.go (empty-output stderr suffix path)
  • Reusable workflow: .github/workflows/reusable_gaze_ai_report.yml

Activity

  1. added 12 commits that reference this issue on Oct 30, 2026
  2. added 6 commits that reference this issue on Oct 31, 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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions