Skip to content
Misconfiguration Write-up Beginner

An Exposed API Key Cost Me $4,000. Here Is Exactly What to Do To

A Google API key that was public by design in frontend code had Gemini API access enabled on the same project, and automated scanners found and abused it, leading to a large bill. Separately, the axios npm package was briefly compromised, installing a remote access trojan on systems that installed it during a short window.

Belkin Marketing Team Follow

Published on belkinmarketing.medium.com

A public-by-design API key in frontend code, which is architecturally normal, combined with Gemini API access being enabled on the same project, which nobody audited, combined with automated scanners that run continuously across the internet looking for exactly that combination.

Belkin Marketing Team, on belkinmarketing.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 the root cause was that a public-by-design API key was not restricted to its intended low-risk scope, and a paid service was enabled on the same project without re-scoping the key.

Impact

Automated scanners found the key and used the paid Gemini API, leading to a large bill; Google compensated roughly 75% after support negotiations, and the rest was a direct cost.

What the attacker needed

Public API key in frontend code; paid API enabled on same project; no IP restriction on key

The fix

The key should be restricted by IP or network, spending caps set low, keys given expiry and rotation, and architectural separation so agents never hold raw credentials.

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 use a paid service. Here, a key meant to be public was left able to use an expensive service, so strangers found it and ran up costs. Separately, a widely used software package was briefly replaced with a malicious version that let attackers control computers that installed it.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.