CCode Story: Insights from Startup Tech Leaders
← All frameworks
Innovation

Session-Level Containment

Isolate one compromised agent execution while keeping the service running

Difficulty
Advanced
Time to result
~months to results
Steps
5
Confidence
98%

Session-Level Containment replaces broad remediation with a scalpel-like response. First, instrumentation identifies the precise execution that is misbehaving. The system then freezes pending tool calls, revokes the session token, and terminates or sandboxes that execution context while preserving its artifacts. Other model instances, infrastructure, and adjacent sessions remain available. The mechanism matters because restarting a pod or rotating credentials after an agent acts cannot reverse sent emails, changed records, or disclosed data. By reducing containment to the affected session, teams bound damage by detection latency instead of by every permission the agent holds. This gives security teams a practical middle option between unrestricted continuation and deployment-wide shutdown.

Origin

Extracted from Code Story: Insights from Startup Tech Leaders

Core principles

  • 01Contain the execution context rather than the whole deployment
  • 02Faster detection produces a smaller blast radius
  • 03Preserve artifacts while stopping harmful activity
  • 04Unaffected sessions should continue serving the business

How to run it

  1. 1

    Identify the execution

    Use runtime instrumentation to locate the exact session and process displaying harmful behavior. Confirm its identity before applying containment.

    Pro tip Correlate the agent identity, session token, process, and pending tool calls.

    Watch out Broad identification can terminate healthy adjacent sessions.

  2. 2

    Pause pending actions

    Freeze outstanding tool calls and stop the execution from accumulating additional harm while the response proceeds.

    Pro tip Prioritize actions that can move data or mutate production systems.

    Watch out Detection without an immediate enforcement path leaves the session active.

  3. 3

    Revoke and isolate

    Invalidate the affected session token and terminate or sandbox only its execution context. Leave the model, infrastructure, and unrelated sessions online.

    Pro tip Use the narrowest control that fully stops the offending session.

    Watch out Restarting the whole pod creates unnecessary disruption and may still occur after harm is complete.

  4. 4

    Preserve evidence

    Retain the session's actions, accessed data, tool calls, and enforcement timeline for investigation.

    Pro tip Capture artifacts before cleanup removes the execution context.

    Watch out Containment without retained evidence weakens root-cause analysis.

  5. 5

    Restore confidence

    Verify unaffected sessions remain healthy and give developers actionable feedback about the behavior and rule that triggered containment.

    Pro tip Use the incident to improve policy and staging visibility.

In the wild

Hijacked enterprise AI session

One user session in an enterprise AI service is hijacked. Instead of shutting the service down for everyone, the operator identifies that session, invalidates its token, freezes its pending calls, and audits what it touched. Other users continue working while investigators retain the compromised session's evidence.

→ The attack is isolated without a deployment-wide outage.

Common mistakes

Restarting everything

Killing the pod disrupts every session and does not reverse actions the compromised session already completed.

Rotating credentials too late

Credential rotation cannot unsend an email or undo a tool action that has already occurred.

Discarding session artifacts

Removing the execution without preserving evidence prevents teams from reconstructing what happened.

Is it for you?

Best for

It is best for multi-session AI services where agents hold credentials, call tools, or interact with sensitive production systems.

Not ideal for

It is not ideal where the platform cannot identify and control individual execution contexts.

From the transcript

“So session level containment talks about terminating or sandboxing just a single agent's execution without taking down the model, the infrastructure, or adjacent sessions, right?”

Craig Thomas · 08:13

“In practice, you revoke the session token or you freeze pending tool calls and that execution context.”

Craig Thomas · 08:43

“You also need to preserve the session artifacts for forensic so you can see what has happened.”

Craig Thomas · 08:50

From the episode

The AI Control Loop: What's Missing in AI Security Today - with Craig Thomas of Wallarm

→