JOURNAL 5 juin 2026

Secure agent access without losing sleep

Letting an AI assistant act through your tools is a real grant of power. Here is the security model that makes it safe: OAuth 2.1, DPoP, row level access, and a hash chained audit trail.

Ismayl Ouledgharri · @ismayloule

The first time you connect an AI assistant to your real systems, there is a small jolt of unease. You have just handed something autonomous the ability to act on your behalf, against data that matters, on inputs you did not write. That unease is correct. It is your security instincts working. The goal is not to suppress it. The goal is to build a system where the answer to “is this safe” is something you can actually verify, so you can stop worrying and go to sleep.

Most of the fear around agent access comes from doing it informally. A long lived API key pasted into a config. A service account with permissions far broader than the task needs. No record of what the assistant actually did. Each of those is a real risk, and stacked together they are the reason a lot of teams keep their assistants safely walled off from anything important, which defeats the point.

There is a better model. It rests on four pieces that work together.

OAuth 2.1 instead of a key that lives forever

A static API key is a password that never changes, often shared, and usually impossible to revoke without breaking everything else that depends on it. When you give one to an assistant, you have created a credential with no expiry, no scope, and no clear owner. If it leaks, you may not even know.

OAuth 2.1 replaces that with access that is scoped, time limited, and tied to a real identity. The assistant receives a token that can only do specific things, expires on its own, and can be revoked the moment something looks wrong. You move from “we hope nobody copied the key” to “we control exactly what this access can do and we can shut it off instantly”. That shift is the foundation everything else sits on.

DPoP so a stolen token is useless

OAuth tokens are better than static keys, but a bare token still has a weakness. If someone intercepts it, they can use it, because the token alone is enough to prove access.

DPoP closes that gap. It binds the token to a cryptographic key that the assistant holds and never transmits. Every request must be signed with that key, which means a token captured in transit or lifted from a log is worthless on its own. The attacker has the token but not the key, and the key is what the server checks. This is the difference between a credential that is dangerous to lose and one that is merely inconvenient to lose.

Row level access so the blast radius is small

Even with perfect authentication, you have to answer a separate question. Once an assistant is in, what can it reach.

The wrong answer is “everything the service account can touch”, because that turns a single mistake or manipulation into a company wide exposure. The right answer is row level access, where the rules about who can see and change which records are enforced at the data layer itself, not in application code that can be bypassed or forgotten.

With row level access, an assistant acting for one user simply cannot reach another user’s data, regardless of how the request is phrased or how cleverly it is manipulated. The boundary is not a policy that hopefully gets checked. It is a wall the request cannot go through. This is what keeps a single compromised session from becoming a breach.

A hash chained audit trail so you can prove what happened

The first three pieces prevent bad outcomes. The fourth lets you prove good ones, which matters more than it first appears.

When an assistant acts through your tools, you will eventually be asked to account for it. A customer wants to know why something changed. A regulator wants evidence a decision was made correctly. Your own team wants to understand an incident. If your only record is ordinary logs, you have a problem, because ordinary logs can be edited, lost, or quietly rewritten, which means they prove nothing under scrutiny.

A hash chained audit trail solves this. Each recorded action is linked to the one before it with a cryptographic hash, so any attempt to alter the history breaks the chain and becomes detectable. The record is tamper evident. When you say “here is exactly what the assistant did, and here is proof it has not been changed”, that statement holds up. This is the difference between trusting your systems and being able to demonstrate they are trustworthy.

The four together are what let you relax

No single piece is enough. OAuth 2.1 controls the door. DPoP makes the key unforgeable. Row level access keeps the blast radius small. The audit trail makes the whole thing provable. Together they turn agent access from a leap of faith into a controlled, observable, reversible grant of power.

That is the model we build into every MCP server and API we ship. Security is not a phase we add before launch. It is present from the first commit, because retrofitting these four pieces into a system that was built without them is far harder than building them in from the start. And because we host and run what we build, the responsibility for keeping that model intact stays with us.

The unease you feel about connecting an assistant to your real systems is healthy. The way to resolve it is not to ignore it but to build something you can actually verify.

We are a small studio in Montreal, and this security model is at the center of how we work. If you are building toward it, we would love to hear about it.

Nous sommes un petit studio à Montréal. Si vous travaillez sur ce type de problème, nous serions ravis d'en discuter avec vous.