Skip to content
VibePaper

WorkflowVibePaper15 min read

API Key Leaks and Billing Abuse: Lessons for AI Apps

A leaked AI key is not a slow leak anymore. Bots find it in minutes, scripts spend it in hours, and the invoice arrives anyway. Here is how keys really get out, what OpenCode, REA and Render teach, and the setup we would insist on before shipping any AI app.

A brass key on a dark desk next to a laptop, with red light draining away from it

Billing abuse used to be a slow leak: a key pushed to a public repo, a few dollars here and there, noticed at the end of the month. With AI APIs it is a flood. One working key can be scripted into thousands of expensive model calls before anyone looks at a dashboard, and the money is gone by morning.

I want this piece to be useful rather than scary, so two rules. Every number links to whoever published it. And where the public record is thin, we say so instead of filling the gap with a guess.

What one leaked key has cost
  • $82,314.44

    spent on one stolen Gemini key in about 48 hours, by a three-person startup that normally spends around $180 a month. The Register

  • $100,000+/day

    Sysdig’s estimate for stolen access to Claude 3 Opus on AWS Bedrock, run flat out. Sysdig

  • $46,080/day

    the same calculation for Claude 2: quota limit times token price times 24 hours times four regions. Sysdig

  • $1,700+

    reported by one OpenCode Console user after a single night. BleepingComputer

Tick bars are drawn to scale against the largest figure. Sysdig’s numbers are worst-case estimates, not invoices.

Video: VibePaper. A leaked key keeps draining until someone shuts it off.

How a key actually gets out

Most leaks are boring. Nobody breaks in. Someone publishes the key by accident and a machine reads it. There are four doors worth knowing, and they all open onto the same room.

From leak to invoice
  1. 01Public repos and front-end bundles
  2. 02Reverse-engineered apps
  3. 03Malicious packages, actions and skills
  4. 04CI logs and infostealers
A key that still works
  1. Scripted generation
  2. Resold model access
  3. Distillation data

Your invoice

Illustrative. Each door is documented in the sources below; no single incident used all four.

Public repos and front-end bundles

GitGuardian counted about 29 million new secrets in public GitHub commits in 2025, up 34% in a year. 1,275,105 of them belonged to AI services, up 81%. Commits written with Claude Code leaked at about 3.2%, roughly twice the baseline, which says more about rushed humans than about the tool. Separately, Truffle Security found 11,908 credentials that still worked in one Common Crawl snapshot of the public web, the kind of dataset models are trained on.

Front-end code is the sneakier version. In February 2026 Truffle Security showed that Google API keys, which Google had long said were fine to paste into web pages for Maps or Firebase, quietly became Gemini credentials once someone enabled the Gemini API in the same project. They found 2,863 such live keys on public websites, including Google’s own. Nobody leaked anything. The meaning of the key changed underneath it.

Reverse-engineered apps

Anything inside a mobile or desktop app is public, it just takes effort to read. REA made that effort close to zero, which is why it gets its own section below.

Malicious packages, actions and skills

In August 2025 malicious versions of the Nx build tool were live on npm for a few hours. Their install script hunted for tokens, SSH keys and .env files, and even drove the local AI coding CLIs it found, with safety flags switched off, to search the disk. Wiz later saw more than a thousand valid GitHub tokens and dozens of cloud credentials in the dumps. Three weeks later the Shai-Hulud worm used stolen npm tokens to publish itself into more packages; CISA counted over 500. Agent skills are the newest member of this family, and the Render case below shows how.

CI logs and infostealers

In March 2025 the tj-actions/changed-files GitHub Action, used by more than 23,000 repositories, was rewritten to print runner secrets into build logs. On a public repo, anyone can read those logs. On laptops, infostealer malware lifts saved passwords and sessions wholesale, which is how Render user logins ended up in a credential dump without Render itself being breached.

How fast a leaked key gets used

The honest answer: faster than you will notice, and for longer than you would guess.

The clock after a key goes public
  1. 0 min
    The key is public

    A commit, a JavaScript bundle, a build log, a pasted config.

  2. < 5 min
    First use

    Unit 42 planted AWS keys on GitHub. The EleKtra-Leak campaign found and used them within five minutes, and started reconnaissance four minutes after AWS had already quarantined the key.

  3. 3 h
    61,000 requests

    Sysdig watched attackers fire most of their Bedrock traffic, 61,000 requests, in one three-hour window on July 11, 2024.

  4. 48 h
    $82,314.44

    The stolen Gemini key above, mostly spent on Gemini 3 Pro Image and Text between February 11 and 12, 2026.

  5. 2+ yrs
    Still working

    GitGuardian found 70% of secrets leaked in 2022 were still valid in 2024. Its 2026 report puts the share of valid 2022 secrets still not revoked at 64%.

