AppKavo
Guide · Incident · Updated 9 October 2026

API key leaked? What to do right now

Do these three things, in this order: 1. Revoke or rotate the key in the provider’s dashboard, so the copied key stops working. 2. Stop the bill: turn on a hard spending limit where the provider has one, because most budget alerts only email you; they don’t stop anything. 3. Find how it leaked and fix that before you put a new key anywhere. Then contact the provider’s support about charges you didn’t make.

Can you cap spending, or only get alerts?

ProviderStops requests at a limit?
OpenAIYes, if you turn it on. Spend alerts only notify; “Enforce a hard limit” makes requests fail. Enforcement isn’t instant, so spend can slightly exceed it.
AnthropicYes. A spend limit you set makes requests fail until you raise or remove it.
Google Cloud / FirebaseMostly no. Budget alerts don’t cap spending. Spend cap budgets that pause usage exist only for some services (Gemini API, Vertex AI, Cloud Run).
AWSNot by default. Budgets alert, and charges can pass the threshold before you’re notified. Budget actions can apply an IAM policy or stop specific EC2 or RDS instances.
StripeNot usage-billed the same way. Use restricted keys and access policies to limit what a key can do.

OpenAI

  1. Create a new key, update your server to use it, then revoke the old one once the new one works.
  2. Under spend limits, turn on Enforce a hard limit for the organization or project, so runaway use fails instead of billing you.
  3. Check usage in the organization usage page for activity you don’t recognise, and keep the details for support.

Anthropic (Claude)

  1. In the Claude Console, open API Keys and delete the leaked key. Create a new one and keep it in a secrets manager, not in your code.
  2. Set a spend limit under Billing. When it’s reached, requests fail until you raise it.
  3. Check the Usage page, and contact Anthropic support about activity you didn’t make.

Stripe

  1. In the Dashboard, choose Rotate key. Stripe creates a new key and sets the old one to expire; pick an expiry long enough to switch over (both keys can work for up to 7 days), or Now to kill it immediately.
  2. Update your backend, confirm it works, then delete the compromised key.
  3. Check the key’s request logs, refund any fraudulent charges to your customers, and pause suspicious payouts.
  4. Going forward, Stripe recommends restricted keys for most uses, so a leaked key can do less.

Google Cloud and Firebase

  1. In Google Cloud’s Credentials page, Rotate key, update your app, then delete the previous key.
  2. Restrict the new key: an application restriction (your website’s referrer, or your Android or iOS app) and API restrictions to only the APIs it needs. Google notes app restrictions alone are easy to bypass.
  3. For the Gemini API, Vertex AI or Cloud Run, you can set a spend cap budget that pauses usage when reached. For other services, budgets only send alerts.
  4. Contact Cloud Billing support about charges from the compromise; Google reviews these case by case.

About Firebase keys: Google says Firebase API keys are fine to include in your app, because access is controlled by Security Rules and App Check, not by the key. Still restrict them. The exception: a Gemini API key should never be in your code or config.

AWS

  1. Create a new access key and update your app. Deactivate the old key first (don’t delete it yet), and delete it once everything works.
  2. In CloudTrail’s Event history, look for things you didn’t do: new access keys, users, roles or policies. Remove them.
  3. Check for unexpected resources in all regions, not just the one you use.
  4. If AWS notified you, respond in the AWS Support Center. Ask support about the charges.

Supabase

A secret or service_role key bypasses all Row Level Security, so treat it as a full database leak. Supabase’s order: fix how it leaked first, create a new secret key, replace it everywhere, confirm nothing uses the old one, then delete it (that can’t be undone). For legacy keys, deactivate them. The public anon or publishable key is different and fine to ship; see Is the Supabase anon key safe?

Why nobody warned you

GitHub scans public repositories and reports leaked keys to providers including OpenAI, Anthropic, Stripe, Google, AWS and Supabase. But a key in your deployed JavaScript bundle or your published Android or iOS app isn’t in a repository, so that net doesn’t catch it. It’s a common way vibe-coded apps leak keys: a secret put in a VITE_ or NEXT_PUBLIC_ variable ends up in code every visitor downloads.

Find the leak before you deploy the new key

Check whether a key is still exposed

AppKavo’s free scan reads your live app the way an attacker would and flags keys in the bundle, with what each could cost you. Read-only, no signup.

Scan my app free

Questions

Will I get the money back?

Not guaranteed. Google Cloud says to contact Cloud Billing support and reviews cases individually. For others, contact support with the details and dates; don’t count on a refund.

The key was only live for a few minutes. Do I still need to rotate it?

Yes. Once a key has been public, you can’t know who copied it, so treat it as compromised.

Does the free scan check APKs too?

The URL scan covers deployed web apps. For Android and iOS builds, the APK audit searches every file in the package for the same keys.

Sources

Checked 9 October 2026 against each provider’s own documentation: OpenAI spend limits and production best practices; Anthropic compromised key help and rate and spend limits; Stripe compromised keys and API keys; Google Cloud API keys, budgets, spend caps and billing issues; Firebase API keys; AWS potential account compromise and budgets; Supabase API keys; GitHub secret scanning. Providers change their consoles often; follow their current docs if a button name differs.

More guides: all guides