Join our Newsletter — 33% off our NHI Course
Home› Guides› If your AI gateway is compromised: contain it,…
Guide AI Platforms

If your AI gateway is compromised: contain it, rotate provider keys and rebuild

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 14 November 2026 16 min read
On this page

A compromised AI gateway hands an attacker every model provider credential your organisation holds, a live feed of prompts and responses, and the switches that turn off your budgets and guardrails, all from one console. The gateway sits between applications, agents and users on one side and model providers or self-hosted inference on the other. It issues virtual keys, stores or retrieves upstream keys and cloud roles, applies content policy, caches responses and logs traffic. This playbook covers what to do once you believe the gateway itself (its admin plane, its hosts, its data stores or its deployment pipeline) has been compromised. It is vendor-neutral, for AI platform, cloud security and incident response teams, and applies to self-hosted, managed and open source gateways: confirm exact settings in your product's documentation. Theft of a single provider key without gateway compromise is handled in the LLMjacking Response Playbook, and preventive hardening is in Securing the AI gateway itself; this page does not repeat either.

Key takeaways

  • Every upstream credential is burned. If the attacker reached the admin plane, a host or the configuration store, assume every provider key, cloud role session and service account the gateway could read is exposed, and rotate them all at the provider, not in the gateway.
  • Prompt logs are a second breach. Stored prompts, responses and cached completions can hold personal data, source code and secrets pasted by users; scope them as a data breach from the first hour.
  • Policy may have been changed silently. Guardrails switched to log only, a widened model allow list or a new upstream endpoint keep working against you after the attacker loses access, so rebuild policy from version control.
  • Close the bypass before you contain. Applications that hold their own provider keys keep running when you take the gateway offline, which is good for availability and bad for scoping; know which ones they are.
  • Agents behind the gateway extend the blast radius. Where the gateway also fronts tools or MCP servers, downstream tool credentials and any responses the attacker could alter are in scope.

What an attacker gains from an AI gateway

The table describes a common gateway architecture, not any one product. The first scoping question is which of these components the attacker reached, because that decides what has to be rotated and what has to be treated as disclosed.

Component reachedWhat the attacker gainsResponse lever
Admin console or management APIMint virtual keys with unlimited budgets, add upstream endpoints, disable guardrails and logging, read stored prompts, export configuration with provider keysRevoke admin sessions and the master or bootstrap key, lock the plane to a break-glass account, rebuild configuration from source
Gateway host, container or podProvider keys in memory or environment variables, the host's cloud role or workload identity, decrypted trafficReplace hosts from a clean image, revoke workload identity sessions
Configuration databaseVirtual key records (hashed or reversible depending on product), upstream keys if stored there, team budgets, user recordsRotate everything stored, establish how keys were stored
Log, trace and analytics storeFull prompts and completions, system prompts, retrieved documents, tool call argumentsRestrict access, preserve, then purge after evidence capture; assess as a personal data breach
Response cacheCached completions from other tenants or teams; ability to poison the cache so users receive attacker-chosen answersFlush the cache, rebuild with per-tenant cache keys
Routing and model configurationSend traffic to an attacker-controlled endpoint that records or alters responsesReset routes to approved endpoints only, review every request in the window
Tool and MCP connectorsDownstream tool tokens, the ability to change which tools agents can callRotate downstream credentials, review agent actions in the window
Deployment pipelinePersistence: weakened configuration redeployed after clean-upRotate pipeline credentials, review commits and merge rights

The relevant threat descriptions are OWASP LLM10:2025 Unbounded Consumption and LLM02:2025 Sensitive Information Disclosure, MITRE ATLAS AML.T0034 Cost Harvesting and AML.T0008.005 AI Service Proxies, and ATT&CK T1496.004 Cloud Service Hijacking.

How the compromise shows up

