API key leaks and prevention

What the Gemini API key disclosure teaches about permission drift

Review what each cloud key can access when you enable a new API. Keep browser identifiers separate from credentials that can read private resources or trigger paid inference.

A key's permissions can change after it ships

In February 2026, Truffle Security reported that some Google API keys that had been publicly deployed could gain access to Gemini in projects where the relevant API was enabled. The same string could take on additional capabilities as services were enabled. A June follow-up described Google's move toward restricted keys backed by service accounts.

The historical finding concerns particular key and project configurations. Read the issuer's current restrictions when you audit your own setup. Avoid inferring capabilities from a key's prefix or from why it was originally created.

Audit by reachable service

  1. List keys by project and separate client identifiers from credentials used for private or billable server-side actions.
  2. Review each key's API restrictions and application restrictions. Check whether enabling another API would grant access to an older key in the same project.
  3. Use an authorised test key with no production access to verify a permitted call works and an out-of-scope call is denied. Remove abandoned credentials and rotate any capable key that was exposed.
  4. Review billing and access logs after major service or authentication changes. Keep the ownership record and rotation steps with the service documentation.

Stop secrets moving between tools

Treat credentials as server configuration. Give developers placeholders for chats and examples, and use request masking on supported surfaces. Masking is useful before an AI request leaves the controlled path. It does not set service permissions or remove an embedded secret from a shipped browser bundle.

References

Practical guides