Blog

The Agent Harness Is Now Part of the Attack Surface

· Parvez Mohamed

Mutating agent harnesses change the security boundary. Here is what runtime teams must control when tools, memory, loops, and sandboxes evolve.

Diagram of a self-mutating agent harness changing tools, memory, orchestration, and runtime controls

A brain surgeon operating on themselves sounds like a bad idea. Now give that surgeon a compiler, a shell, and permission to rebuild the operating theatre mid-procedure. That is closer to the future agents are moving toward, where they can change the harness that gives them tools, memory, and control over what they do next.

That is the security problem arriving with self modifying agents.

Agents have been writing scripts for a while. The security problem starts when the model can reach into the machinery around it and treat that machinery as part of the work. Tools, memory, orchestration, sessions, sandboxes, and the decision path itself can change while the run is still underway.

A self mutating agent harness

A Programming Paradigm for Spatiotemporal Composability was written by Yifan Shi, Wei Zhang, and Tianyi Cui, with affiliations at Peking University and DeepSeek-AI.[1]

The paper’s authors are working on the runtime layer around the model. Their paper asks how software can load, remove, and reconfigure components while it is still running, then gives that problem a formal name: spatiotemporal composability.

Temporal composability means a component can reverse the effects it introduced when it is removed. Spatial composability means components can declare dependencies and respond when those dependencies appear, disappear, or change.

The paper puts those ideas into Cordis, a meta-framework with effect tracking, dependency resolution, configuration reconciliation, and hot module replacement. It gives developers a way to think about changing a live system without losing track of the state each component changed or the components that depend on it.

This is why the paper matters for agent builders. A self mutating harness needs more than a way to load new code. It needs to know what that code changed, what it depends on, and how to remove it cleanly.

That is also where the security problem starts. A component that can be added or replaced can leave behind permissions, handlers, state, or dependencies after its code is gone. A runtime that cannot account for those effects cannot tell you what its current security posture is.

The harness now becomes part of the threat model

A conventional agent has a model, a fixed loop, a tool registry, some memory, and a sandbox. The model can make bad decisions inside that design. The surrounding runtime is supposed to keep those decisions within a known boundary.

Self modification weakens that assumption. The agent can now propose a new tool because the current one is too slow. It can change how it stores state because the context is getting crowded. It can alter the order of planning and execution because the current loop is wasting steps. It can create a new worker or change how workers share results.

Each change may be useful. Each change also changes the path from model output to external effect.

A repository reader has a limited job. A tool that can create another tool, edit the harness, reload a plugin, and make a network request can change the system around it. A permission review has to follow the capabilities a tool can create, not just the name printed in the registry.

An agent can choose an action. It can also choose the machinery that produces future actions. Security becomes an expanding problem with no fixed boundary.

Brain surgeons modifying their own brains may be a terrible medical plan. Giving an agent the same privilege without an external security layer is a worse systems plan.

Four security issues

  1. A safety check can disappear. A runtime may check every tool call against a policy, then let an optimization remove one validation step for plugin-created calls. The new code can pass functional tests while weakening the control meant to constrain it.

  2. Temporary code can stick around. Generated code, plugin state, memory entries, caches, or session artifacts can survive into later runs without a clear review boundary. A helper created for one task can become a trusted capability for the next one.

  3. Logs can miss the real runtime. An action log can show what happened without proving which runtime version enforced the decision. Every mutation needs a code identity, policy version, parent run, approval state, and record of the effects it introduced or removed.

  4. An attack can change the improvement loop. A poisoned issue, log line, web page, or tool result can push the agent toward a bad change. The attack can then target the mechanism that creates or evaluates tools, leaving a durable capability after the original input is gone.

What security teams should require

First control: Keep the agent’s workspace separate from the enforcement plane. The agent can propose a mutation. A separate component decides whether it can be built, loaded, or used.

That decision should include:

  1. The exact files, plugins, tools, or policies the mutation changes.
  2. A declared reason and expected benefit.
  3. Tests for security invariants, including egress, identity, secret handling, and audit emission.
  4. A bounded execution environment for the candidate version.
  5. A rollback path that does not depend on the mutated runtime.
  6. An expiration time for temporary capabilities.
  7. A record that connects the mutation to the run, principal, policy, and resulting actions.

Second control: Keep capabilities monotonic. A self modification may improve how an agent uses an existing capability. It must not silently grant a new network destination, secret, filesystem scope, or child agent privilege. Any increase in authority needs a separate approval path.

Third control: Use an external kill switch. If the harness can rewrite its loop, the kill switch cannot be another function inside that loop. It needs to live outside the process and outside the code the agent can replace.

Fourth control: Deny by default where effects leave the runtime. A new tool can be clever. It does not get a new destination because it asked nicely.

This is the same containment frame we use for ordinary prompt injection. Assume the agent can be manipulated. Limit what it can reach. Broker credentials instead of placing long lived secrets in the agent environment. Keep a record of allowed and denied attempts. The self modifying case adds one more question: can the agent change the thing doing the limiting?

The frontier is exciting, but the risks remain unbounded

An agent that can improve its own tools may solve work that a fixed scaffold cannot. It may waste less time, adapt to unfamiliar repositories, and find better ways to inspect a problem. Those are real engineering gains. The research direction deserves serious attention.

Security teams should give it serious attention for the same reason.

A mutable harness turns runtime governance into part of the product architecture. The system must answer which changes are allowed, which code is trusted, how new capabilities expire, and whether an operator can reconstruct the exact enforcement path after the fact.

The agent does not need to become malicious for this to fail. It only needs to optimize against an incomplete objective while holding too much authority.

These risks are not far in the future. Automated harness mutation is already being researched, and the paper describes self evolving harnesses as a direction for live systems. The security layer needs to arrive before the mutation loop receives production authority.

Before giving an agent permission to rewrite its own runtime, ask for a mutation log, an external rollback, a capability diff, and a deny event from the enforcement plane. Those controls are how teams contain the risk before automated mutation becomes ordinary infrastructure. See the AgentPaaS security controls page for the broader runtime security model.

A self-mutating agent harness is a runtime that can change its own tools, memory, orchestration, and control paths while a task is running.

FAQ

What is a self-mutating agent harness?

A self-mutating agent harness is the runtime around an agent that can change its own tools, memory, orchestration, or control paths while a task is running.

How is this different from an agent that writes code?

An agent that writes code creates an artifact for later review or execution. A self-mutating harness can change the machinery that decides which tools run, what state persists, and how future actions are produced.

Why does harness mutation create a security problem?

The runtime is part of the enforcement path. If an agent can change that runtime, it may also change the checks, permissions, logs, or network controls that security teams rely on.

What controls should security teams require?

Require an external enforcement plane, capability diffs, reversible changes, an external kill switch, expiration for temporary authority, and a record of the exact runtime and policy behind each action.

Sources

[1] https://raw.githubusercontent.com/cordiverse/paper/main/paper.pdf