Skip to content
mentoor

Topic 5 of 5 · 4 min read

Auditing agent permissions and action logs

Goal: Read an agent's permission grant and action log, find unused or excessive access, and propose what to revoke.

Compare what the agent is allowed to do with what it actually did, then remove the difference. Permissions drift upward over time. A review brings them back down.

Check yourself · 1 of 3

What is the main goal of a permission review for an agent?

Choose one answer

Why it matters

Agents get new permissions in a hurry: a 403 error, a quick scope added, a demo that needed one more repository. Nobody removes them later. After a few months the grant is much wider than the job. The same is true for ordinary cloud accounts, which is why cloud guidance such as AWS IAM advice recommends reviewing last-used information and removing access that is not used. The action log is the evidence: it shows what the agent really touched.

How to do it

  1. Export the grant. Scopes, roles, repositories, databases, secrets, expiry, owner.
  2. Export the action log for a period. Each entry should have time, agent, acting user, tool, target, result and request id.
  3. Join them. For every permission, ask: was it used in the period?
  4. Sort into three groups. Used and needed, used but wider than needed, unused.
  5. Revoke the unused, narrow the wide. Do it one change at a time and watch for failures, so you learn which ones were needed.
  6. Read the log for oddities. Calls at odd hours, new targets, many denied attempts, large reads, a tool used far more than usual, calls to outside hosts.
  7. Set an owner and a review date. Every grant has a named person and an expiry, so reviews happen without a reminder.

Before and after

{
  "agent": "report-agent",
  "granted": ["orders:read", "orders:write", "customers:read", "billing:read", "storage:write"],
  "used_last_90_days": ["orders:read", "customers:read"]
}

Three grants were never used, and two of them allow writes. The proposal is to revoke orders:write, billing:read and storage:write, and keep the two that match real work.

What goes wrong

  • Grant reviewed once, at creation. Permissions added later are never looked at again.
  • Logs that cannot answer questions. No actor, no target or no result, so you cannot tell what the agent did.
  • Logging secrets. Tokens and customer data copied into the log become a new leak. Log identifiers and outcomes, not contents.
  • Revoking everything unused at once. A quarterly job fails, and people re-grant too much to fix it fast.
  • Nobody owns the agent. With no owner, no one decides.

Examples

Reading a denied-call pattern

03:12 support-agent delete_ticket id=4 DENIED
03:12 support-agent delete_ticket id=5 DENIED
03:12 support-agent delete_ticket id=6 DENIED

The agent has no delete grant and tried it many times at 3 a.m. That is not a reason to add the grant. It is a reason to find out what asked for those deletes, for example a poisoned ticket.

A revocation proposal

Agent release-bot, 90-day review.

keep:    contents:read, pull_requests:write
revoke:  actions:write (never used), admin:org (never used)
review:  2027-03-01, owner: platform team

Each line has a reason, and the review date makes the next check automatic.

Key points

  • Compare granted permissions with permissions actually used in the action log.
  • Revoke what is unused and narrow what is wider than the work needs.
  • Logs need actor, acting user, tool, target, result and request id to be useful.
  • Look in logs for odd hours, new targets, repeated denials and unusually large reads.
  • Give every grant an owner and a review date so the check happens regularly.

Common mistakes

  • Reviewing the grant only on the day it was created.
  • Keeping logs that lack the actor, target or result, so they cannot answer an incident question.
  • Writing tokens or full customer records into the action log.
  • Treating repeated denied calls as noise instead of a signal to investigate.

Check yourself · 2 of 3

An agent holds read and write on billing but its log for 90 days shows only reads. What do you propose?

Choose one answer

Check yourself · 3 of 3

Which log entry is most useful for investigating an agent incident?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic