# Permission Boundaries and Immutable Audit Logs for Autonomous Agents

> Source: <https://dev.to/samamderson/permission-boundaries-and-immutable-audit-logs-for-autonomous-agents-2o5l>
> Published: 2026-11-20 07:05:45+00:00

**Recommendation:** Put tool allowlists and spend caps in versioned Rego policy tested on every commit, and mint short-lived scoped tokens per task at a gateway so leaked credentials expire within minutes.
More in the playbook "Securing agents and AI tools": <https://wpnews.pro/playbooks/agent-security>

Two teams usually share the job of controlling an agent. The identity team writes the allowlist, and the platform team ships the logs. Neither can answer one plain question: did policy version 14 or version 15 allow that tool call?

That gap matters because any immutable audit trail ai agents produce is only as useful as the decisions it records. A tamper-proof pile of unlabeled calls proves little.

This guide joins both halves. You will define permission boundaries as code, enforce them at a gateway, log every decision, and seal the record against rewrites.

Permission boundaries are explicit limits on what an agent may call, read, write, and spend. They live outside the model, so a clever prompt cannot talk its way past them.

Think in three layers. Identity says who the agent is. Scope says which tools and data it may touch. Limits say how much it may do in a given window. Begin with deny-by-default tool access.

The agent receives a named allowlist, and every other call fails closed. Likewise, give each agent its own identity instead of a shared service account.

As a result, every later log line points to one agent, one version, and one owner. Least privilege for AI agents then becomes something you can test, not a slogan on a slide.

Enforce boundaries in one place: a gateway that sits between the agent and its tools. The agent never holds a raw credential. Therefore, the gateway sees every call and can refuse it. It also gives you one choke point for logging, so no tool call can slip past the record. The flow below shows each possible outcome.

Policy-as-code for AI agents keeps rules reviewable, versioned, and testable. Open Policy Agent suits this job because Rego policies are plain files in your repository. The policy below lets a support agent read tickets and search the knowledge base. It allows refunds only under a cap and denies everything else.

``` python
package agent.authz

import rego.v1

default allow := false

default reason := "allowed"

read_tools := {"crm.read_ticket", "kb.search"}

allow if input.tool in read_tools

allow if {
    input.tool == "payments.refund"
    input.agent_id == "refund-agent"
    input.args.amount <= 100
}

reason := "tool not in allowlist" if {
    not allow
    input.tool != "payments.refund"
}

reason := "refund above cap or wrong agent" if {
    not allow
    input.tool == "payments.refund"
}
```

Two details deserve attention.

First, the default rule denies anything unlisted, so a forgotten tool fails closed.

Second, the refund cap lives in policy rather than in the prompt, so a reviewer changes it through a pull request.

Pair the policy with tests, and run them on every commit with `opa test ./policies -v`.

``` python
package agent.authz_test

import rego.v1

import data.agent.authz

test_read_tool_allowed if {
    authz.allow with input as {"tool": "kb.search", "agent_id": "refund-agent"}
}

test_refund_under_cap_allowed if {
    authz.allow with input as {"tool": "payments.refund", "agent_id": "refund-agent", "args": {"amount": 40}}
}

test_refund_over_cap_denied if {
    not authz.allow with input as {"tool": "payments.refund", "agent_id": "refund-agent", "args": {"amount": 900}}
}

test_unlisted_tool_denied if {
    not authz.allow with input as {"tool": "db.drop_table", "agent_id": "refund-agent"}
}
```

Next, remove long-lived keys. The gateway mints a token for each task, with a short expiry and only the scope the policy approved. If a prompt injection leaks that token, it dies within minutes and opens very little.

The command below issues a 15-minute session limited to one read-only prefix through an inline session policy. Replace the account ID and role name with your own.

```
aws sts assume-role \
  --role-arn arn:aws:iam::123456789012:role/refund-agent-tools \
  --role-session-name refund-agent-task-8841 \
  --duration-seconds 900 \
  --policy '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:GetObject","Resource":"arn:aws:s3:::support-docs/refunds/*"}]}'
```

Record the session name in the decision event. Consequently, every token traces back to one task and one agent.

Record both allowed and denied calls. Denials matter most, since they show what the agent tried and failed to do.

Each decision event should carry the policy version, because that single field answers the version 14 versus version 15 question.

Log a hash of the inputs instead of raw arguments, and keep full text in a protected vault. With these fields, a reviewer can rebuild the [immutable audit trail ai agents](https://www.xccelera.ai/blogs/the-evidence-agent-explained-how-xccelera-creates-an-immutable-audit-trail-for-every-ai-action) depend on during an incident review, without guessing which rule fired. 

The table maps each boundary layer to the evidence its log must contain.

| Boundary layer | What it blocks | What its log must prove | 
|---|---|---|
| Identity | Shared credentials, anonymous calls | Which agent and version acted, for which user | 
| Tool allowlist | Calls to unapproved tools | Tool name, decision, and the rule that matched | 
| Argument limits | Oversized refunds, wide queries | Argument hash and the limit that applied | 
| Credential scope | Standing access, token reuse | Token session name, scope, and expiry | 
| Rate and budget | Runaway loops, cost spikes | Counter value and window at decision time | 

A single decision event then looks like this:

```
{
  "event_id": "dec_01J8Q2",
  "trace_id": "tr_7f3a",
  "agent_id": "refund-agent",
  "agent_version": "2.4.1",
  "tool": "payments.refund",
  "decision": "deny",
  "reason": "refund above cap or wrong agent",
  "policy_version": "sha256:4be1c9...",
  "input_hash": "sha256:9b1c7e...",
  "session": "refund-agent-task-8841",
  "ts": "2026-11-20T09:41:58Z"
}
```

Recording decisions is only half the job. Teams that need an [immutable audit trail for every AI action](https://www.xccelera.ai/guard) must also make rewriting impossible, or at least instantly detectable. 

Two controls deliver that: signed checkpoints and write-once storage. Signatures show who vouched for the record, and retention locks show that nobody removed it.

A plain hash chain proves order, yet checking one entry means walking the whole chain. A Merkle tree removes that cost. Hash each batch of decision events into a single root, sign the root, and publish it.

An auditor can then verify any event with a short proof, and one edited byte changes the root.

The sketch below builds a root and signs it with Ed25519. In production, load the key from a KMS or HSM instead of generating it inline.

Also, publish each root outside the system that writes the events, because an attacker who controls the writer should not control the witness.

``` python
import hashlib
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey

def h(data: bytes) -> bytes:
    return hashlib.sha256(data).digest()

def merkle_root(leaves: list[bytes]) -> bytes:
    level = [h(leaf) for leaf in leaves]
    while len(level) > 1:
        if len(level) % 2:
            level.append(level[-1])
        level = [h(level[i] + level[i + 1]) for i in range(0, len(level), 2)]
    return level[0]

events = [
    b'{"event_id":"dec_01","decision":"allow"}',
    b'{"event_id":"dec_02","decision":"deny"}',
    b'{"event_id":"dec_03","decision":"allow"}',
]

root = merkle_root(events)
signing_key = Ed25519PrivateKey.generate()  # load from a KMS or HSM in production
signature = signing_key.sign(root)
signing_key.public_key().verify(signature, root)  # raises if invalid

events[1] = events[1].replace(b"deny", b"allow")  # simulate tampering
print("root matches after edit:", merkle_root(events) == root)
```

Signed roots expose edits. Write-once storage prevents deletion. Amazon S3 Object Lock in compliance mode blocks every user, including the root account, from overwriting or deleting a protected object version until retention expires.

Create the bucket with locking enabled, then set a default retention period that matches your regulatory duty. Store each signed checkpoint and each batch of events there.

Finally, remember that compliance mode cannot be shortened, so rehearse the setup in governance mode first.

Enabling Object Lock also turns on bucket versioning, so every checkpoint becomes a new object version and the full history of roots stays intact.

```
aws s3api create-bucket --bucket agent-audit-evidence \
  --region us-east-1 --object-lock-enabled-for-bucket

aws s3api put-object-lock-configuration --bucket agent-audit-evidence \
  --object-lock-configuration '{"ObjectLockEnabled":"Enabled","Rule":{"DefaultRetention":{"Mode":"COMPLIANCE","Days":365}}}'
```

Boundaries and logs both fail quietly, so test them like production code. Three checks cover most of the risk.

`opa test ./policies -v` on every pull request, and fail the build when a deny case starts passing.
Together these checks prove two claims. The policy blocks what it should, and nobody altered the record afterward.

Moreover, they give reviewers evidence they can rerun, which beats a screenshot every time.

Xccelera builds enterprise agentic AI with the view that control belongs inside the workflow, not beside it.

Its engineering approach pairs enforced permission policy with human approval wherever policy requires one, so risky actions reach an accountable person before they run.

Every decision, and every approved or blocked step, then lands in a tamper-evident evidence record as the work happens.

Developers never bolt logging on after launch, and security teams never rebuild a story from scattered files.

Audit readiness becomes a default behavior of the system. That is the standard worth demanding from any agent program: speed from automation, paired with proof that each action stayed inside its boundaries and that nobody changed the record afterward.
