Skip to content

Claude Code hardcoded API key in markdown documentation file #12524

@BernardUriza

Description

@BernardUriza

Description

During a coding session, I asked Claude Code to save/document Azure OpenAI configuration. Instead of using environment variables in the examples, Claude Code hardcoded the actual API key directly in a markdown documentation file (AZURE_OPENAI_CURL_REFERENCE.md).

What happened

  1. I was integrating Azure OpenAI into my project
  2. I asked Claude to create documentation with curl examples
  3. Claude created the file with my actual API key hardcoded:
    export AZURE_API_KEY="2a48df168ba44526a8f3cf71ae280d3f"  # Real key!
  4. I committed and pushed without noticing (my fault for not reviewing)
  5. The key was exposed in a public repo for 11 days
  6. Hackers found it and used $30,000 USD worth of API calls

Expected behavior

Claude Code should NEVER hardcode actual API keys in any file. It should always use:

  • Placeholder values: your-api-key-here
  • Environment variable references: $AZURE_API_KEY
  • Or at minimum, warn the user about the security risk

Suggested improvements

  1. Add a safety check that detects when Claude is about to write something that looks like an API key
  2. Always use placeholders in documentation examples
  3. Warn users before committing files that contain potential secrets

Impact

  • $30,000 USD fraudulent charges
  • Lost employment

Commit reference

f3ac3f6 - "feat: Integrate Azure OpenAI as LLM provider alongside Claude and Ollama"

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corearea:securityautocloseIssue will be closed automaticallybugSomething isn't workinghas reproHas detailed reproduction steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions