Back to Intelligence

AI Agents Are Privileged Users: How to Audit Non-Human Identities Before They Become Your Next Insider Threat

SA
Security Arsenal Team
September 28, 2026
13 min read

Dark Reading recently surfaced a question that every CISO should be asking in 2026: AI agents are privileged users — who is auditing their access? The observation is uncomfortable because it is accurate. Enterprises spend millions on user behavior analytics, insider threat programs, and identity governance for human employees. Meanwhile, autonomous AI agents — copilots wired into ticketing systems, LLM-driven automation chained to cloud APIs, agentic frameworks with standing access to production databases — operate with broad privileges, minimal logging, and in many organizations, no owner at all.

This is not a hypothetical future risk. Non-human identities (NHIs) — service accounts, service principals, API keys, OAuth tokens, and now AI agent credentials — already outnumber human identities in most mature environments by an order of magnitude. Industry analyses consistently place the ratio at 40:1 or higher. Every one of those identities is an authentication path that bypasses your MFA rollout, your phishing-resistant hardware keys, and your security awareness training. When an AI agent is manipulated via prompt injection, or when its long-lived API key leaks from a CI/CD pipeline or a public repository, the attacker inherits whatever that agent was allowed to do — and in most environments, that is far too much.

The defensive gap is governance, not tooling. Your SIEM already ingests the logs. Your identity provider already issues the tokens. What is missing is the discipline to treat AI agents as what they are: privileged, non-human insiders that require inventory, least privilege, behavioral baselining, and continuous audit.

Technical Analysis: How AI Agents Become Insider Threats

The Privilege Accumulation Problem

AI agents rarely get purpose-built access. They get convenient access. In engagement after engagement, we find the same pattern:

  • Over-scoped service principals. An agent built to summarize tickets gets Mail.ReadWrite and Files.ReadWrite.All on Microsoft Graph because the developer needed one attachment workflow and scoping was "phase two." Phase two never ships.
  • Shared standing credentials. A single API key or client secret shared across multiple agent workloads, stored in environment variables, plaintext config files, or worse — committed to source control.
  • Human-equivalent privileges without human-equivalent oversight. Agents are granted membership in privileged groups (Domain Admins, Global Administrator, cloud IAM roles with *:* permissions) because the automation "just needs to work."
  • No behavioral baseline. Nobody knows what normal looks like for the agent, so nobody can tell when it deviates.

Attack Paths Defenders Must Model

From a threat-modeling perspective, there are three realistic paths by which an AI agent becomes an active threat in your environment:

  1. Prompt injection / tool misuse (confused deputy). An attacker embeds malicious instructions in content the agent processes — an email, a web page, a support ticket, a document in a SharePoint library. The agent, acting as a confused deputy, executes the injected instructions using its own legitimate privileges: exfiltrating mailbox contents, invoking downstream APIs, or modifying records. The activity is technically authorized — it originates from a legitimate identity with legitimate scopes — which makes it invisible to controls keyed on authentication anomalies.

  2. Credential theft and replay. Agent credentials are typically long-lived bearer tokens, client secrets, or API keys. They leak through CI/CD logs, developer workstations, container images, and third-party SaaS integrations. Once stolen, they are replayed from attacker infrastructure with no MFA challenge, no conditional access evaluation (service principals are commonly excluded), and no impossible-travel alerting tuned for machine identities.

  3. Supply-chain compromise of the agent framework itself. Agentic frameworks, orchestration layers, and MCP (Model Context Protocol) servers are software dependencies like any other. A compromised plugin or tool connector inherits the agent's privilege surface. We covered a structurally similar risk pattern in our analysis of the React2Shell mass exploitation campaign — the lesson generalizes: the automation layer is part of your attack surface, and adversaries know defenders under-monitor it.

Exploitation Status

There is no single CVE assigned to this threat class — it is an architectural and governance weakness, not a patched product bug. However, prompt injection against LLM-integrated applications is extensively documented in real-world research, agent framework vulnerabilities are being disclosed at an accelerating cadence through 2025 and 2026, and stolen machine credentials remain one of the most common initial access vectors we see in IR engagements. Treat this as an actively exploited threat pattern, not a theoretical one.

Detection & Response

The core detection philosophy: machine identities should be the most predictable actors in your environment. An AI agent that suddenly logs on interactively, consents to new permissions, touches a resource it has never touched, or spawns a scripting engine is an anomaly worth paging on. The detections below target exactly those behaviors.

Sigma Rules

YAML
---
title: Service Account or AI Agent Interactive Logon
id: 3f8a2c91-7d44-4b6e-a921-9c1e5f7a2b83
status: experimental
description: Detects interactive or remote-interactive logons by service accounts and AI agent identities. Machine identities should authenticate via service logon types, not interactive sessions. Interactive use indicates credential theft, hands-on-keyboard abuse, or an engineer operating under an agent identity.
references:
  - https://www.darkreading.com/vulnerabilities-threats/ai-agents-are-privileged-users-who-is-auditing-their-access
  - https://attack.mitre.org/techniques/T1078/004/
author: Security Arsenal
date: 2026/06/15
tags:
  - attack.defense_evasion
  - attack.persistence
  - attack.privilege_escalation
  - attack.initial_access
  - attack.t1078.004
logsource:
  product: windows
  service: security
detection:
  selection:
    LogonType:
      - 2
      - 10
    TargetUserName|startswith:
      - 'svc-'
      - 'svc_'
      - 'ai-'
      - 'agent-'
      - 'bot-'
  filter_known_owners:
    TargetUserName|contains: 'healthmailbox'
  condition: selection and not filter_known_owners
falsepositives:
  - Break-glass administrative use of service accounts — tune to a documented allowlist of accounts approved for interactive use
  - Legacy applications that require console sessions; document and allowlist explicitly
level: high
---
title: Privileged OAuth Consent Granted to Application or Agent
id: 8b1d4e72-3a9f-4c51-b8d6-2e7a9f4c1d05
status: experimental
description: Detects admin or user consent grants assigning high-impact Microsoft Graph or cloud API permissions to an application or service principal — a common path for AI agents to accumulate excessive, unmonitored privilege.
references:
  - https://www.darkreading.com/vulnerabilities-threats/ai-agents-are-privileged-users-who-is-auditing-their-access
  - https://attack.mitre.org/techniques/T1550/001/
author: Security Arsenal
date: 2026/06/15
tags:
  - attack.persistence
  - attack.privilege_escalation
  - attack.t1550.001
logsource:
  product: azure
  service: auditlogs
detection:
  selection:
    OperationName:
      - 'Consent to application'
      - 'Add service principal'
      - 'Add app role assignment to service principal'
    RiskyPermissions|contains:
      - 'Mail.Read'
      - 'Mail.ReadWrite'
      - 'Mail.Send'
      - 'Files.Read.All'
      - 'Files.ReadWrite.All'
      - 'Sites.FullControl.All'
      - 'Directory.ReadWrite.All'
      - 'RoleManagement.ReadWrite.Directory'
      - 'Application.ReadWrite.All'
      - 'full_access_as_app'
  condition: selection
falsepositives:
  - Approved enterprise application onboarding — alert should route to identity governance for attestation, not auto-close
level: high
---
title: Scripting Engine or Shell Spawned Under Service Account Context
id: c4e7f1a3-6b28-4d95-a317-5f2c8e9b4d61
status: experimental
description: Detects command shells and scripting engines executing under service account or AI agent identities. Agents calling tools through an orchestration layer should not be spawning interactive shells directly — this pattern is consistent with prompt-injection-driven command execution or stolen-credential abuse.
references:
  - https://www.darkreading.com/vulnerabilities-threats/ai-agents-are-privileged-users-who-is-auditing-their-access
  - https://attack.mitre.org/techniques/T1059/
author: Security Arsenal
date: 2026/06/15
tags:
  - attack.execution
  - attack.t1059
logsource:
  category: process_creation
  product: windows
detection:
  selection_user:
    User|contains:
      - 'svc-'
      - 'svc_'
      - 'ai-'
      - 'agent-'
  selection_image:
    Image|endswith:
      - '\powershell.exe'
      - '\pwsh.exe'
      - '\cmd.exe'
      - '\wscript.exe'
      - '\cscript.exe'
      - '\mshta.exe'
      - '\curl.exe'
  filter_automation:
    CommandLine|contains:
      - 'C:\\ApprovedAutomation\\'
  condition: selection_user and selection_image and not filter_automation
falsepositives:
  - Documented automation platforms (RPA, scheduled maintenance) — allowlist by full CommandLine path, never by account name alone
level: high

KQL — Microsoft Sentinel / Defender

This hunt baselines service principal behavior over the prior 14 days and surfaces agents authenticating from new IP addresses, touching new resources, or operating outside their historical application set — the exact signal you get when an agent credential is replayed or a prompt-injected agent is steered toward new data.

