Skip to content
Leaked secrets Write-up Beginner

Identifying Publicly Leaked OpenAI and Anthropic API Keys

Internet-facing assets were found exposing OpenAI and Anthropic API keys through Next.js page data, publicly accessible .env files, client-side JavaScript, and debug pages. An attacker could use these keys for unauthorised AI API usage charged to the organisation, or chain them with other exposed credentials.

medium.com

Published on medium.com

As organizations increasingly integrate artificial intelligence into their services, API tokens issued by providers such as OpenAI and Anthropic have become critical credentials for application operations. However, API tokens intended exclusively for server-side use are sometimes exposed through web pages, environment…

Criminal IP, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely secrets intended for server-side use were serialised into client-delivered data, placed in publicly served files, or embedded in browser JavaScript, rather than kept in server-only storage.

Impact

An unauthorised party could use the exposed token within its permissions, rate limits, and spending limits, potentially causing charges, quota exhaustion, or broader compromise if other credentials were exposed alongside it.

What the attacker needed

Internet-facing asset with exposed key; no authentication needed to view it

The fix

Exposed keys should be revoked and rotated, secrets should be kept in a secrets manager and retrieved only server-side at runtime, frontend frameworks should be checked so server-only variables are not serialised to the browser, and secret scanning should run in CI/CD.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

An API key is like a password that lets software talk to a paid service, such as an AI provider. Here, those passwords were accidentally left where anyone on the internet could read them, for example in a web page's hidden data or a file that should have been private. Someone who finds such a key could use the organisation's AI account, possibly running up bills or misusing the service.

What is Leaked secrets?

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.

Similar reports

View all

Same bug class and techniques, clearest first.

Leaked secrets and credentials

The lesson behind this report.

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.