PlaybookLast checked 16 October 2026 with AI-assisted research. Editor: Akshay Dubey.MethodologyCorrections log

NHI detection and response means collecting the logs that show service accounts, OAuth apps and API keys at work, joining each event to the identity's owner and purpose, alerting on known misuse patterns, and containing incidents by revoking the specific credential involved.

Security operations teams are built around people: user sign-ins, endpoints, mailboxes. Non-human identities often fall between those views. A service account has no laptop and no MFA prompt, and an OAuth token used from an attacker's server looks like a normal API call. This playbook sets out how to bring NHIs into detection and response: which logs to collect, what context to add, which signals to watch, and how to contain an NHI incident without breaking production.

Why NHIs need their own detection logic

  • No second factor. The joint advisory AA24-057A, SVR Cyber Actors Adapt Tactics for Initial Cloud Access (published by CISA with the UK NCSC and partners) reports password spraying against service accounts and notes that, with no human user behind them, they cannot easily be protected with MFA.
  • Tokens skip the sign-in. MITRE ATT&CK T1550.001 describes stolen application access tokens used in place of login credentials, often without a second factor. T1528 covers how those tokens are stolen.
  • Predictable behaviour. Many workload identities call the same APIs from the same places on a schedule. As our monitoring and detection page explains, that makes deviations easier to see than for people, if the logs and the baseline exist.

The identity and the credential need separate treatment here too. Under this site's taxonomy, the alert concerns an identity (a service account, a service principal, an integration), while the evidence and the containment step usually concern a credential (an access key, a token, a client secret). An incident record should name both.

Step 1: Collect the logs that show NHI activity

List the sources and check that each one reaches your SIEM or data lake with enough retention for an investigation:

  • cloud control-plane logs, such as AWS CloudTrail, including role assumption and key creation events;
  • identity provider sign-in and audit logs for service principals and workload identities, not only for users;
  • SaaS audit logs for connected apps and API access (consent events, token grants, data exports);
  • code hosting audit logs for token creation, deploy keys and app installations;
  • secrets manager audit logs, which show which identity read which secret;
  • Kubernetes API server audit logs for service account use.

Retention matters. AWS CloudTrail event history, for example, holds management events for the last 90 days per Region (AWS, Viewing CloudTrail events with the AWS CLI). The Codecov alterations ran from 31 January to 1 April 2021 according to Codecov, longer than many default windows. Microsoft's consent investigation playbook warns that if auditing was not on before an attack, the data will not be there.

Step 2: Join identity context to every event

An alert that says an access key was used from a new IP address is hard to triage without knowing what the key is for. From your NHI inventory, attach to each identity: its owner, its purpose, the systems it is expected to call, where it normally runs, and whether its credentials are held by a third party. The discovery methodology and ownership pages describe how to build that inventory. In our reading, an alert on an identity with no recorded owner is one that nobody can confirm or dismiss quickly, so ownership gaps found here should go back to the inventory.

Step 3: Write detections for NHI behaviour

Start with a small set of signals tied to known techniques. The table lists examples; each needs tuning to your environment.

SignalWhy it mattersReference
Application token used to call APIs with no matching interactive sign-in, or with unusual scopesPossible stolen token in useMITRE T1550.001, analytic AN0528
Temporary credential or federation requests inconsistent with the account's normal activityPossible use of a stolen token to obtain further credentialsMITRE T1550.001, analytic AN0526
New consent grant to an app, especially tenant-wide or with mail or file scopesPossible illicit consentMITRE T1528; Microsoft consent playbook
A service identity creating new keys or secrets for itself or another identityPossible persistenceOur interpretation
Use of a dormant service account, or sign-in to a canary service accountAccounts with no legitimate use should not be activeCISA AA24-057A
Session token reuse from a new client or networkPossible session hijack, as in the Okta support caseMITRE T1550.001, analytic AN0527

CISA's advisory recommends canary service accounts: accounts that look valid but are never used, so that any activity on them is a strong signal. The cost is low and the false-positive rate, in our reading, should be close to nil if the account is truly unused.

Step 4: Triage with four questions

  1. Which identity and which credential? Name both, for example the IAM user and the access key ID.
  2. Who owns it, and is this activity expected? Ask the owner first; it is often a deployment change.
  3. What can it reach? Pull its current permissions, not the ones in the design document.
  4. Where else is the credential stored or used? This decides the blast radius of revocation and of the leak.

The script below answers part of the first and fourth questions for an AWS access key: which Regions, services and API calls it was used for, and from which source addresses.

