Back to Intelligence

AI Agents and the Shared Responsibility Gap: A Defender's Guide to Securing Agent Identities, Permissions, and Accountability

SA
Security Arsenal Team
November 23, 2026
12 min read

For two decades, the shared responsibility model was a cloud problem: your IaaS provider secured the hypervisor, you secured the workload, and the line was — more or less — drawn on a napkin. In 2026, that model is collapsing under the weight of a new class of principal that doesn't fit anywhere on the diagram: autonomous AI agents.

Token Security's recent analysis, covered by BleepingComputer, puts a name to what many of us in incident response have been seeing in the field: AI agents now operate across multiple platforms — reading email in Microsoft 365, writing to GitHub, calling AWS APIs, and browsing the web — while no single vendor in that chain has visibility into, or control over, the agent's end-to-end actions. The agent's identity is fragmented. Its permissions are scattered across OAuth grants, API keys, service accounts, and session tokens. And its accountability trail is a patchwork of logs in four different consoles that nobody is stitching together.

This is not a theoretical governance problem. From an attacker's perspective, an over-privileged AI agent with a long-lived token is a dream initial-access vector: it runs with legitimate credentials, blends into approved automation traffic, executes actions at machine speed, and — critically — falls into the accountability gap where no single security control assumes ownership. If you are running SOC operations or owning IAM in an environment that has deployed Copilot agents, Claude-based workflows, Devin-style coding agents, or custom LLM automations chained through Model Context Protocol (MCP) servers, this post is your defensive playbook.

Technical Analysis: Why Agents Break the Shared Responsibility Model

The anatomy of the gap

In classic cloud shared responsibility, the boundary is architectural: hardware vs. guest OS vs. application. AI agents break this because the boundary is now transactional — a single agent "task" may traverse five trust domains in five seconds:

  1. The agent runtime/platform (e.g., Microsoft Copilot Studio, OpenAI-based custom agents, LangChain/CrewAI orchestration, vendor SaaS agent products) — controls the model, but not the downstream systems it touches.
  2. The identity layer (Entra ID, Okta, AWS IAM, GCP service accounts) — issues tokens but typically cannot see what the agent intended to do, only what API was called.
  3. The SaaS/data plane (M365, Salesforce, Slack, GitHub, Google Workspace) — sees an API call from a valid token, not that the token was wielded by an autonomous process acting on untrusted input.
  4. MCP servers and tool connectors — the connective tissue that gives agents "hands" (filesystem, shell, database, browser access), frequently running locally with whatever permissions the invoking user had.
  5. The endpoint — where agent CLIs, MCP servers, and browser-automation sessions actually execute, often outside EDR policy because they look like legitimate Node/Python developer tooling.

Each vendor legitimately claims they secured their layer. Nobody owns the composite identity. That is the shared responsibility gap, and it produces four concrete failure modes defenders must plan for:

Failure mode 1: Non-human identity (NHI) sprawl with excessive standing privilege

Agents are provisioned the way developers provision dev-test service accounts: broad OAuth scopes (Mail.ReadWrite, Directory.Read.All, repo full scope), long-lived secrets, no rotation, no owner. Machine identities now outnumber humans by an order of magnitude in most enterprises, and agent adoption is accelerating the ratio. A single compromised agent token with app-only Graph permissions is equivalent to handing an attacker a persistent, MFA-exempt account.

Failure mode 2: Prompt injection → privilege execution

Because agents consume untrusted content (email, web pages, tickets, documents) and then act, indirect prompt injection converts a content-parsing flaw into an authenticated action: exfiltrating mailbox content, creating forwarding rules, pushing code, or invoking an MCP tool that runs shell commands. The platform sees a valid tool call. The SaaS sees a valid API request. Neither sees that the agent was steered by hostile input — and neither considers it their problem.

Failure mode 3: Token and consent abuse across platforms

Attackers don't need to "hack the model." They phish for OAuth consent, register malicious MCP servers or connectors, or steal agent API keys from .env files and config stores — then operate entirely through sanctioned API surfaces. Cross-platform means a token minted in Entra can move data out of Google Workspace through an agent's connector without either vendor correlating the session.

Failure mode 4: The accountability vacuum

When an agent deletes a production resource or exfiltrates a SharePoint library, who answers for it — the agent vendor, the IdP, the SaaS, or the admin who approved the OAuth grant in 2025 and forgot? Post-incident, we've seen engagements where reconstructing a single agent action required joining logs from four vendors with mismatched retention windows. If you cannot answer "what identity did this agent use, what scopes did it have, and who approved them" in under an hour, you have the gap.

Exploitation status

There is no single CVE here — the risk is architectural and actively exploited in the wild through OAuth consent phishing, token theft, and prompt-injection-driven agent abuse, all of which have been documented in real intrusions over the past 12 months. Treat this as a current, high-likelihood attack surface, not a future state.

