Security researchers at Truffle Security have uncovered a critical flaw in Google’s API key system. Legacy public-facing Google API keys can quietly access sensitive Gemini AI endpoints without developer warnings. This exposes private files, cached data, and billable AI usage to attackers.
The Hidden Upgrade Risk
For years, Google advised developers to embed API keys in client-side code for services like Google Maps and Calendar.
These keys acted as harmless project identifiers for billing, safe to expose publicly. But enabling the Generative Language API on an existing project silently upgrades these keys into powerful credentials.

Truffle Security reports thousands of such keys now linger on the public internet as live Gemini access tokens. The root cause? Google’s insecure defaults.
New API keys start “unrestricted,” granting access to every enabled API in the project. With no separation between public billing IDs and secret auth tokens, privilege escalation is inevitable.
Simple Exploitation Path
Attackers scrape public GitHub repos or websites for exposed keys common in front-end code. They then send direct requests to Gemini endpoints. No alerts trigger.
Results? Attackers steal private datasets, read cached contexts, and run costly AI queries, racking up bills in thousands of dollars.

Truffle’s research shows even Google’s own keys were vulnerable until recent fixes.
| Feature | Legacy Public API Keys | Upgraded Gemini Keys |
|---|---|---|
| Primary Purpose | Public project ID and billing | Sensitive auth and data access |
| Deployment Location | Client-side HTML/JS | Secure backends only |
| Exposure Risk | Low; harmless if leaked | High; leaks private AI data |
| Default Config | Unrestricted across project APIs | Unrestricted; needs manual limits |
Google now defaults new AI Studio keys to Gemini-only access and blocks known leaked credentials. But legacy projects remain at risk.
- Audit Google Cloud dashboards for Generative Language API enablement.
- Scan for unrestricted public keys using tools like TruffleHog.
- Rotate all client-side keys immediately.
- Enforce key scoping and service accounts for AI APIs.
- Integrate code scanners in CI/CD to detect exposures.
This flaw underscores the perils of layering AI on outdated cloud designs. Developers must treat all API keys as secrets now. Organizations ignoring audits face data theft and surprise costs.
Follow us on Google News, LinkedIn and X to Get More Instant Updates. Set Cyberpress as a Preferred Source in Google