Skip to content

High: setup.py exposes API keys during interactive configuration #1

Description

@tg12

Severity: High

Evidence:

  • scripts/setup.py:46-51 uses input() for prompts, so values typed for secret prompts are echoed by the terminal.
  • scripts/setup.py:178-186 asks for OPENAI_API_KEY, ANTHROPIC_API_KEY, and GEMINI_API_KEY values through that echoed prompt path.
  • scripts/setup.py:60-89 writes KEY=value to .env, then prints the full Set {key}={value} string on stdout.
  • .env.example:33-39 documents those values as API keys.

Reproduction:

  1. Run python3 scripts/setup.py.
  2. Choose provider openai, anthropic, or gemini.
  3. Enter any token-like value, for example sk-test-redacted.
  4. Observe that the value is visible while typing and then printed again as Set OPENAI_API_KEY=sk-test-redacted.

Impact:
API keys are exposed in terminal scrollback, shell/session recording, CI logs if setup is scripted, and AI-agent transcripts. This is especially risky for a repo designed to be operated by coding agents.

Smallest credible fix:

  • Use getpass.getpass() for secret prompts.
  • Treat keys matching *_API_KEY, *_TOKEN, *_PASSWORD, and similar names as sensitive in _patch_env() and print only a masked confirmation such as Set OPENAI_API_KEY=<redacted>.
  • Avoid echoing existing secret values during reconfiguration.
  • Add a small test around _patch_env() output redaction for sensitive keys.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions