October 5, 2026 · 19 min read · Agent Security

Rejecting Untrusted Proxies: Architectures for Memory‑Safe Agent Orchestration

How to secure agent orchestration without trusting proxies: attested runtimes, per-agent sandboxes, deterministic state, wipe protocols, and end-to-end networki

Essay · 21 min read · Agent Security · System Architecture

The Proxy Is the Risk, Not the Product

If an agent stack leaks, it tends to leak through a middleman. Reverse proxies, shared runtimes, app stores that wrap your build in a convenience shell—these are the quiet bottlenecks where memory is reused, billing meters tick, and policies get injected. That’s not paranoia; it’s a reading of the failure modes that keep repeating.

A proxy is billed as insulation: put the fragile things behind a layer that soaks up attacks and smooths operations. The trouble is that agents carry state. Scratchpads, tool results, prompts, embeddings, session keys. When intermediaries hold or transform that state, they become single points of accidental data exposure, cost shock, and policy gatekeeping. We’ve seen how classes of bugs in reverse proxies can produce memory disclosure across tenants. Cloudbleed made that clear years ago, and the pattern continues to crop up across shared infrastructure. Meanwhile, platform verification has tightened—what can run, how it runs, who can ship it—and teams are waking up to SaaS bills outpacing their mental models of use. Together, that’s a three-front problem for agent orchestration security.

This essay argues for a different baseline: architectures that assume intermediaries are useful but untrusted. That stance pushes security down into the runtime, up into the serialization layer, and sideways into the network fabric. The goal is not to eliminate proxies or platforms. It’s to stop them from holding secrets, defining your reliability, or writing your cost story.

What Goes Wrong When Agents Meet Intermediaries

Agent stacks are unlike classic web apps in a few ways that matter:

Three failure modes recur.

First, reverse proxy memory leak. Whether from parser bugs, buffer reuse, or an optimization that trims one tenant’s response and slices into the next, the class of fault is simple: a shared component reuses memory in ways that can expose prior content. The severity varies—some incidents are narrowed to whitespace and headers; others spill payloads—but the trust boundary is breached. If part of your agent’s working set transits that component in plaintext, it is at risk by construction.

Second, shared runtimes blur isolation. Serverless platforms and extensions that run your code in a multi-tenant process model can cross-contaminate memory through error paths or misconfiguration. Even without a bug, lifecycle reuse (warm starts) can leave residual data if the language runtime doesn’t eagerly zero memory. Managed frameworks hide a lot of magic. They do not guarantee strong isolation unless isolation was the original design objective.

Third, platform coercion. App stores, plugin catalogs, and SaaS layers route your agent traffic through metering, verification, and policy enforcement they control. That can be helpful for safety and abuse prevention. It can also ratchet cost and veto product choices without warning, because the enforcement sits in the middle of your critical path.

The consequence: one misbehaving middleman can breach confidentiality, mutate behavior, and explode spend. You can bolt on monitoring and rate caps, but you still have a data path that assumes the proxy is honest, available, and stable.

A Different Baseline: Distrust Intermediaries by Default

Start with a crisp threat model.

Then set constraints that fall out of those assumptions:

With that baseline, reverse proxies can still help with caching, load smoothing, and DoS posture. They simply stop being sources of truth.

Attested Native Runtimes: Shrink the Trust Boundary to the Code You Ship

When an agent is a graph of tools and models glued by a planner, your runtime is the blast radius. If you cannot say what binary ran, with what dependencies, on what host class, you are not in control of agent orchestration security.

Attested runtimes are the core. Two parts matter.

Attestation is not only for enclaves. Even without hardware support, you can derive value:

TEEs add stronger guarantees by letting a remote verifier confirm a measurement produced by hardware. They bring tradeoffs: limited memory, side-channel research that continues to evolve, and operational complexity. They shine for key material and small critical loops, such as a planner that decrypts and re-encrypts prompts locally. For heavy model inference, you likely pair TEEs with isolating hypervisors and rely on message-layer cryptography to protect payloads in flight.

Attestation should extend to the orchestration pipeline:

This shrinks your trust boundary to code you can reason about and components that can prove what they are. It also sets you up to defend against coercion: even if a platform requires a proxy hop, your runtime decides what to reveal, not the other way around.

Per-Agent Memory Sandboxes: Isolation, Not Convention

Most agent frameworks default to pragmatic sharing. A pool of workers handles many agent sessions. A shared cache speeds up tokenization and tool results. That is fine for performance; risky for memory.

Move to hard isolation. The unit is the agent session.

