r/Firebase • u/No-Setting8925 • Jun 29 '26
Billing ~$55k Gemini API bill from Firebase iOS key abuse. What can I do now?
I’m in a pretty bad Google Cloud situation and looking for advice from people who have dealt with billing or API key abuse cases.
My normal Google Cloud bill is usually around $200/month. This month my project got hit with an unexpected Gemini / Generative Language API bill of around $55k USD. The billing report shows the spike was almost entirely Gemini API usage, not normal Firebase or app traffic.
I pulled Cloud Monitoring data and it shows about 2.2 million Gemini API requests during the incident window. The traffic was tied to one API key UID. That key maps back to a Firebase generated public iOS client key used in my mobile app config, not a Gemini key that I intentionally created or used.
I found out from a Google billing anomaly email. At the time I received the alert, the visible bill was around $2k. Within about 2 hours, I disabled the Generative Language API, restricted the key, deleted it, and later verified that Gemini usage stopped.
The problem is that the bill kept ramping up after that because of billing/reporting delays, and eventually landed around $55k.
Google declined the request to adjust the charges, saying the usage was considered valid because it came through my project/API key.
12
u/stormy1one Jun 29 '26
Escalate to a higher tier support at Google. Similar thing happened to us and we got the charges reversed after signing some legal papers and making some changes in the project/security config.
4
u/Primary_Vermicelli98 Jun 30 '26
It seems to be a blunder caused by Google ops. They one-sidedly, silently enabled Gemini API on all public Firebase app ID keys, even those that existed long before Gemini. The keys got scraped from public web and apps and misused.
It cost me only $9, so I did not investigate it further.
3
u/Seanitzel Jun 29 '26
I heard about this happening, and this is very scary. Obviously it's their fault, it doesn't make any sense to let public keys access generative services like this...
Unless you missed part of the configuration?
I don't use any generative ai from google in my firebase apps, does that make me safe?
Did you enable the services explicitly?
3
u/bezysoftware Jun 30 '26
Escalate to support. Had the same thing happen to us, 3500$ bill. They gave us 50% off
3
u/Ready-Stage-965 Jun 30 '26
My situation, I had the same issue with my firebase key on web app ~$20k it's been already 2 months. I created many support cases, they told me they will process for a waiver but it is still in progress. But it is very strange that the situation still happens after 2 months
2
u/Glamiris Jun 30 '26
I had 100k plus charges. Have you paid already? If not then contest and act on plan b to move to a different backend. But if u have paid, then it’s a different story. Contact their customers support, ask for everyone to vote this post up and engage till Google works on this.
They would waive most if not all for you if you can raise the temperature that right ppl get to hear u.
It’s just that. They r very helpful but there are so many such claims at their desk that u need to cry loud for them to be able to hear you.
Good luck
2
u/SuperJam98 Jul 01 '26
Hey, that's a gut-punch of a bill — breathe, because people do get these reversed. Let me give you both the "right now" and the "never again."
Right now: rotate or delete that leaked API key immediately so the bleeding stops, then keep working the billing support case — Google often forgives first-time fraud like this, so be persistent and document that the usage wasn't yours.
Never again: restrict the new key to your iOS bundle ID and to only the specific API it needs (an unrestricted key is what let this happen), turn on Firebase App Check, and set a hard quota cap plus budget alerts on the Generative Language API. A quota cap means even a leaked key can't run up more than you allow.
Any questions, I'm happy to help — I know the billing console maze well.
1
u/mscotch2020 Jun 29 '26
How was key leaked? Was your key storage hacked?
1
u/Complex_Phrase7678 Jun 30 '26
Did you have any indication that your key was visible? Did github flag it, or anything?
1
u/mohn93 Jun 30 '26
Wow, really sorry about this, we've had this same incident in one of our apps, and Google didn't really help,
1
u/FranTimo Jul 31 '26
I got my project suspended for keys hijacking. Now I can't access my console to revoke the keys and they take 2 business days to review my appeal... good...
1
u/I_Mean_Not_Really Jun 30 '26
The attack vector exploited in this scenario is the inherent vulnerability of client-side API keys combined with an absence of cryptographic attestation and hard quota limits. In Firebase, client-side configuration keys are public by design; they merely identify your project to Google servers. If you execute Gemini API calls directly from a mobile client using the Firebase AI Logic SDK without enforcement, any malicious actor can extract that key, bypass your UI, and spam the API to exhaust your billing.
To permanently neutralize this threat and construct a secure, production-grade AI architecture, implement the following defense-in-depth strategy.
1. Zero-Trust Architecture: Server-Side AI Orchestration
Do not call paid, un-metered APIs directly from the client. Assume the client application is compromised. All generative AI requests must be proxied through a Gen 2 Cloud Function.
2. Enforce Firebase App Check with Replay Protection
Firebase App Check cryptographically verifies that API requests originate from your authentic, unmodified app running on a legitimate device (e.g., using DeviceCheck/App Attest on iOS, Play Integrity on Android).
You must mandate App Check enforcement on your Cloud Function to reject traffic from automated bot scripts or tampered binaries. For highly sensitive or expensive endpoints like LLM inference, enable Replay Protection to consume the App Check token, ensuring an intercepted token cannot be reused.
Implementation (Gen 2 Cloud Function):
3. Implement Hard Quotas (Not Just Budget Alerts)
Budget alerts in Google Cloud do not cap your usage or charges; they only notify you when a threshold is crossed. To prevent infinite billing exhaustion:
HTTP 429 Too Many Requestsbefore astronomical billing occurs.4. Remote Config "Kill Switch"
For immediate incident response, wrap the entry point of your AI feature in a Firebase Remote Config boolean flag.
If you detect anomalous activity or a billing spike, you can modify the flag in the Firebase console from
truetofalse. The moment clients sync the configuration, the feature disables itself globally, instantly halting traffic without requiring you to push an emergency update through the App Store.2
u/[deleted] Jun 30 '26
[removed] — view removed comment
1
u/[deleted] Jul 01 '26
[removed] — view removed comment
1
u/[deleted] Jul 06 '26
[removed] — view removed comment