KQL — Microsoft Sentinel / Defender
// Baseline service principal / AI agent behavior and flag first-seen deviations
let lookback = 14d;
let recent = 1d;
let baseline = SigninLogs
    | where TimeGenerated between (ago(lookback) .. ago(recent))
    | where Identity hasprefix "svc-" or Identity hasprefix "ai-" or Identity hasprefix "agent-"
       or AppDisplayName has_any ("agent", "copilot", "automation", "bot")
    | summarize BaselineIPs = make_set(IPAddress), BaselineResources = make_set(ResourceDisplayName),
                BaselineApps = make_set(AppDisplayName)
      by Identity;
SigninLogs
| where TimeGenerated >= ago(recent)
| where Identity hasprefix "svc-" or Identity hasprefix "ai-" or Identity hasprefix "agent-"
   or AppDisplayName has_any ("agent", "copilot", "automation", "bot")
| summarize RecentIPs = make_set(IPAddress), RecentResources = make_set(ResourceDisplayName),
            SigninCount = count(), LastSeen = max(TimeGenerated)
  by Identity, AppDisplayName
| join kind=inner baseline on Identity
| extend NewIPs = set_difference(RecentIPs, BaselineIPs)
| extend NewResources = set_difference(RecentResources, BaselineResources)
| where array_length(NewIPs) > 0 or array_length(NewResources) > 0
| project Identity, AppDisplayName, LastSeen, SigninCount, NewIPs, NewResources, BaselineIPs, BaselineResources
| order by LastSeen desc;

For environments forwarding Windows Security events, this companion query catches the interactive-logon anomaly directly:

KQL — Microsoft Sentinel / Defender
// Interactive logons (Type 2/10) by machine identities in the last 24 hours
SecurityEvent
| where TimeGenerated >= ago(24h)
| where LogonType in (2, 10)
| where TargetUserName startswith "svc-" or TargetUserName startswith "svc_"
   or TargetUserName startswith "ai-" or TargetUserName startswith "agent-" or TargetUserName startswith "bot-"
| where TargetUserName !has "healthmailbox"
| summarize LogonCount = count(), SourceSystems = make_set(Computer), SourceIPs = make_set(IpAddress)
  by TargetUserName, LogonType
| order by LogonCount desc;

Velociraptor VQL

Use this artifact during an IR sweep or scheduled hunt to identify scripting engines and shells running under machine identities across the fleet — strong corroborating evidence when you suspect a compromised agent credential or injection-driven execution.

VQL — Velociraptor
-- Hunt for shells and scripting engines executing under service/agent accounts
SELECT Pid, Ppid, Name, CommandLine, Exe, Username, CreateTime
FROM pslist()
WHERE (Username =~ '(?i)(svc[-_]|ai-|agent-|bot-)')
  AND (Name =~ '(?i)(powershell|pwsh|cmd\.exe|wscript|cscript|mshta|curl)')
ORDER BY CreateTime DESC

Audit & Hardening Script

Run this in an elevated session with the Microsoft Graph PowerShell SDK (Connect-MgGraph -Scopes "Application.Read.All","Directory.Read.All","AuditLog.Read.All") to inventory over-privileged app registrations and service principals, and stale machine credentials — the foundation of any AI agent governance program.

PowerShell
# Requires: Microsoft.Graph PowerShell SDK, read-only scopes
# Inventories high-privilege app consent and stale service principal credentials

$HighRiskScopes = @(
    'Mail.Read','Mail.ReadWrite','Mail.Send','Files.Read.All','Files.ReadWrite.All',
    'Sites.FullControl.All','Directory.ReadWrite.All','RoleManagement.ReadWrite.Directory',
    'Application.ReadWrite.All','full_access_as_app'
)

# 1. Find service principals holding high-risk Graph app roles
$roleAssignments = Get-MgServicePrincipal -All | ForEach-Object {
    $sp = $_
    Get-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $sp.Id -All | ForEach-Object {
        [PSCustomObject]@{
            ServicePrincipal = $sp.DisplayName
            SPObjectId       = $sp.Id
            AppRoleId        = $_.AppRoleId
            ResourceId       = $_.ResourceId
            CreatedDateTime  = $_.CreatedDateTime
        }
    }
}
$roleAssignments | Export-Csv -Path ".\SP-AppRoleAssignments-$(Get-Date -Format yyyyMMdd).csv" -NoTypeInformation

# 2. Flag app registrations whose required resource access includes high-risk scopes
$flagged = Get-MgApplication -All | Where-Object {
    $app = $_
    $app.RequiredResourceAccess.ResourceAccess | Where-Object {
        $HighRiskScopes -contains $_.Id -or $_.Type -eq 'Role'
    }
} | Select-Object DisplayName, AppId, Id, CreatedDateTime
$flagged | Export-Csv -Path ".\Apps-HighRiskScopes-$(Get-Date -Format yyyyMMdd).csv" -NoTypeInformation

