Stolen Keys, Not Stolen Models: The Long-Lived AI Credential Problem Nobody Budgeted For
AI security coverage obsesses over prompt injection and model theft, but the bigger immediate risk is far more boring: static, long-lived API keys attached to expensive inference budgets. Here's a short-lived-credential migration playbook for Bedrock and Gemini.
A developer at a mid-sized Midlands retailer wired Google's Gemini into their customer support tool over a long weekend in 2026. It worked beautifully. They pasted the API key straight into an environment variable, pushed to the shared repo so the rest of the team could test, and moved on. Six weeks later the finance director flagged a £9,000 charge from Google that nobody could explain. The key had leaked — probably through the repo, possibly through a misconfigured container log — and someone on the other side of the world had been quietly running inference on it for a fortnight.
No model was stolen. No clever prompt injection was involved. Nobody needed to be a security researcher. They just found a key that worked and used it until the money ran out.
This is the AI security story that doesn't get written, because it isn't exciting. The headlines go to prompt injection demos and jailbroken chatbots. Meanwhile the thing actually costing UK businesses money is the oldest mistake in cloud computing, dressed up in new clothes: static, long-lived credentials, now attached to an inference bill that can climb into four figures a day.
The research that should worry you
In November 2026, Datadog published its latest look at how teams actually run AI in production, and the numbers are sobering. Nearly half of Gemini users in the dataset were relying on long-lived API keys — the kind that never expire, that sit in config files and CI pipelines and the occasional Slack message, that keep working until a human remembers to revoke them.
That figure matters because it mirrors a pattern cloud providers spent a decade trying to stamp out. Back when everyone was moving to AWS, the standard foot-gun was the long-lived IAM access key committed to a public GitHub repo. Bots scraped GitHub for those keys within minutes and spun up crypto-mining fleets. AWS eventually built automated scanning, quarantine policies, and a loud drumbeat of 'use roles, not keys' to deal with it.
We have, collectively, forgotten all of that. The rush to ship AI features has recreated the exact same mistake, except the blast radius is different. A stolen AWS key might mine crypto. A stolen Gemini or Bedrock key burns through your inference budget and, depending on how you've wired things up, hands an attacker a pipe into whatever data your application feeds the model.
Why this is a FinOps problem, not just a security one
Most organisations treat credential hygiene as a security concern and inference cost as a finance concern, and the two teams rarely talk. That separation is exactly why this slips through.
A leaked database password is bad, but databases don't bill you per query at pennies a time with no ceiling. Large language model APIs do. The cost model is pay-as-you-go, the per-request price is small enough to feel harmless, and the volume an attacker can generate is effectively unlimited. You can rack up thousands of pounds before an anomaly alert fires — assuming you set one up.
There's a second-order problem too. Because inference is metered, a compromised key doesn't just cost you money directly. It can trip rate limits and quota ceilings that take your legitimate application offline, so your customers feel the breach before your finance team spots it.
So the right way to frame long-lived AI keys is as a joint liability. The security team owns the leak. The FinOps team owns the bill. Both of them should be nervous about the same thing.
What short-lived credentials actually buy you
The fix is not revolutionary. It's the same thing cloud security landed on years ago: stop issuing permanent keys and start issuing credentials that expire in minutes or hours and are tied to a specific workload identity.
When a credential lives for fifteen minutes, a leaked key is worth very little. By the time it shows up in a scraped repo or a log aggregator, it's already dead. There's nothing to mine, nothing to drain, nothing to exfiltrate. You've shrunk the window of exposure from 'forever' to 'the length of a coffee break'.
The trade-off is a bit more plumbing up front. Here's how to do it on the two platforms most UK teams are shipping with.
Migration playbook: Amazon Bedrock
Bedrock has the advantage of living inside AWS's existing identity system, so the tools already exist. If you're calling Bedrock with a long-lived IAM user access key, you're doing it the hard, dangerous way.
-
Replace IAM users with roles. Create an IAM role with a tightly scoped policy — ideally limited to the specific Bedrock models you actually invoke, not
bedrock:*. Grant onlyInvokeModelandInvokeModelWithResponseStreamwhere those are all you need. -
Use the right identity source for your runtime. If your app runs on ECS or EKS, attach the role via task roles or IAM Roles for Service Accounts (IRSA). On EC2, use the instance profile. These hand your code temporary credentials that rotate automatically — you never see a static key.
-
For anything outside AWS, use OIDC federation. GitHub Actions, on-prem workloads, and third-party CI can assume an AWS role via OpenID Connect without a stored secret. The CI job proves its identity, AWS hands back credentials that expire in an hour.
-
Set per-model budget guardrails. Use AWS Budgets with actions and CloudWatch alarms on Bedrock invocation metrics. If spend spikes, you want a human paged within minutes, not a surprise at month-end.
-
Audit for residual keys. Run IAM Access Analyzer and check for any IAM users with Bedrock permissions. Every one of them is a liability. Deactivate, then delete.
Migration playbook: Google Gemini
Gemini is where Datadog found the worst habits, partly because the quickest route to a working prototype — a raw API key from AI Studio — is also the least safe. For anything beyond a throwaway experiment, move off it.
-
Use Vertex AI instead of the raw Gemini API. Vertex AI gives you access to Gemini models through Google Cloud's proper IAM system, which means service accounts and short-lived tokens rather than a flat string.
-
Prefer attached service accounts over keys. On Cloud Run, GKE, or Compute Engine, attach a service account to the workload. Google's metadata server issues short-lived access tokens automatically. No key file ever touches your code or your repo.
-
Kill service account key files. The downloadable JSON key is the Gemini equivalent of the leaked IAM key. If you have them, plan to remove them. Use the organisation policy constraint that disables service account key creation entirely once you've migrated.
-
Use Workload Identity Federation for external runners. Same principle as AWS OIDC — your GitHub Actions or external workload proves who it is and gets a token that expires, rather than storing a Google credential.
-
Set quotas and budget alerts per project. Cap the requests-per-minute quota on your Gemini-enabled project to something realistic for your traffic. An attacker who somehow gets in still can't run away with your budget, and you get a signal the moment the ceiling is hit.
Where to start if this describes you
You don't need a six-month programme. Start by answering one question: can you list every long-lived API key or service account key that can reach an AI model, and who has access to each? If you can't, that's your first job.
From there, the order of work is simple. Stop creating new static keys today — make short-lived credentials the only sanctioned path. Then migrate your production workloads, which carry the most spend and the most data. The forgotten keys in test environments can wait, but don't let them wait forever; attackers don't care which environment they found the key in.
The teams who get burned by this won't be the ones who fell for a clever attack. They'll be the ones who shipped fast, pasted a key into a config file, and never came back to it. The model was never the valuable thing. The key was.
