AI

AgentOps: verify access revocation before reconnecting a production agent

A production runbook for proving that an AI agent can no longer reach a protected action across runtime tokens, MCP identities, queues and backend authorization before reconnecting it.

28 Oct 2026 aiagentopsagentsmcpidentityrbactokenssecurityobservabilitycanaryautomationrunbookrollbackproduction

An operations agent performs an unexpected write through an MCP tool. The on-call engineer removes the role assignment attached to the agent runtime, then retries a read-only probe. The call still succeeds. The immediate conclusion is that revocation failed.

That conclusion may be wrong. The successful request can use a token issued before the change, an identity carried by the MCP server rather than the agent, a queued job authenticated earlier, or a backend permission outside the role that was removed. Reconnecting the agent because the portal now shows the expected RBAC state is equally unsafe: configuration is not proof of enforcement.

The running case is a production agent that can read incidents and submit a bounded remediation job. This runbook leads to one decision: keep the agent quarantined, restore read-only access, reauthorize one write tool, or roll back the reauthorization.

Freeze the execution chain before changing more permissions

Stop new production actions while preserving the evidence needed to explain the last one. Disable the affected tool in the agent catalog or gateway, pause its execution queue, and retain trace IDs, job IDs and backend request IDs. Do not delete sessions or rotate every credential before you know which identity crossed each boundary.

Record the complete path, not only the identity configured on the agent resource:

  1. the user or service that initiated the run;
  2. the agent runtime identity;
  3. the credential presented to the MCP server;
  4. the identity used by the MCP server or automation worker downstream;
  5. the principal evaluated by the protected resource.
yaml revocation-evidence.yml
incident_id: INC-4821
frozen_at_utc: 2026-10-28T15:40:00Z
agent_release: ops-agent-2026.10.28.2
tool: remediation_job_submit
scope: /subscriptions/sub-prod/resourceGroups/rg-payments-prod

execution_chain:
initiator: operator-object-id
agent_runtime: managed-identity-object-id
mcp_authentication: workload-token
mcp_backend_identity: mcp-service-object-id
automation_worker: worker-managed-identity-object-id

evidence:
agent_trace_id: trace-7f3c
mcp_request_id: req-a91e
job_id: job-18422
backend_correlation_id: corr-5d02

containment:
tool_disabled: true
queue_paused: true
active_runs_reconciled: false

reauthorization_owner: platform-on-call
rollback: disable tool, pause queue, restore last approved role set

The freeze is complete only when no unclassified run remains active. A job accepted before revocation can execute later with a worker identity that still has access.

Prove which principal authorized the successful call

Start from the protected resource and work backward. Backend audit data is the authoritative place to identify the principal, operation, scope, result and request correlation. Agent traces explain intent and tool selection; they do not prove which identity the backend authorized.

For Azure control-plane actions, correlate the operation in AzureActivity. For data-plane services, use the resource-specific diagnostic table or application audit log. Field names vary by destination, so adapt the query to the deployed schema.

kusto 01-correlate-authorized-principal.kql
let Start = datetime(2026-10-28T15:20:00Z);
let End = datetime(2026-10-28T16:00:00Z);
AzureActivity
| where TimeGenerated between (Start .. End)
| where CorrelationId == "corr-5d02"
 or Properties_d has "req-a91e"
| project TimeGenerated, OperationNameValue, ActivityStatusValue,
        Caller, CallerIpAddress, CorrelationId, ResourceId,
        Claims = Claims_d
| order by TimeGenerated asc

Compare the observed principal ID and audience with the evidence pack. If the backend authorized the MCP service or automation worker, removing the agent runtime role cannot revoke that path. If the principal is correct but the scope is broader than expected, inspect inherited roles, group membership, direct assignments and service-specific access controls before adding another deny or role change.

Separate token lifetime from authorization state

A token is evidence that an identity provider authenticated a principal at issuance time. It is not a live mirror of every permission change. A component can keep using an already issued token until the resource rejects it or it expires. A process can also refresh credentials from a different source than the one the team changed.

Inspect token metadata inside the runtime without printing or persisting the token. On an Azure host using managed identity, a bounded probe can retain only the resource, issue window and expiry returned by the metadata endpoint:

bash 02-inspect-managed-identity-token-window.sh
RESOURCE="https://management.azure.com/"

curl --fail --silent --show-error --header "Metadata: true" "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2019-08-01&resource=$RESOURCE" | jq '{resource, token_type, expires_on, expires_in}'

Run this only from the intended Azure runtime. Never send the returned payload to shared logs because it also contains an access token; the jq projection must happen in the same protected process. Record whether the failing or successful call began before or after the role change and whether the process obtained a fresh token.

Also check application caches, connection pools, long-lived MCP sessions and worker processes. Restarting a component can force credential renewal, but it also destroys evidence. Use it as a controlled test after the active token window is documented, not as the first diagnostic action.

Build positive and negative revocation canaries

One failed request is not enough. It may target the wrong scope, use a malformed argument or fail before authorization. Build a small matrix that exercises the same backend operation through every legitimate execution path.

yaml revocation-canaries.yml
canaries:
- name: agent_read_after_revocation
  path: agent_to_mcp_to_backend
  expected: denied
- name: direct_mcp_read_after_revocation
  path: mcp_to_backend
  expected: denied
- name: queued_write_created_before_revocation
  path: queue_to_worker_to_backend
  expected: cancelled_or_denied
- name: unrelated_read_only_agent
  path: approved_control_identity
  expected: allowed

acceptance:
revoked_paths_denied: true
control_path_allowed: true
backend_principal_matches_inventory: true
no_unreconciled_job: true
no_token_or_secret_in_logs: true

Use a harmless resource or a no-effect operation where possible. Keep the same audience, tool schema and scope shape as production. A canary that changes all three cannot distinguish revocation from a routing or validation error.

The positive control matters: if the approved identity also fails, the test proves a broader outage, not a precise revocation. Conversely, if the agent path is denied but a direct MCP or queued-worker path succeeds, containment is incomplete.

Contain the system while revocation converges

Do not wait on RBAC propagation with the agent still able to schedule work. Keep controls at more than one boundary:

  • remove the sensitive tool from the runtime-visible catalog;
  • block new submissions at the MCP gateway or automation endpoint;
  • pause and inventory queued jobs;
  • revoke or rotate the actual credential when the evidence identifies a static secret or delegated session;
  • preserve a read-only incident path through a separately approved identity.

These controls are not substitutes for least privilege. They reduce the time between a configuration change and verified enforcement. Every temporary block needs an owner, expiry and removal test so that emergency containment does not become an undocumented production dependency.

Reauthorize one capability, then validate rollback

Restore access from the backend outward. Start with one read-only operation on one resource scope and one runtime release. Require a fresh credential, correlate the backend principal, and confirm that the negative write canary remains denied.

Only then reauthorize the bounded write tool. Keep human approval, idempotency key, dry-run or diff output, and an execution limit. Observe both the agent trace and backend audit record for the same correlation ID.

Roll back immediately if the runtime uses an unexpected principal, a revoked path still succeeds, a queued job cannot be reconciled, or the write scope exceeds the reviewed target. Disable the tool, pause the queue and restore the last approved role set. Rollback is validated when new write attempts are denied, in-flight work is accounted for, and the independent read-only control still works.

Conclusion

Access revocation is an end-to-end behavior, not a portal state. An agent action can cross several identities, token caches and asynchronous workers before a backend makes the final authorization decision.

The safe outcome is explicit: quarantine while any path remains unexplained, restore read-only access after fresh-token negative tests, reauthorize one bounded write capability with correlated evidence, or roll back at the first identity or scope mismatch. Reconnection comes after enforcement is proved, not when the configuration merely looks correct.