# 3. Identify stale or long-lived credentials on service principals (rotation candidates)
$staleCutoff = (Get-Date).AddDays(-180)
$staleCreds = Get-MgServicePrincipal -All | ForEach-Object {
    $sp = $_
    $sp.PasswordCredentials | Where-Object { $_.StartDateTime -lt $staleCutoff } | ForEach-Object {
        [PSCustomObject]@{
            ServicePrincipal = $sp.DisplayName
            KeyId            = $_.KeyId
            StartDateTime    = $_.StartDateTime
            EndDateTime      = $_.EndDateTime
            AgeDays          = ((Get-Date) - $_.StartDateTime).Days
        }
    }
}
$staleCreds | Sort-Object AgeDays -Descending | Export-Csv -Path ".\SP-StaleCredentials-$(Get-Date -Format yyyyMMdd).csv" -NoTypeInformation

Write-Output "Exports complete. Review SP-AppRoleAssignments, Apps-HighRiskScopes, and SP-StaleCredentials CSVs. Any secret older than 180 days on a non-human identity is a rotation candidate — for an AI agent, it is an incident waiting to be triaged."

Remediation: A Governance Program for Non-Human Identities

There is no patch for this problem — there is a program. Prioritize in this order:

  1. Inventory every non-human identity. You cannot audit what you cannot enumerate. Pull service accounts from AD/Entra ID, service principals, API keys in your secrets manager, OAuth grants, and CI/CD workload identities. Assign each one a named human owner. Orphaned identities get disabled, not debated.

  2. Enforce least privilege on agent scopes. Map every AI agent to the minimum API permissions required for its function. Files.ReadWrite.All becomes per-site or per-drive scoping. Wildcard IAM actions become explicit resource ARNs. If the vendor's documentation cannot justify a scope, remove it and watch what breaks — in a sandbox first.

  3. Kill long-lived credentials. Move agents to short-lived, workload-identity-based tokens (managed identities, workload identity federation, SPIFFE/SPIRE) wherever the platform supports it. Where secrets are unavoidable, enforce automated rotation at 90 days or less and store them exclusively in a secrets manager — never in environment variables checked into pipelines.

  4. Baseline and alert on agent behavior. Machine identities are deterministic by nature — that is your detection advantage. Alert on first-seen IPs, first-seen resources, first-seen API operations, interactive logons, and consent grants. The KQL and Sigma content above is your starting point.

  5. Apply conditional access to service principals. Entra ID Conditional Access for workload identities (and equivalents in other IdPs) lets you restrict agent authentication to known IP ranges and block sign-ins from anomalous locations. Most tenants we assess have this licensed and unconfigured.

  6. Human-in-the-loop for high-impact actions. Any agent operation that sends external email, moves money, deletes data, or changes access controls should require human approval or at minimum a dual-control workflow. Prompt injection is a solved problem only at the architecture layer, not the model layer.

  7. Log agent actions at the tool-call layer. Authentication logs tell you the agent connected; they do not tell you what the agent did. Require your agent frameworks to emit structured audit events for every tool invocation, API call, and data access — and ship those events to your SIEM with the same rigor as endpoint telemetry.

  8. Include agents in red team and pen test scope. If your next engagement does not include prompt-injection testing against production agents and credential-theft simulation against machine identities, your test is modeling last decade's adversary. Our team has written about adjacent failure modes in the Axios npm supply-chain compromise and the Resecurity honeypot operation — both reinforce the same lesson: attackers go where defenders are not looking, and right now, nobody is looking at the agents.

Executive Takeaways

  • Treat AI agents as privileged users in policy, not just in practice. They belong in your joiner/mover/leaver process, your access reviews, and your insider threat program.
  • Ownership is the forcing function. Every agent identity needs a named accountable owner; unowned identities are decommissioned on a deadline.
  • Your telemetry advantage is determinism. Humans are noisy; agents are not. First-seen-anything alerting on machine identities is high-fidelity and cheap to operate.
  • Assume prompt injection will succeed. Architect so that a fully manipulated agent can still only reach what least privilege allows — and nothing high-impact executes without human approval.
  • Audit before the auditors do. Regulators are catching up fast; AI governance language is already appearing in financial, healthcare, and federal compliance frameworks. The organizations that build NHI governance now will not be retrofitting it under a consent decree later.

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.