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 reached | What the attacker gains | Response lever |
|---|---|---|
| Admin console or management API | Mint virtual keys with unlimited budgets, add upstream endpoints, disable guardrails and logging, read stored prompts, export configuration with provider keys | Revoke admin sessions and the master or bootstrap key, lock the plane to a break-glass account, rebuild configuration from source |
| Gateway host, container or pod | Provider keys in memory or environment variables, the host's cloud role or workload identity, decrypted traffic | Replace hosts from a clean image, revoke workload identity sessions |
| Configuration database | Virtual key records (hashed or reversible depending on product), upstream keys if stored there, team budgets, user records | Rotate everything stored, establish how keys were stored |
| Log, trace and analytics store | Full prompts and completions, system prompts, retrieved documents, tool call arguments | Restrict access, preserve, then purge after evidence capture; assess as a personal data breach |
| Response cache | Cached completions from other tenants or teams; ability to poison the cache so users receive attacker-chosen answers | Flush the cache, rebuild with per-tenant cache keys |
| Routing and model configuration | Send traffic to an attacker-controlled endpoint that records or alters responses | Reset routes to approved endpoints only, review every request in the window |
| Tool and MCP connectors | Downstream tool tokens, the ability to change which tools agents can call | Rotate downstream credentials, review agent actions in the window |
| Deployment pipeline | Persistence: weakened configuration redeployed after clean-up | Rotate 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
| Signal | Where to look | Likely meaning |
|---|---|---|
| Spend or token volume rising on keys with no matching application release | Gateway usage analytics, provider billing | Keys minted or budgets raised by an attacker (AML.T0034) |
| Virtual keys created outside the onboarding process, or budget limits removed | Gateway admin audit log | Admin plane access (ATT&CK T1098.001 where keys are cloud credentials) |
| Provider keys used from addresses that are not gateway egress | Provider usage logs, cloud audit logs | Upstream keys copied out of the gateway (T1078.004, AML.T0012) |
| New upstream base URL or model endpoint | Routing configuration diff | Traffic diverted for collection or response tampering (T1557) |
| Guardrail, PII redaction or content filter set to log only or disabled | Policy configuration diff, admin audit log | Defence impairment (ATT&CK T1685 Disable or Modify Tools) |
| Logging level changed, log sink added or log export to an unknown destination | Gateway settings, log pipeline | Exfiltration of prompts (T1567) or hiding activity |
| Bulk reads of stored prompts or log exports by an admin | Admin audit log, log store access logs | Collection of sensitive conversations |
| Users reporting odd or unsafe answers on routine questions | Help desk, feedback channels | Cache 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
- 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.
- 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.
- 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.
- 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).
- 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?
- 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.
- 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
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
| Order | Credential | Action | Why it matters |
|---|---|---|---|
| 1 | Gateway admin accounts, master or bootstrap key, SSO trust for the console | Revoke, reissue, store the new master key as a split-control break-glass secret | Stops the attacker changing the gateway again |
| 2 | Model provider API keys and cloud AI roles used upstream | Revoke at the provider, issue new per-environment credentials, set provider-side limits | Unlimited spend and access to every enabled model, fine-tuned models and stored files |
| 3 | Gateway cloud role, workload identity, secrets manager access, pipeline credentials | Revoke sessions, narrow permissions, reissue | The route from the gateway to other cloud resources and back into production |
| 4 | Downstream tool and MCP credentials held by the gateway | Rotate at each tool, review actions taken in the window | Agents may have acted on attacker-influenced instructions |
| 5 | Virtual keys issued to applications and agents | Reissue in waves by risk, with a short overlap; revoke all keys created in the window immediately | Stored or observed keys let the attacker impersonate workloads and spend their budgets |
| 6 | Database, cache and log pipeline credentials | Rotate | Direct access to prompts and key records without the console |
| 7 | OAuth tokens and sessions for users and agents seen in traffic | Revoke refresh tokens at the identity provider, shorten access token lifetimes | Bearer tokens in decrypted traffic stay usable until expiry |
| 8 | TLS private keys on gateway listeners | New keys and certificates, revoke the old certificates | A 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
- Run the clean gateway against regression tests for authentication, budget enforcement, guardrails, redaction and routing before it takes traffic.
- Restore low-risk, internal workloads first and watch spend, error rates and refusals for a business cycle; restore applications handling regulated data last.
- Complete virtual key reissue and track traffic on old keys to zero, then delete them.
- Move any applications that used temporary direct provider keys back behind the gateway and revoke those keys.
- 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
| Situation | Choose | Trade-off |
|---|---|---|
| Admin account misused, hosts untouched, full prompt logging off | Revoke admin access, rebuild configuration from source, rotate upstream keys readable in the console | Fast, but depends on a trustworthy admin audit log |
| Gateway software exploited or host compromised | Replace all hosts, rotate every credential the gateway could read, reissue TLS keys | Larger rotation workload, removes implant risk |
| Full prompt and response logging was on | Treat as a data breach, involve privacy and legal, scope by team and data class | Notification work, but anything less underestimates exposure |
| Virtual keys stored hashed | Revoke keys created or seen in the window now, reissue the rest in planned waves | Less disruption, relies on knowing which keys were observed |
| Virtual keys stored in plaintext or reversible form | Reissue all virtual keys | Disruption to every application team |
| Managed gateway service, tenant admin stolen | Contain your identities that administer the tenant, rotate upstream keys, open a provider case for audit records | Scoping limited by what the service logs for you |
| Small team, single gateway, no standby | Allow two or three critical applications direct, capped, short-lived provider keys during rebuild | Temporary 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
| Framework | Reference | Where it applies |
|---|---|---|
| NIST CSF 2.0 | RS.MA-01, RS.AN-03, RS.MI-01, RS.MI-02, RC.RP-03, PR.AA-01, DE.CM-09 | Executing the plan, analysis, containment, eradication, verified restore, credential management, monitoring |
| NIST SP 800-53 Rev. 5 | IR-4, IR-6, IA-5, AC-2, AC-6, AU-9, CM-3, SC-12, SI-4 | Incident handling and reporting, authenticators, accounts, least privilege, log protection, change control, keys, monitoring |
| OWASP Top 10 for LLM Applications 2025 | LLM02, LLM03, LLM10 | Disclosure through logs and cache, gateway supply chain, unbounded consumption |
| MITRE ATLAS | AML.T0034, AML.T0008.005, AML.T0012, AML.T0055 | Cost harvesting, AI service proxies, valid accounts, unsecured credentials |
| MITRE ATT&CK | T1190, T1496.004, T1078.004, T1098.001, T1557, T1567, T1685 | Exploitation, 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
- NIST: SP 800-61 Rev. 3, Incident Response Recommendations and Considerations for Cybersecurity Risk Management
- NSA, CISA, FBI and partners: Deploying AI Systems Securely
- NIST: AI 600-1, Generative Artificial Intelligence Profile
- OWASP: Top 10 for LLM Applications 2025
- MITRE ATLAS: Cost Harvesting
- MITRE ATT&CK: Cloud Service Hijacking
- IETF: RFC 7009, OAuth 2.0 Token Revocation
- GDPR: Article 33, Notification of a personal data breach to the supervisory authority
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