The last row is the one that should bother you. Deleting the file does not kill the key. Rewriting git history does not kill the key. Making the repo private does not kill the key. Only revoking it at the provider does.

The attacker never touches your infrastructure. They just scrape a key from a public webpage.

Joe Leon, Truffle Security

Why AI keys are the expensive kind

A leaked database password is a data problem. A leaked model key is a money problem, and a fast one. Three reasons.

  • There is nothing to install. Cryptojacking needs servers; a model key just needs a loop. Sysdig’s worst case is simple arithmetic: rate limit times price times hours times every region you enabled.
  • Someone actually wants the output. Truffle Security makes the case that stolen keys pay for model distillation: the attacker collects a strong model’s answers to train their own, and you fund the teacher. They cite Anthropic’s report of proxy services built on stolen credentials of real companies and individuals.
  • Limits are higher than you think, and alerts are not brakes. Published monthly limits start at $250 to $500 on the first paid tier at OpenAI, Anthropic and Google, and reach $200,000 at the top. OpenAI’s spend alerts leave requests running, and Google documents roughly ten minutes of billing delay, so a budget is not a ceiling.

OpenCode: keys stored in a console, drained overnight

OpenCode is an open source AI coding agent. Alongside the local app and CLI it runs OpenCode Console, a hosted platform where users can link their own provider keys for OpenAI, Anthropic, Google and others. Console stores the credential and forwards requests through its gateway, and the provider bills the customer.

OpenCode, as reported
  1. Oct 16, 2026
    Night, US Eastern time

    Attackers reach what TechCrunch describes as an older system and the keys stored in Console workspaces.

  2. Oct 17, 00:30 UTC
    Earliest possible exposure

    The time OpenCode’s follow-up gives for when keys could first have been read.

  3. Oct 17
    Disclosure

    1.4% of Console users are affected, all with external providers linked. OpenCode emails them and links the attack to large-scale distillation; some commentators call it a plain breach.

  4. Oct 17–19
    Bills and revocations

    Users report charges in the hundreds, some above $1,000, one over $1,700 overnight, and suspended Google Cloud projects. Anthropic and Google revoke exposed keys; OpenAI works with OpenCode on refunds.

  5. 48 h after
    Still knocking

    Co-founder Dax Raad says attackers kept trying to get back in for two days.

The local CLI and desktop app were not affected, because those keys never reach OpenCode’s servers. That is the whole lesson in one sentence. Truffle Security put it more bluntly: a service that holds your key makes its storage, backups and retired systems part of your security boundary.

Every place that stores a key for you is a place that can lose it for you.

This is not an argument against hosted tools. It is an argument for giving each one its own key, with its own cap. The users who had per-key limits and alerts lost an evening. The ones who did not lost real money.

REA: anything you ship to the client is public now

The "reverse engineering app" people keep mentioning is REA, short for Reverse Engineer Anything (github.com/morluto/rea). It is an open source MCP server and CLI that gives a coding agent tools to inspect native binaries, JavaScript and Electron apps, .NET assemblies, APK and IPA archives, websites and saved network captures. It sat quietly on GitHub from April 2026, then topped GitHub Trending for most of October 6 to 12 and passed 100,000 stars within days.

To be fair to the project: REA is not a key-stealing tool, and its network-capture inspection deliberately leaves authorization headers, cookies and URL credentials out of its evidence. That is not the point. Opening an app bundle, reading its JavaScript and mapping its API calls used to cost a skilled person an afternoon. Now an agent does it on request. If your app ships a provider key, a signing secret or an unauthenticated endpoint that spends money, assume someone has already read it.

Render: stolen passwords and a token sent to a domain nobody owned

We looked for a recent Render billing-theft incident and found none in public reporting, so we will not invent one. What Render has published is still worth reading, because both cases are about credentials leaving the place they belong.

In October 2025 a researcher told Render that a dump of stolen credentials included logins for some Render users. Render’s write-up is clear the platform was not breached: infostealer malware on users’ own devices harvested the passwords. Render reset them, invalidated sessions, and built monitoring that scans breach datasets for Render credentials and forces resets.