#!/usr/bin/env bash
# Show where and how one AWS access key was used, from CloudTrail event history.
# Read-only. Usage: ./key_activity.sh AKIAEXAMPLEKEYID 2026-10-01T00:00:00Z
# Needs: AWS CLI v2 with cloudtrail:LookupEvents and ec2:DescribeRegions, jq.
set -euo pipefail
key="${1:?access key id}"
since="${2:?start time, ISO 8601 UTC}"
for region in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do
  aws cloudtrail lookup-events --region "$region" \
    --lookup-attributes "AttributeKey=AccessKeyId,AttributeValue=$key" \
    --start-time "$since" --output json |
  jq -r --arg r "$region" '.Events[].CloudTrailEvent | fromjson |
    [$r, .eventTime, .eventSource, .eventName, (.sourceIPAddress // "-"), (.userAgent // "-")] | @tsv'
done

Limits of this script. CloudTrail event history covers management events only, for the last 90 days, and each lookup is per Region. Data events, such as S3 object reads, are not included; for those you need a trail delivering to storage, or CloudTrail Lake. AWS limits lookups to two requests per second per account per Region; the AWS CLI pages through results and retries throttled calls, but a busy key can still take a long time. We have checked the syntax with bash -n and the jq filter on sample data, not against a live account.

Step 5: Contain by credential type

Containment usually means revoking or disabling the credential, and sometimes the identity. Plan the step in advance for each credential type, because the commands differ and some revocations do not end existing sessions.

  • AWS access key. Deactivate it (aws iam update-access-key --status Inactive) before deleting it, so you can restore it if a production system breaks. Check for keys or roles the attacker may have created.
  • Microsoft Entra application. Microsoft's playbook advises disabling a malicious application rather than only deleting it, because a deleted app can return through new consent. Revoke its delegated grants and application role assignments as described in Microsoft's permissions guide.
  • Third-party OAuth integration. Revoke the integration on your side and ask the vendor to revoke all tokens. In the Drift case, Salesloft and Salesforce revoked all active access and refresh tokens for the Drift application.
  • Personal access token or API key. Revoke at the issuer, then search code, CI variables and secrets stores for other copies.

CISA's advisory also recommends keeping session lifetimes as short as practical, which limits how long a stolen token remains useful after containment of the credential that issued it.

Step 6: Rotate what the identity could read

An NHI compromise often exposes other credentials. In the Codecov case, anything in the CI environment was sent out, so affected customers had to rotate every secret that had passed through those jobs. In the Okta support case, according to Okta, a service account was used to read customer files, some of which held session tokens. List the secrets, tokens and data the compromised identity could read, and rotate the credentials among them. Then check for persistence: new keys, new grants, new federation trusts, or new app registrations created during the window.

Step 7: Feed lessons back into governance

Each NHI incident should change something upstream: a scope narrowed, a static key replaced with a short-lived credential, an owner assigned, a log source added. Track two measures over time: how long it takes to name the owner of an alerting identity, and how long it takes to revoke its credential. For incidents involving AI agents, see the agent incident response guide. The NIST SP 800-207 zero trust model, which grants no implicit trust based on network location, supports the same direction: verify each request by identity and context, including requests from workloads.

Mapping to the OWASP NHI Top 10

This is our mapping, not a statement by OWASP.

Risk (OWASP NHI Top 10 (2025))Where security operations meets itSteps above
NHI2 Secret LeakageLeaked credential detected in use3, 5, 6
NHI3 Vulnerable Third-Party NHIVendor-held tokens used after a vendor breach3, 5
NHI4 Insecure AuthenticationPassword-only service accounts targeted by spraying3
NHI1 Improper OffboardingDormant identities becoming active3, 7
NHI10 Human Use of NHIService credentials used from a person's device or browser3, 4

Frequently asked questions

How is detection for non-human identities different from detection for users?

NHIs usually have no MFA and no device, and stolen tokens can be used without a sign-in event. On the other hand, many workloads behave predictably, so deviations from a baseline are easier to spot when the logs carry identity context such as owner and expected systems.

What is the first containment step when an API key is compromised?

Deactivate or revoke the key at its issuer, then check the issuer's logs for what it did and search for other copies. Where possible, deactivate before deleting so a broken production system can be restored while a replacement is issued.

Which logs matter for NHI incidents?

Cloud control-plane logs, identity provider logs for service principals, SaaS audit logs for connected apps, code hosting audit logs and secrets manager audit logs. Check retention: AWS CloudTrail event history, for example, covers management events for 90 days.

Sources

Where a primary URL is not shown, we have not confirmed the figure against the publisher’s own document and say so on the page rather than linking a secondary source that paraphrases it. Paywalled standards (ISO/IEC, AICPA) are cited by clause and not linked. Corrections welcome: report an error.

Disclosure. This reference is free. No vendor pays for coverage, placement, or favourable treatment. HumanAudit Inc., which publishes this site, sells ISO/IEC 42001 documentation and plans NHI governance documentation packs, including an RFP kit that does not name, rank or recommend any vendor; it builds and sells no NHI scanner and no NHI discovery, monitoring or security tool (see About). Links to its offers appear in the header, in the site footer and in one marked box on guide pages; company profiles carry none. See our methodology, sourcing standards and corrections policy.

From the publisher

HumanAudit, which publishes this site, is preparing the NHI Governance pack: an NHI policy, ownership register, lifecycle procedures and one control set mapped, as our interpretation, to PCI DSS v4.0.1, ISO/IEC 27001:2022, NIS2 and DORA. Planned for March 2027; not yet on sale, and no price has been published.

Monthly change log

Know when the NHI landscape changes.

One email a month from this reference: new deals, standards status changes and corrections. No sponsored content. Unsubscribe from any email.

We first email you a link to confirm. Privacy policy.