SignalWhere to lookLikely meaning
Spend or token volume rising on keys with no matching application releaseGateway usage analytics, provider billingKeys minted or budgets raised by an attacker (AML.T0034)
Virtual keys created outside the onboarding process, or budget limits removedGateway admin audit logAdmin plane access (ATT&CK T1098.001 where keys are cloud credentials)
Provider keys used from addresses that are not gateway egressProvider usage logs, cloud audit logsUpstream keys copied out of the gateway (T1078.004, AML.T0012)
New upstream base URL or model endpointRouting configuration diffTraffic diverted for collection or response tampering (T1557)
Guardrail, PII redaction or content filter set to log only or disabledPolicy configuration diff, admin audit logDefence impairment (ATT&CK T1685 Disable or Modify Tools)
Logging level changed, log sink added or log export to an unknown destinationGateway settings, log pipelineExfiltration of prompts (T1567) or hiding activity
Bulk reads of stored prompts or log exports by an adminAdmin audit log, log store access logsCollection of sensitive conversations
Users reporting odd or unsafe answers on routine questionsHelp desk, feedback channelsCache poisoning or a malicious upstream

The joint guidance Deploying AI Systems Securely (NSA AISC, CISA, FBI and Five Eyes partners, April 2024) asks operators to monitor for unauthorised changes to AI system configuration and to keep logs in immutable storage. If your gateway logs only to its own database, assume an admin-level attacker could have edited them, and rely on provider-side and cloud-side logs for the timeline.

Triage: the first hour

  1. Establish the entry point. Admin credential (stolen SSO session, leaked master key), exploited gateway software (T1190), compromised host or cluster, configuration database, or pipeline. Note whether a security advisory exists for your gateway version.
  2. Preserve before changing. Export the running configuration, admin audit log, usage and spend records, routing and policy settings, and snapshot hosts. Copy provider-side usage logs and cloud audit logs for the gateway's roles.
  3. Diff configuration against version control. List every virtual key, budget, route, upstream, guardrail and user that differs. That list is your first scope of attacker changes.
  4. Inventory upstream credentials. Every provider API key, cloud role, service account and downstream tool token the gateway can use, with owner, provider account and where it is stored (secrets manager, environment, database).
  5. Size the data exposure. What does the gateway log, for how long, and who could read it? Which teams send personal, regulated or confidential data through it?
  6. Identify the bypass population. Which applications call providers directly with their own keys? They are not covered by gateway containment but may have been reconfigured to point at the gateway or away from it.
  7. Decide severity and owners. Spend-only abuse with no data access is serious; any access to logs, cache or routing makes it a data incident with privacy and legal involvement.

Containment by priority

  1. Stop the money first. Set hard spend limits or quotas at each model provider account and cloud AI project, because a copied upstream key bypasses the gateway's own budgets. See How to set spend limits on LLM API keys.
  2. Close the admin plane. Revoke admin sessions and API tokens, disable the master or bootstrap key, remove unknown users, and restrict the console to a management network with a single break-glass responder account. The joint AI guidance asks for separate admin accounts, phishing-resistant MFA and privileged access workstations for administration; re-establish that before anyone else gets admin back.
  3. Cut the gateway's own identities. Revoke sessions for its cloud role or workload identity, remove its read access to the secrets manager until rebuilt, and rotate pipeline deploy credentials.
  4. Revoke upstream credentials at the provider. Disable provider keys and service account keys in the provider console, not just in gateway configuration. Where workloads need continuity, issue new keys only to the clean gateway.
  5. Take the decision on service. The joint AI guidance expects operators to be able to block suspected malicious users or disconnect all inbound connections during a major incident. Options: full outage, a clean standby gateway with a minimal model list, or temporary direct access for named critical applications with fresh, capped keys.
  6. Freeze the data stores. Restrict the log store and cache to responders, stop any external log export, and flush the response cache after capturing a sample for evidence.

Rollback: keep previous routing documented so a critical application can be moved back if the clean gateway breaks it, but never back through compromised hosts or configuration.

Credentials to rotate, in order

