API Key Exposure

Cybersecurity Glossary Authentication & Access Control

API Key Exposure

When API keys or credentials are inadvertently revealed in public locations like code repositories, client-side code, or logs, enabling unauthorized access.

API Key Exposure occurs when API keys, tokens, or credentials are inadvertently revealed in public locations such as source code repositories, client-side code, logs, or documentation, allowing unauthorized access to APIs and services.

Common Exposure Locations

  • Git repositories: Committed credentials in code or config files
  • Client-side code: API keys embedded in JavaScript
  • Mobile apps: Keys in APK/IPA files
  • Public documentation: Examples with real keys
  • Log files: Keys logged in requests or errors
  • Error messages: Stack traces revealing configuration

Impact by Key Type

  • AWS keys: Full cloud account access, data breach, cryptomining
  • Database credentials: Direct database access
  • Payment API keys: Financial fraud
  • OAuth secrets: Account impersonation
  • Private signing keys: JWT forgery, code signing abuse

Prevention

  • Use environment variables, not hardcoded keys
  • Implement secret scanning in CI/CD
  • Use secrets management (Vault, AWS Secrets Manager)
  • Rotate keys regularly and after exposure
  • Restrict key permissions to minimum required

See Also