The second case is stranger. An official OpenAI skill for deploying to Render told agents to send traffic to render-internal.com, a domain nobody had registered. AIR Security registered it, pointed it at a passive sinkhole, and started receiving live, token-bearing calls from real production apps. Render removed the references on August 14, 2026, OpenAI pulled the plugin on August 26, and the research went public on October 16. No billing loss was reported. It is here because it is the cleanest example yet of an agent copying a secret-handling mistake straight into production.

Older history fits too: in 2021 The Record listed Render among the free compute platforms crypto-mining groups farmed by signing up account after account. Free credit is money, and it gets treated that way.

The defense playbook

None of this is exotic. Most incidents above would have been an annoyance instead of a loss with three or four of these in place. In order of how much pain each one saves.

Six layers of defense, from keeping keys off the client to anomaly detection and incident response
Each layer assumes the one above it has already failed.

1. Stop keys at the commit, and scan what you ship

Turn on GitHub secret scanning with push protection, so a recognised key is rejected at git push. It is free on public repositories; private ones need GitHub’s paid Secret Protection. Add a pre-commit hook so the key never leaves the laptop. Then scan the build output, because a key injected at build time never shows up in the source.

Push protectionbash
# Secret scanning + push protection for one repository
gh api -X PATCH repos/OWNER/REPO \
  -f 'security_and_analysis[secret_scanning][status]=enabled' \
  -f 'security_and_analysis[secret_scanning_push_protection][status]=enabled'
Pre-commit hookyaml
# .pre-commit-config.yaml
repos:
  - repo: https://github.com/gitleaks/gitleaks
    rev: v8.24.2
    hooks:
      - id: gitleaks
Scan the bundle and historybash
# Scan what you ship, not only what you commit
npm run build
trufflehog filesystem ./dist --only-verified --fail

# Once: the whole git history
trufflehog git file://. --only-verified

2. Never ship a provider key to a client

No model key belongs in a mobile app, a desktop bundle, a browser extension or front-end JavaScript, obfuscated or not. Put a thin server in front of every paid API. The client proves who the user is; your server decides whether the call is allowed, picks the model, caps the tokens, and holds the real key. This is also where your only real brake lives: a per-user budget you enforce yourself.

A proxy with a budgetts
// server/generate.ts: the only place the provider key exists
const DAILY_BUDGET_USD = 5;

export async function generate(req: Request, user: User) {
  if (!(await limiter.allow(`gen:${user.id}`, { perMinute: 6 }))) {
    return new Response('Too many requests', { status: 429 });
  }
  if ((await ledger.spentToday(user.id)) >= DAILY_BUDGET_USD) {
    return new Response('Daily budget reached', { status: 402 });
  }
  const { prompt } = await req.json();
  const upstream = await fetch(PROVIDER_URL, {
    method: 'POST',
    headers: { Authorization: `Bearer ${process.env.PROVIDER_API_KEY}` },
    body: JSON.stringify({
      model: ALLOWED_MODEL,          // the client never picks the model
      input: String(prompt).slice(0, 4000),
      max_output_tokens: 800,
    }),
  });
  await ledger.record(user.id, upstream.clone());
  return upstream;
}

3. One key per job, scoped and short-lived

One key per service, per environment, per third-party tool, restricted to the APIs it needs. If you use Google Cloud, check every project for the Generative Language API and restrict old browser keys now. In CI, prefer short-lived OIDC credentials over long-lived secrets, pin actions to a commit SHA, and keep the default token read-only.

Restrict keys, set budget alertsbash
# Lock a browser key to the one API it needs
gcloud services api-keys update KEY_ID \
  --api-target=service=maps-backend.googleapis.com \
  --allowed-referrers="https://example.com/*"

# Budget alerts at 50% and 90%: an alarm, not a brake
gcloud billing budgets create \
  --billing-account=BILLING_ACCOUNT_ID \
  --display-name="ai-spend" \
  --budget-amount=200USD \
  --threshold-rule=percent=0.5 \
  --threshold-rule=percent=0.9
CI that leaks lessyaml
# .github/workflows/ci.yml
permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      # Pin third-party actions to a full commit SHA, never a moving tag
      - uses: actions/checkout@<full-40-character-commit-sha>
      # No install scripts in CI unless a package truly needs one
      - run: npm ci --ignore-scripts

4. Caps that stop, alerts that wake someone

Set a hard monthly limit at every provider and per-project or per-key caps where they exist, close to what you actually spend rather than the tier maximum. Send alerts somewhere a human sees at 2 a.m., not a shared inbox. And remember the lag: provider billing data can trail reality by minutes, which is why the app-level budget in step 2 matters.

5. Watch for the shape of abuse

Abuse looks different from use. A key suddenly calling a model it never used. A brand-new account spending ten times the normal rate. Requests at 4 a.m. from a region you do not serve. Bursts of sign-ups from throwaway email domains chasing free credit. Compare each key to its own history, not to a global threshold.

Hourly anomaly checksql
-- Keys spending 5x their own 14-day hourly average, in the last hour
SELECT u.key_id, sum(u.cost_usd) AS last_hour
FROM usage_events u
WHERE u.created_at > now() - interval '1 hour'
GROUP BY u.key_id
HAVING sum(u.cost_usd) > 5 * (
  SELECT coalesce(avg(h.spend_usd), 0.5)
  FROM hourly_key_spend h
  WHERE h.key_id = u.key_id
    AND h.hour > now() - interval '14 days'
);

6. Make rotation boring

If rotating a key needs a meeting, you will not do it at 2 a.m. Keep keys in a secret manager, deploy them by reference, and support two live keys at once so you can swap without downtime. Rehearse it once a quarter. The 64% of old secrets still unrevoked are mostly keys nobody knew how to rotate safely.

The first hour after a leak

Print this. When the alert fires, work top to bottom and do not skip step one to investigate first.

First-hour runbook0/6

Tick as you go. Nothing is saved; this page just keeps count.

Be ready for the refund to be refused. In the $82,000 case, the developer says Google pointed to its shared responsibility model. Refunds happen, as OpenAI did with OpenCode users, but plan as if this one will not.

Where VibePaper goes from here

We build an AI creation product and pay for model calls every day, so this problem is never far from our minds. We are turning what we have learned into security solutions for teams who ship AI apps, and VibePaper will offer them in the future. We will share more when it is ready, and not before.

Sources

TechCrunch: Hackers hit AI coding tool OpenCode2026-10-19BleepingComputer: OpenCode hack exposes API keys2026-10ctxsec: OpenCode Console breach timeline2026-10Truffle Security: Model distillation, why attackers want your API keys2026-10-22Truffle Security: Google API keys weren’t secrets, then Gemini changed the rules2026-02-25The Register: Dev stunned by $82K Gemini bill2026-03-03GitGuardian: State of Secrets Sprawl 20262026-03-17GitGuardian: State of Secrets Sprawl 20252025-03-11Truffle Security: 12,000 live API keys in Common Crawl2025-02Unit 42: EleKtra-Leak, exposed IAM keys used within minutes2023-10Sysdig: LLMjacking2024-05Sysdig: The growing dangers of LLMjacking2024-09GitHub advisory: tj-actions/changed-files (CVE-2025-30066)2025-03CISA: tj-actions and reviewdog supply chain compromise2025-03-18Nx: s1ngularity postmortem2025-08Wiz: s1ngularity supply chain attack2025-08CISA: Shai-Hulud npm compromise2025-09-23REA on GitHub (morluto/rea)READMEDEV Community: rebuilding an API contract from a HAR file with REA2026-10Render: Your Render password is worthless2025-11-18CSO Online: Hallucinated domain in official OpenAI skill2026-10-16The Record: Crypto-mining gangs on free cloud platforms2021

Questions

What should I do first if my AI API key leaks?

Revoke it at the provider immediately, before investigating. Then issue a replacement with a lower cap, and check usage since the earliest possible exposure.

Does deleting the commit or making the repo private fix a leaked key?

No. Scanners copy keys within minutes, and GitGuardian found most leaked secrets stay valid for years. Only revoking the key at the provider ends the exposure.

Is it safe to put an API key in a mobile app if I obfuscate it?

No. Tools like REA let an agent inspect app bundles on request. Keep provider keys on your server and call them through a proxy that enforces per-user budgets.

Will a billing alert stop the charges?

Not by itself. Alerts notify; hard limits stop. Provider billing data can also lag by minutes, so enforce your own per-user budget in your server as well.

Try it on the canvas

Every guide here maps to something you can open in the workspace. Start with the prompt from the article and change one thing.

Open the workspace