OrderCredentialActionWhy it matters
1Gateway admin accounts, master or bootstrap key, SSO trust for the consoleRevoke, reissue, store the new master key as a split-control break-glass secretStops the attacker changing the gateway again
2Model provider API keys and cloud AI roles used upstreamRevoke at the provider, issue new per-environment credentials, set provider-side limitsUnlimited spend and access to every enabled model, fine-tuned models and stored files
3Gateway cloud role, workload identity, secrets manager access, pipeline credentialsRevoke sessions, narrow permissions, reissueThe route from the gateway to other cloud resources and back into production
4Downstream tool and MCP credentials held by the gatewayRotate at each tool, review actions taken in the windowAgents may have acted on attacker-influenced instructions
5Virtual keys issued to applications and agentsReissue in waves by risk, with a short overlap; revoke all keys created in the window immediatelyStored or observed keys let the attacker impersonate workloads and spend their budgets
6Database, cache and log pipeline credentialsRotateDirect access to prompts and key records without the console
7OAuth tokens and sessions for users and agents seen in trafficRevoke refresh tokens at the identity provider, shorten access token lifetimesBearer tokens in decrypted traffic stay usable until expiry
8TLS private keys on gateway listenersNew keys and certificates, revoke the old certificatesA copied key allows impersonation of the gateway hostname

On token revocation, RFC 7009 notes that revoking a refresh token only invalidates related access tokens where the server supports access token revocation, and that immediate revocation of self-contained tokens needs non-standardised backend interaction, so short lifetimes are the practical remedy. For rotating many keys with overlap, see Credential Rotation at Scale; for provider-specific key revocation steps, see AI model provider API keys.

Eradication and rebuild

  • Replace, do not clean, gateway hosts. Redeploy from a clean, current image or a verified release of the gateway software, with checksums or signatures checked against the publisher. Do not restore a configuration backup taken during the window.
  • Rebuild configuration from source. Re-apply reviewed declarative configuration for routes, model allow lists, budgets and guardrails. Anything that existed only in the running gateway without an owner and change record is removed.
  • Check plugins and custom callbacks. Custom guardrail code, logging callbacks and pre- or post-processing hooks can carry persistence or quietly copy prompts. Rebuild them from the repository.
  • Review every upstream endpoint. Confirm each base URL resolves to the provider or your own inference service. See the LLM Base URL and Endpoint Override Security Guide.
  • Hunt at the providers. Review provider-side logs for model enablement, fine-tuning jobs, file uploads, new projects, batch jobs and assistant or agent objects created by the gateway's credentials in the window.
  • Review responses served in the window. If routing or cache was tampered with, identify which applications received responses from the bad path and whether any downstream decision, code or agent action relied on them.

Recovery and return to service

  1. Run the clean gateway against regression tests for authentication, budget enforcement, guardrails, redaction and routing before it takes traffic.
  2. Restore low-risk, internal workloads first and watch spend, error rates and refusals for a business cycle; restore applications handling regulated data last.
  3. Complete virtual key reissue and track traffic on old keys to zero, then delete them.
  4. Move any applications that used temporary direct provider keys back behind the gateway and revoke those keys.
  5. Return admin rights only to named accounts with phishing-resistant MFA, and separate key administration from policy administration.

Where identity fits

Almost every step above is non-human identity work: provider keys, cloud roles, workload identities, virtual keys and agent tokens. The speed of the response depends on whether you already know which credentials the gateway holds, who owns them and how to rotate them without an outage. Where agents call models through the gateway with their own credentials, also follow the AI Agent Credential Compromise Playbook for each affected agent.

Evidence and notification

  • Preserve: host images, configuration exports with timestamps, admin audit logs, usage and billing records, provider-side logs, cloud audit logs for the gateway's identities, pipeline history, and a sample of cache and log entries.
  • Personal data: stored prompts often contain personal data. Under GDPR Article 33(1) the controller notifies the supervisory authority without undue delay and, where feasible, within 72 hours of becoming aware, unless the breach is unlikely to result in a risk to individuals. See the Data Breach Notification Checklist and the Cyber Incident Reporting Requirements Map.
  • Providers: open a case with each model provider to report credential misuse and ask about charges; keep the case references in the timeline.
  • AI incident reporting: NIST AI 600-1 suggests after-action reviews of incident response and disclosure, and defined criteria for reporting generative AI incidents. See AI Incident Reporting Guide.

Decision guidance