Detection & Response

The detections below target the observable behaviors of agent abuse: AI agent runtimes spawning shells, risky OAuth consent grants, and anomalous non-human identity activity. They are scoped to minimize noise — tune thresholds to your agent inventory (see Remediation; if you don't have an inventory, build one first, because without it these rules cannot distinguish agent from attacker).

Sigma Rules

YAML
---
title: AI Agent Runtime or MCP Server Spawning Shell or Script Interpreter
id: 3f7a9c1e-2b4d-4e8a-9c5f-6a1b2d3e4f50
status: experimental
description: Detects common AI agent runtimes, coding agents, or MCP server processes (Node/Python-based) spawning command shells or script interpreters. Indicative of prompt-injection-driven tool execution or malicious MCP tool invocation.
references:
  - https://www.bleepingcomputer.com/news/security/ai-agents-are-creating-a-shared-responsibility-gap/
  - https://attack.mitre.org/techniques/T1059/
  - https://attack.mitre.org/techniques/T1190/
author: Security Arsenal
date: 2026/02/13
tags:
  - attack.execution
  - attack.t1059
logsource:
  category: process_creation
  product: windows
detection:
  selection_parent:
    ParentImage|endswith:
      - '\node.exe'
      - '\python.exe'
      - '\python3.exe'
      - '\uv.exe'
      - '\npx.exe'
    ParentCommandLine|contains:
      - 'mcp'
      - 'claude'
      - 'cursor'
      - 'copilot'
      - 'langchain'
      - 'agent'
  selection_child:
    Image|endswith:
      - '\cmd.exe'
      - '\powershell.exe'
      - '\pwsh.exe'
      - '\wscript.exe'
      - '\cscript.exe'
      - '\mshta.exe'
      - '\rundll32.exe'
  condition: selection_parent and selection_child
falsepositives:
  - Legitimate agent tool use in development environments; restrict deployment to servers and non-developer endpoints, or maintain an allowlist of approved agent parent processes by hash and path
level: high
---
title: High-Risk OAuth Application Consent Grant for AI or Automation App
id: 8c2e5b41-7f3a-4d9c-b1e6-5d8a9f0c2b34
status: experimental
description: Detects admin or user consent granted to applications requesting high-impact Microsoft Graph scopes commonly abused to give AI agents or attacker apps persistent mailbox and directory access.
references:
  - https://www.bleepingcomputer.com/news/security/ai-agents-are-creating-a-shared-responsibility-gap/
  - https://attack.mitre.org/techniques/T1550/001/
  - https://attack.mitre.org/techniques/T1528/
author: Security Arsenal
date: 2026/02/13
tags:
  - attack.persistence
  - attack.credential_access
  - attack.t1550.001
logsource:
  product: azure
  service: auditlogs
detection:
  selection_operation:
    OperationName:
      - 'Consent to application'
      - 'Add OAuth2PermissionGrant'
      - 'Add app role assignment to service principal'
  selection_scope:
    TargetResources|contains:
      - 'Mail.Read'
      - 'Mail.ReadWrite'
      - 'Mail.Send'
      - 'Directory.Read.All'
      - 'Directory.ReadWrite.All'
      - 'Files.ReadWrite.All'
      - 'Sites.FullControl.All'
      - 'Application.ReadWrite.All'
      - 'RoleManagement.ReadWrite.Directory'
  condition: selection_operation and selection_scope
falsepositives:
  - Approved enterprise agent deployments; alert should trigger change-ticket verification workflow, not auto-block
level: high
---
title: Non-Human Identity Creating Additional Credentials or API Keys
id: 61d4f8a2-9c3b-4e7d-a2f1-8b6c4d9e0a17
status: experimental
description: Detects service principals or agent identities creating new secrets, keys, or certificates — a common pattern when a compromised agent establishes durable access or when a malicious agent self-escalates.
references:
  - https://www.bleepingcomputer.com/news/security/ai-agents-are-creating-a-shared-responsibility-gap/
  - https://attack.mitre.org/techniques/T1098/001/
author: Security Arsenal
date: 2026/02/13
tags:
  - attack.persistence
  - attack.privilege_escalation
  - attack.t1098.001
logsource:
  product: azure
  service: auditlogs
detection:
  selection:
    OperationName|contains:
      - 'Add service principal credentials'
      - 'Update application – Certificates and secrets'
      - 'Add key credential to application'
      - 'Add password credential to application'
  filter_human:
    InitiatedBy|contains: '@'
  condition: selection and not filter_human
falsepositives:
  - Automated secrets rotation pipelines; exclude known rotation service principals by object ID
level: critical

KQL — Microsoft Sentinel / Defender

Hunt for anomalous agent / service principal behavior and risky consent grants across Entra and SaaS audit data.

KQL — Microsoft Sentinel / Defender
// Hunt 1: New OAuth consent grants with high-impact scopes (agent token abuse surface)
AuditLogs
| where TimeGenerated > ago(7d)
| where OperationName in~ ("Consent to application", "Add OAuth2PermissionGrant", "Add app role assignment to service principal")
| mv-expand TargetResources
| mv-expand TargetResources.modifiedProperties
| extend PropName = tostring(TargetResources_modifiedProperties.displayName)
| extend NewValue = tostring(TargetResources_modifiedProperties.newValue)
| where PropName has "Scope" or NewValue has_any ("Mail.Read", "Mail.ReadWrite", "Mail.Send", "Directory.Read.All", "Files.ReadWrite.All", "Sites.FullControl.All", "Application.ReadWrite.All", "offline_access")
| extend Initiator = tostring(InitiatedBy.user.userPrincipalName), InitiatorIp = tostring(InitiatedBy.user.ipAddress)
| project TimeGenerated, OperationName, Initiator, InitiatorIp, AppName = tostring(TargetResources.displayName), NewValue, CorrelationId
| sort by TimeGenerated desc;

// Hunt 2: Service principal sign-ins from new geographies/IPs (stolen agent tokens)
let KnownIPs = AADServicePrincipalSignInLogs
| where TimeGenerated between (ago(30d) .. ago(1d))
| summarize by IPAddress, AppId;
AADServicePrincipalSignInLogs
| where TimeGenerated > ago(1d)
| where IPAddress !in (KnownIPs | summarize make_list(IPAddress))
| summarize SignInCount = count(), Locations = make_set(Location), Resources = make_set(ResourceDisplayName) by AppId, AppDisplayName, IPAddress, bin(TimeGenerated, 1h)
| sort by SignInCount desc;

// Hunt 3: Agent runtimes / MCP servers spawning interpreters on endpoints (Defender XDR)
DeviceProcessEvents
| where TimeGenerated > ago(7d)
| where InitiatingProcessFileName in~ ("node.exe", "python.exe", "python3.exe", "npx.exe", "uv.exe")
| where InitiatingProcessCommandLine has_any ("mcp", "claude", "cursor", "langchain", "agent")
| where FileName in~ ("cmd.exe", "powershell.exe", "pwsh.exe", "rundll32.exe", "wscript.exe", "mshta.exe", "curl.exe")
| project TimeGenerated, DeviceName, InitiatingProcessCommandLine, FileName, ProcessCommandLine, AccountName
| sort by TimeGenerated desc;

Velociraptor VQL

Hunt endpoints for AI agent installations, MCP server configurations, and the credentials they store — the artifacts you'll need during an agent-compromise investigation.

VQL — Velociraptor
-- Enumerate AI agent processes, MCP server configs, and potential stored agent credentials
SELECT Pid, Name, CommandLine, Exe, Username
FROM pslist()
WHERE CommandLine =~ '(?i)(mcp|model.context.protocol|claude|langchain|crewai|autogen)'
   OR Exe =~ '(?i)(claude|cursor|copilot|windsurf|cline)'

-- Hunt MCP/agent configuration files that reveal connected tools and embedded secrets
SELECT FullPath, Size, Mtime
FROM glob(globs=[
  'C:/Users/*/.claude*/**/*.json',
  'C:/Users/*/AppData/Roaming/Claude*/**/*.json',
  'C:/Users/*/.cursor*/**/mcp*.json',
  'C:/Users/*/.config/claude*/**/*.json',
  'C:/Users/*/.aws/credentials',
  'C:/Users/*/.env*',
  'C:/Users/*/.config/gcloud/application_default_credentials.json'
])
WHERE NOT IsDir
ORDER BY Mtime DESC

Audit Script — Discover Your Agent Identity Exposure

You cannot defend what you haven't inventoried. This PowerShell script (requires the Microsoft Graph PowerShell SDK with Application.Read.All and AuditLog.Read.All) enumerates service principals with high-impact app-only permissions, stale credentials, and recent consent grants — the exact population an attacker targets first.

PowerShell
# AI Agent / NHI exposure audit — run as a tenant-read administrator
# Step 1: Connect with least-privilege read scopes
Connect-MgGraph -Scopes "Application.Read.All","Directory.Read.All","AuditLog.Read.All"

# Step 2: Enumerate service principals holding high-impact app-only Graph roles
$highImpact = @('Mail.Read','Mail.ReadWrite','Mail.Send','Directory.Read.All','Directory.ReadWrite.All','Files.ReadWrite.All','Sites.FullControl.All','Application.ReadWrite.All','RoleManagement.ReadWrite.Directory')
$graphSp = Get-MgServicePrincipal -Filter "appId eq '00000003-0000-0000-c000-000000000000'"
$roles = $graphSp.AppRoles | Where-Object { $_.Value -in $highImpact }
foreach ($role in $roles) {
  Get-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $graphSp.Id -All |
    Where-Object { $_.AppRoleId -eq $role.Id } |
    ForEach-Object {
      $sp = Get-MgServicePrincipal -ServicePrincipalId $_.PrincipalId
      [PSCustomObject]@{ AgentIdentity = $sp.DisplayName; SpObjectId = $sp.Id; Scope = $role.Value; Created = $sp.AdditionalProperties.createdDateTime }
    }
} | Export-Csv .\agent-privileged-identities.csv -NoTypeInformation

# Step 3: Find stale credentials (older than 90 days = rotation failure)
Get-MgServicePrincipal -All | Where-Object { $_.PasswordCredentials.EndDateTime -and ($_.PasswordCredentials | Where-Object { $_.StartDateTime -lt (Get-Date).AddDays(-90) }) } |
  Select-Object DisplayName, Id, @{N='OldestSecretStart';E={ ($_.PasswordCredentials | Sort-Object StartDateTime)[0].StartDateTime }} |
  Export-Csv .\agent-stale-secrets.csv -NoTypeInformation

# Step 4: Recent consent grants in the last 30 days for change verification
Get-MgAuditLogDirectoryAudit -Filter "activityDateTime ge $((Get-Date).AddDays(-30).ToString('yyyy-MM-dd'))" -All |
  Where-Object { $_.ActivityDisplayName -match 'Consent to application|Add OAuth2PermissionGrant' } |
  Select-Object ActivityDateTime, ActivityDisplayName, @{N='Initiator';E={ $_.InitiatedBy.user.userPrincipalName }}, @{N='Target';E={ $_.TargetResources[0].displayName }} |
  Export-Csv .\agent-consent-grants-30d.csv -NoTypeInformation

Write-Host "Review the three CSVs. Every identity without an owner, ticket, and rotation date is part of your shared responsibility gap."

Remediation

There is no patch for an architectural gap — remediation is a governance and engineering program. Prioritize in this order:

1. Build the agent inventory (this week). Enumerate every AI agent, MCP server, connector, and the NHIs they use across Entra, Okta, AWS IAM, GCP, and your SaaS admin consoles. Every entry needs an owner, a business justification, an approved scope list, and a credential rotation date. The script above gives you the Entra half; repeat the exercise for AWS (aws iam list-roles / access analyzer), GCP service accounts, and GitHub/GitLab tokens.

2. Collapse standing privilege. Replace long-lived API keys and client secrets with short-lived, workload-identity credentials (Managed Identities, workload identity federation, SPIFFE/SPIRE where feasible). Scope OAuth grants to the minimum per-task permission — an agent that triages email does not need Mail.ReadWrite tenant-wide; it needs a scoped grant to one mailbox. Enforce a 90-day maximum secret lifetime with automated rotation.

3. Constrain the action surface. For MCP and tool connectors, maintain an explicit allowlist of approved servers and tools; block agents from invoking shell, filesystem-write, or network tools without a human-in-the-loop approval step for production systems. Treat indirect prompt injection as a given: agents processing untrusted content (email, web, tickets) must operate in a read-mostly permission envelope with egress filtering on the tool layer.

4. Centralize the accountability trail. Pipe agent platform logs, IdP sign-in/audit logs, MCP server logs, and SaaS audit logs into one SIEM correlation layer keyed on the agent identity, not the platform. Define retention so you can reconstruct any agent action for at least 90 days. Pre-build the join — during an incident is the wrong time to learn that your Copilot Studio logs live in a different console than your Graph audit logs.

5. Contractually close the vendor gap. Update your shared responsibility matrices and procurement reviews: require agent vendors to document what identity their agent assumes, what telemetry they emit (OpenTelemetry/SIEM-forwardable), how tokens are stored, and what their kill-switch and revocation SLA is. If a vendor cannot answer "how do I see everything your agent did yesterday," that is a procurement blocker.

6. Prepare the incident playbook. Pre-stage revocation runbooks: one-click disable for the agent's service principal, mass OAuth grant revocation (Revoke-MgUserSignInSession, app role assignment removal), and MCP server isolation steps. Test it in a tabletop — the organizations that contain agent compromises in minutes are the ones that rehearsed the revocation path before they needed it.

The shared responsibility gap isn't closed by any single vendor's roadmap — it's closed by defenders who treat every AI agent as a privileged, untrusted-input-consuming, cross-platform identity that they alone are accountable for governing.

Related Resources

Security Arsenal Penetration Testing Services AlertMonitor Platform Book a SOC Assessment vulnerability-management Intel Hub

Is your security operations ready?

Get a free SOC assessment or see how AlertMonitor cuts through alert noise with automated triage.