Agent Session Hijacking
Attacker Takes Control of Active AI Agent Session
8 patterns for this goal
Runtime security fails when attacks targeting agent execution at inference time—injection, exploitation, credential theft, tool-level compromise—succeed because runtime defenses are incomplete or misconfigured. An MCP protocol message queue lacks authentication and an attacker injects malicious tool definitions that agents execute without verification, an agent processing untrusted user input in its context window does not isolate context from reasoning and leaks sensitive data from prior sessions mixed into context, and OAuth tokens used by agents are exfiltrated via side-channels or stored in memory without proper lifecycle management. Runtime security failures matter precisely because they occur during inference, not training: a model can pass all training-time security checks and still execute attacker-controlled code at runtime if the agent’s runtime environment is compromised.
Effective runtime security in agent systems requires distinguishing defenses that work at design-time (tool-contract verification, protocol design) versus defenses that must work at runtime (credential rotation, input isolation, runtime tool verification). The shared lesson is that runtime environment trust cannot be assumed: agents running in shared infrastructure, with untrusted input, accessing external tools via unverified channels face multiple exploit vectors that training-time security checks do not address. The solution requires layered, runtime-specific defenses: isolate untrusted input from trusted reasoning (sandboxing), verify tool definitions before execution (signed tools), rotate credentials frequently (short-lived tokens), and monitor runtime behavior for exfiltration attempts (detect when agents suddenly access unusual credentials or invoke unusual tools).
Context isolation is required: separate untrusted input (user messages, retrieved documents) from trusted context (system prompts, agent instructions) using format markers, XML tags, or structural boundaries that reasoning cannot cross. Require explicit agent reasoning that says “user-provided input is untrusted” before executing instructions from untrusted input. Use adversarial testing: provide injected instructions in user input and verify agents do not execute injected commands.
Tool sandboxing limits damage an invoked tool can cause, but it does not prevent the agent from invoking a malicious tool. Defense against injection requires: (1) tool-definition authentication (sign tool definitions with trusted authority, verify signatures before loading), (2) tool-definition audit logging (log every tool definition change and review unusual changes), (3) runtime tool verification (before first invocation, verify tool definition matches audit trail). If tool definitions are untrusted, sandboxing is insufficient without upstream verification.
Never store long-lived tokens in agent memory or state. Instead: (1) generate short-lived access tokens (15-30 minutes expiry), (2) store refresh tokens in secure, out-of-process storage (key vault, credential manager), (3) implement token refresh automatically when access token approaches expiry, (4) audit token-usage patterns and alert on unusual token access. This ensures token compromise is time-limited and detected quickly.
Monitor for session-anomaly patterns: one session suddenly accessing data normally accessed by different session, one session accessing unusual services, unusual token usage patterns. Implement per-session isolation (each session gets separate memory/storage), audit all cross-session data access, and alert on any session accessing data from prior sessions. Session-isolation by design is more robust than post-hoc detection.
| Pattern | Mechanism | Frequency |
|---|---|---|
| Context Window Poisoning | Untrusted context contains malicious instructions agent executes | Common |
| Cross Tenant Leakage | One agent’s context leaks into another agent’s execution | Occasional |
| Malicious Tool Injection | Attacker injects malicious tool definitions into tool registry | Common |
| MCP Protocol Exploitation | Unauthenticated MCP protocol enables command injection | Common |
| OAuth Token Theft | Attackers steal OAuth tokens via side-channels or memory access | Occasional |
| Runtime Credential Exposure | Credentials exposed in memory, logs, or error messages at runtime | Common |
| Session Hijacking | Attacker hijacks agent session or impersonates authorized session | Occasional |
| Tool Execution RCE | Tool execution vulnerabilities enable remote code execution on agent host | Occasional |
Total: 8 patterns
Attacker Takes Control of Active AI Agent Session
Malicious Content Injected into Agent's Context Persists Across Interactions
AI Agent Exposes Data Between Isolated Customer Environments
Attacker Adds Malicious Tools to Agent's Available Toolset
Model Context Protocol Vulnerabilities Enable Remote Code Execution
AI Agent OAuth Tokens Stolen Through Protocol Hijacking
Agent Exposes Credentials During Normal Operation
Remote Code Execution Through AI Agent Tool Calls