Give each agent session its own key material. Derive a per-session data-encryption key from a master held in an HSM or cloud KMS, bound to the attested runtime measurement. All scratch files, temporary vector indexes, and on-disk spills are encrypted with that key. The key lives in memory only as long as the session. When the key is gone, crypto-erasure wipes the data even if you miss a cleanup path. That is the memory-safe agent architecture move that pays off again and again.

Keep caches out of the trust path. That big embedding cache everyone shares to save money? Move it behind a process boundary and a narrow API that returns only what the caller can see, and encrypt entries with per-tenant or per-session keys. Or accept the privacy risk explicitly and never put secrets in that cache. What you cannot do is carry on with an in-process LRU and assume conventions will hold once the system is under load.

Tooling matters, but discipline matters more. Don’t let tools register arbitrary callbacks into the agent’s heap. Give them an RPC surface that enforces data shape and size, and treat every tool as if it were a network hop.

Deterministic Serialization: State That Travels Without Bleeding

Agent orchestration lives on serialization. Plans, tool invocations, and partial outputs must be shipped between processes and machines. If serialization is sloppy, you will leak state, misroute data, and create memory that refuses to die.

A few rules help:

Deterministic serialization has a security dividend. If a reverse proxy memory leak exposes fragments, the damage is contained and recognizable—bounded values, redacted fields, and checksums that fail if a proxy tampers. And if a platform tries to inject or reorder steps, your runtime can detect mismatches between the signed state sequence and the traffic it sees.

It also makes debugging less invasive. You can ship logs to observability systems without raw prompts or tool results, because the event graph and hashes are enough to reconstruct behavior inside a safe environment when needed.

Provable Wipe Protocols: Memory That Tells the Truth When It’s Gone

Wiping memory sounds easy. Zero the buffer. Close the file. In practice, runtimes optimize away zeroization, GC defers frees, filesystems journal blocks you never see, and caches cling to the best bits.

This is where cryptographic erasure and protocol-level guarantees matter.

When you put wipe protocols under policy, the debugging culture changes as well. Engineers stop sprinkling print statements and start leaning on redacted structured logs and deterministic replays. That is a healthy trade.

Proxy-Resistant Networking: End-to-End or It’s Not Confidential

A reverse proxy is a great place to terminate TLS if you’re optimizing for convenience. It’s the wrong place to terminate confidentiality.

Design message-layer security as if the transport were always compromised. That means:

This is not about skirting enterprise controls. It is about clean separation of concerns: proxies route and throttle; endpoints protect privacy. The best corporate networks in finance and government already draw this line. Agent orchestration should, too.

For agent-to-agent chatter, avoid ad hoc RPC. Use capability-bearing tokens that constrain what the callee can do. Bind capabilities to a narrow scope: tool X, on input Y, for session Z, until time T. The token is signed by the orchestrator and is useless if transplanted to another context, which blunts the damage if a proxy logs it.

If you must traverse third-party APIs that inspect content, assume inspection will happen, and never send more than the minimum. Redact aggressively and split flows: sensitive computation local or on a trusted endpoint; non-sensitive augmentation through the service.

These moves add latency. You pay a few extra milliseconds for crypto. The response is not to give up; it is to measure and adjust batching and concurrency. Reliability improves when you are not praying a cache in the middle remains honest.

Cost and Policy Coercion: The Other Two Spikes on the Same Spear

Security failures get attention; cost and policy pain linger in ticket queues until the quarter ends. Proxies and managed layers complicate both.

Billing shock happens when the meter lives in the middle. Platform convenience often comes with opaque pricing curves: escalators for concurrency, data egress charges at layer 7, hidden minimums on idle listeners. Agents are bursty. A planner that fans out to five tools and retries twice can turn into dozens of calls per user input. If a proxy ties cost to those tiny bursts, your mental arithmetic will be wrong.

A proxy-resistant approach helps you reclaim control:

Policy gatekeeping is less about money and more about pace. App stores and plugin catalogs are tightening verification for good reasons—safety, abuse mitigation, ecosystem stability. But if a store can remotely disable your adapter or throttle a capability, product behavior is the hostage.

To prepare:

None of this rejects platforms. It simply avoids fusing your product to their private rails.

The Counter-Argument: Centralized Middleboxes Reduce Risk

A fair critique goes like this: middleboxes concentrate expertise. A big reverse proxy can absorb attacks better than your slender agent runtime. A managed gateway is where compliance teams put logging and controls. Fragmenting responsibility across runtimes and message-layer crypto complicates life for defenders and auditors.

There is truth here. Centralizing TLS termination, IP reputation, and coarse rate limiting helps. It cuts down exposure to trivially automated attacks. It gives teams a single place to patch. Observability is easier when all traffic flows through one visible choke point.

The reply is not to yank proxies out. The reply is to strip them of privileges they do not need. Let them keep their strengths—routing, shielding, coarse policy—while taking confidentiality, fine-grained authorization, and sensitive state out of their hands. You can still ship rich logs by recording hashes, event graphs, and metadata. You can still run a WAF without giving it your customer prompts. You can still embrace zero trust while using centralized infrastructure.

And you will sleep better knowing that a memory disclosure in a proxy can spill headers and metadata, not raw agent state.

Migration Paths: From Proxy-Centric to Proxy-Resistant Without a Rewrite

Enterprises don’t refactor architectures on a hunch. The path to memory-safe agent architectures runs through a few practical moves you can make without pausing delivery.

Start with contracts, not code. Define the agent state model as a versioned schema and commit to deterministic serialization. If you need to migrate a dozen handlers and queues to use it, do that first. Everything else builds on this bedrock.

Introduce per-session keys early. Even if you don’t encrypt every buffer on day one, switch scratch files and on-disk spills to envelope encryption with keys bound to session IDs. The changes are localized and measurable. You will immediately see the shape of your scratch world, which is a gift during audits.

Pull tools behind capability-bearing RPC. Wrap your in-process adapters in a thin RPC server that enforces data shapes, quotas, and capabilities. You can run it on the same host initially. The point is to make tool boundaries explicit so isolation can grow later without rewrites.

Attest what you can attest. Sign binaries. Pin container images. Export runtime measurements to logs. If your platform supports remote attestation, adopt it for the orchestrator and key-handling components. Start small, with the planner and key store. Build familiarity before moving heavier parts.

Push message-layer crypto on one critical path. Pick a high-sensitivity call—say, the prompt that includes customer identifiers—and encrypt it end-to-end. Prove to yourself that operations can live with proxies that are blind to the payload. Then expand coverage.

Measure cost where it matters. Set up internal metering hooked to the agent runtime, not the proxy logs. Make planners budget-aware. Once you can see spend at the application level, platform billing surprises stop being surprises.

Alongside, update procurement language. New contracts with vendors and platforms should include:

In regulated multi-entity environments—common in the Gulf where groups run multiple regulated units under one umbrella—the impact compounds. Clean boundaries let you route traffic through shared infrastructure without drifting into shared memory. When external audits drill into how agent state moves across entities, you have evidence, not folk wisdom.

A Concrete Reference Flow

It helps to see how these patterns compose. Consider a customer-support agent that triages tickets, queries a knowledge base, and drafts responses.

A reverse proxy can still balance load, absorb attacks, and centralize coarse logging. If it leaks a buffer, it spills only metadata. If the platform tightens policy on a tool, you can swap to an internal adapter with the same contract. If the provider changes billing curves, your runtime can throttle and fall back to a local model for drafts rather than blasting requests into a new tier.

Pitfalls and Practical Limits

Not every team can flip all of these switches. A few caveats help avoid disappointment.

These are tradeoffs, not ideology. The question is whether the control you gain over security, cost, and policy is worth the overhead. In most agent deployments that handle real customer data, it is.

Why This Matters Now

Memory disclosure bugs at the edge have a long history. They are not going away. Every time a shared layer grows more features—smart parsing, compression tricks, programmable middleware—the surface grows. At the same time, platform verification and policy enforcement have tightened. App stores and managed ecosystems are curating what gets to run, and under what rules. And usage-based pricing interacts badly with agent burstiness. None of these trends is hypothetical. Teams have watched bills spike, builds blocked, and payloads skimmed by components they do not control.

Treating intermediaries as untrusted changes the energy of all three. Memory safety becomes a property of your runtime and your state model. Cost becomes something your orchestrator can see and cap. Policy remains important but cannot rewrite your product overnight from a distance.

In the UAE and across the Gulf, this is especially relevant for organizations that operate across regulated entities or jurisdictions. A proxy may be mandated. A shared platform may be efficient. The discipline is to let them move packets and enforce high-level rules without turning them into containers for secrets. The audit story becomes cleaner. The architecture becomes portable when the regional footprint grows.

The Sharp Edge

The habit of trusting middleboxes grew when apps were stateless and secrets were few. Agents are not like that. They carry memory by design. If you let intermediaries handle that memory, you’ve already answered your own security question—and not in your favor.

Keep using proxies, platforms, and stores. But stop giving them intimacy. Put attested runtimes at the core, isolate each agent’s memory, serialize deterministically, wipe with proofs, and ship encrypted payloads that do not ask a proxy for discretion. That is how agent orchestration security grows up.

Reverse proxies can still leak. Platforms can still tighten. Billing can still surprise. If your stack is built with proxy-resistant networking and memory-safe agent architectures, those events hurt—then bounce. That’s the point.