r/LocalLLaMA • • Oct 06 '26

Discussion An architecture to cryptographically constrain autonomous AI agents at the execution boundary

Hi everyone,

As we move from simple RAG chat to fully autonomous tool-using and coding agents, we are hitting a massive wall: predictability and safety.

Right now, most setups try to secure AI agents using probabilistic methods like system prompt hardening, alignment tuning or reactive LLM-based guardrails (e.g., LlamaGuard). The problem is that these guardrails can be bypassed via Indirect Prompt Injections (IPI), leading to capability escapes, unauthorized shell command executions or runaway API budget depletion.

To solve this, I’ve been working on a framework that completely shifts the paradigm from trusting the model to governing the execution environment using cryptography.

I call it EBP-CA (Execution-Boundary Proofs with Cryptographic Authorization). It is a model-agnostic layer that sits directly between the untrusted agent and the runtime environment, treating every single model-generated action as untrusted.

The core architecture implements six deterministic security primitives:

  1. Signed Capability Contracts: Immutable cryptographic tokens defining the exact boundaries of what an agent can execute.
  2. Independently Recomputed Policy Checks: The runtime re-evaluates policy compliance deterministically, bypassing the model's interpretation entirely.
  3. Short-Lived Single-Use Execution Grants: Atomic, ephemeral tokens issued for a single specific payload to eliminate permanent session hijacking.
  4. Replay & TOC-TOU Protection: Cryptographic binding of the execution grant to the exact payload hash, neutralizing Race Conditions (Time-of-Check to Time-of-Use).
  5. Trusted Cost Accounting: Enforced real-time budget tracking at the runtime layer.
  6. Human-in-the-Loop (HITL) Gateways: Non bypassable prompts that freeze execution and mandate cryptographic user authorization for out-of-scope tasks.

The working prototype currently passes 74 integration tests, validating full resilience against path traversals, command injections, budget bypasses, and sandbox escapes.

The specifications, architectural diagram, and executive summary are available on GitHub under a private proprietary license (free for technical evaluation and research review): https://github.com/lucadilo/ebpca-ai

I'm posting this here because I’d love to get the community's feedback on this approach. How do you see this scaling with kernel-level sandboxing (like eBPF or gVisor integration)? Let's discuss!

0 Upvotes

13 comments sorted by

View all comments

2

u/audioen Oct 06 '26 edited Oct 06 '26

I struggle to understand what any of your cryptography buys you.

This boils down to some kind of is_allowed(cmd) function which evaluates whether model can run a command or not. This is generally speaking hard, as the models treat execution failures as bugs and try to work around them. The other key issue is that agents are the more useful the more capable they are, and the less restrictions they operate under. However, they are all the more dangerous and if you let them run around as sysadmin in your servers, they can do pretty much every sort of damage, while still trying to be helpful -- and they would probably be absolutely devastating if they intended to ever take your shit down for good.

As far as I can tell, the meat of your poc is here: https://github.com/lucadilo/ebpca-ai/blob/master/src/cbc.ts that defines some example commands at draft level for what your agents might be able to do, and this file likely handles the verifying of the command: https://github.com/lucadilo/ebpca-ai/blob/master/src/validate.ts and everything else, like the cryptography and all your signed message structures and so on, is just noise that contributes nothing to the solution. Nobody's going to verify signed execution grants, they're going to hand the command to a function that says yes or no. That function can just directly evaluate the safety of the command, is my point.

That problem is hard enough that I think it would be the best to dispense with all the cryptography and other noise around the problem, and just stick to writing a really good is_allowed(cmd). Alternatively, sandboxing your agent to an ephemeral filesystem and firewalling the crap out of it might also work. There exists other ways to mitigate the problems arising from the free spirit nature of the agents, which is to strictly limit what the worst case scenario is. If the agent wants to ssh to your production and rm -rf everything, can it do it? Can it read your mail, possibly containing instructions from a third party? Use a browser with your identity logged in, paypal or amazon account ready to purchase stuff? These are scary questions and a good prompt attack will probably make your agent do almost anything.

My money is on the latter approach winning -- reduce the worst case scenario and treat it like a coworker -- very nice sort of guy, but no matter how nice he is, he won't have the keys to your house, to your car, or your bank account. The agent acts like it is "yours" only if nobody seriously tries to confuse it.

-2

u/lucadilo Oct 06 '26

Thank you for digging into the code and for your feedback. You've hit the exact core of the architectural debate.

You are completely right that in a single local machine, everything eventually hits a function like is_allowed(cmd). In that vacuum, cryptography looks like noise.

However, it is designed for distributed enterprise architectures (where agents call remote microservices and APIs), not just local scripts. Here is exactly what the cryptography buys you over a simple if/else function:

  1. Defeating TOC-TOU Race Conditions: If an agent is compromised, it can alter the payload after the safety check but before execution. Binding a short-lived grant to the exact SHA256 hash of the payload ensures atomic integrity.
  2. Preventing Confused Deputy Attacks: In a microservice mesh, remote tools shouldn't evaluate again the agent's full state. Signed contracts allow remote environments to instantly verify authorization using just a public key.
  3. Tamper-Evident Auditing: If the runtime environment itself is partially compromised, signed receipts ensure the agent cannot forge financial logs or erase the tracks of an attempted escape.

I totally agree with your conclusion: we must treat the agent like a coworker who doesn't get the keys to the house. The OS sandboxing you mentioned is the physical cage, the cryptography in EBP-CA is the unforgeable lock on the cage door.