SituationChooseTrade-off
Admin account misused, hosts untouched, full prompt logging offRevoke admin access, rebuild configuration from source, rotate upstream keys readable in the consoleFast, but depends on a trustworthy admin audit log
Gateway software exploited or host compromisedReplace all hosts, rotate every credential the gateway could read, reissue TLS keysLarger rotation workload, removes implant risk
Full prompt and response logging was onTreat as a data breach, involve privacy and legal, scope by team and data classNotification work, but anything less underestimates exposure
Virtual keys stored hashedRevoke keys created or seen in the window now, reissue the rest in planned wavesLess disruption, relies on knowing which keys were observed
Virtual keys stored in plaintext or reversible formReissue all virtual keysDisruption to every application team
Managed gateway service, tenant admin stolenContain your identities that administer the tenant, rotate upstream keys, open a provider case for audit recordsScoping limited by what the service logs for you
Small team, single gateway, no standbyAllow two or three critical applications direct, capped, short-lived provider keys during rebuildTemporary loss of central policy and logging for those applications

Detection and measurement

  • Configuration drift: differences between running gateway configuration and version control, checked daily; target zero unexplained.
  • Upstream key use from outside gateway egress: provider calls with gateway credentials from any other address; target zero.
  • Guardrail state changes: policies moved to log only or disabled without an approved change; alert on every one.
  • Time to provider-side cap: minutes from declaration until every provider account has a hard limit.
  • Rotation completion: share of gateway-held credentials rotated per class, and old-key traffic falling to zero.
  • Bypass ratio: share of model traffic that reaches providers without passing the gateway.

Framework mapping

FrameworkReferenceWhere it applies
NIST CSF 2.0RS.MA-01, RS.AN-03, RS.MI-01, RS.MI-02, RC.RP-03, PR.AA-01, DE.CM-09Executing the plan, analysis, containment, eradication, verified restore, credential management, monitoring
NIST SP 800-53 Rev. 5IR-4, IR-6, IA-5, AC-2, AC-6, AU-9, CM-3, SC-12, SI-4Incident handling and reporting, authenticators, accounts, least privilege, log protection, change control, keys, monitoring
OWASP Top 10 for LLM Applications 2025LLM02, LLM03, LLM10Disclosure through logs and cache, gateway supply chain, unbounded consumption
MITRE ATLASAML.T0034, AML.T0008.005, AML.T0012, AML.T0055Cost harvesting, AI service proxies, valid accounts, unsecured credentials
MITRE ATT&CKT1190, T1496.004, T1078.004, T1098.001, T1557, T1567, T1685Exploitation, cloud service hijacking, cloud accounts, added credentials, interception, exfiltration, disabled tools

Common failure patterns

  • Rotating keys in the gateway, not at the provider. Editing the stored key does nothing if the old key is still valid at the provider; the attacker keeps spending.
  • Relying on gateway budgets during the incident. Copied upstream keys bypass them; only provider-side limits stop the spend.
  • Restoring the running configuration. A backup from the window brings back minted keys, extra endpoints and disabled guardrails.
  • Treating it as a cost incident only. Teams cap spend, rotate keys and close the ticket while full prompt logs sat readable by the attacker for weeks.
  • Forgetting the cache. A poisoned or cross-tenant cache keeps serving bad or leaked content after the hosts are rebuilt.
  • Ignoring the provider side. Fine-tuning jobs, uploaded files and new projects created with gateway credentials persist after rotation unless someone looks for them.

Practitioner checklist

  • Keep gateway configuration, routes, budgets and guardrails in version control and alert on drift.
  • Maintain an inventory of every upstream and downstream credential the gateway holds, with owner and rotation path.
  • Set provider-side spend limits on every provider account, independent of the gateway.
  • Send gateway admin and usage logs to a store the gateway admins cannot alter.
  • On compromise, cap spend at providers, close the admin plane and revoke upstream keys at the provider first.
  • Scope stored prompts and cache as a potential personal data breach from the first hour.
  • Rebuild hosts from verified releases and configuration from reviewed source.
  • Hunt provider-side for fine-tuning jobs, files and projects created in the window.
  • Reissue virtual keys in waves and track old-key traffic to zero.

Standards and references

Related NHI Mgmt Group resources: AI Gateway and LLM Gateway Guide · Securing the AI gateway itself · AI gateway health check · LLMjacking Guide · MCP Gateway and MCP Server Governance Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.