Skip to content

[Security] init echoes API keys in the terminal while they are entered #313

Description

@404-Page-Found

Description

The API-key setup prompt is implemented with the normal text() prompt rather than masked/password input. The prompt therefore echoes the secret as it is typed into the terminal.

The warning text says the key will be stored in config, but it does not warn that the interactive input itself is visible on screen.

Location

  • src/commands/init.ts:148-157 — promptApiKey()
  • src/commands/init.ts:126-133 — buildApiKeyPrompt()

Relevant code

const existingKey = existingConfig?.apiKey ?? process.env[provider.apiKeyEnv] ?? '';
const keyResult = await text(buildApiKeyPrompt(existingKey, provider.apiKeyEnv));

buildApiKeyPrompt() only supplies the message and placeholder; the returned options do not configure masked input.

Steps to Reproduce

  1. Run commit-echo init.
  2. Select a provider that requires an API key.
  3. Type an API key into the prompt.
  4. Observe that the entered characters are rendered in the terminal like ordinary text input.

Expected Behavior

Secret input should be masked while typing, consistent with password/credential prompts.

Actual Behavior

The API key is echoed to the terminal as it is entered, exposing it to anyone viewing or recording the terminal session.

Suggested Fix

Use the prompt library's password/masked input mode for API keys. Keep the non-secret placeholder and existing-key messaging, but never display the credential characters themselves.

Impact

Users can disclose provider credentials to people looking at the terminal or to terminal/session recordings.

Reviewed against current main at 6c01ad0a853501e9617a3af0a5db3b515dd8ed53.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingp1High priority; blocks core functionality

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions