Skip to content
TrustHappens
Cybersecurity & Identity

What Is Non-Human Identity Security? A Practical Guide

What non-human identities are, why service accounts, tokens and AI agents need their own security program, and a six-step plan to inventory, scope and rotate them.

TrustHappens Editorial TeamPublished 9 min read
Illustration for Cybersecurity & Identity
On this page

Every deployment pipeline, scheduled job, integration and AI agent in your company authenticates as something. That something is rarely a person. It is a cloud service account, a CI token, an OAuth app, an API key in a vault, a Kubernetes service account or, increasingly, an agent calling tools through an MCP server. Together these are non-human identities (NHIs), and in most environments they outnumber employees and hold more standing access than any individual engineer.

Most identity programs were built around people: joiners, movers and leavers, single sign-on, MFA, quarterly access reviews. Non-human identities slip through every one of those controls. They are created by developers in minutes, never attend an exit interview, cannot complete an MFA prompt and often authenticate with a static secret that has been copied into three places.

This guide explains what non-human identity security covers, how the risks map to the OWASP Non-Human Identities Top 10, and a six-step program you can run without buying anything first.

What counts as a non-human identity

A non-human identity is any credentialed principal that a machine, workload or automated process uses to authenticate and be authorised. The useful test is simple: if it can call an API and no human types a password or touches a security key at the moment of the call, it is an NHI.

Common examples:

  • Cloud service accounts and roles. AWS IAM roles and users with access keys, Google Cloud service accounts, Azure managed identities and app registrations.
  • CI/CD credentials. Deploy keys, personal access tokens stored as pipeline secrets, cloud keys used by build jobs, registry push tokens.
  • OAuth apps and GitHub Apps. Third-party integrations granted scopes on your SaaS tenant, source control or chat workspace.
  • API keys and webhooks. Payment, email and model-provider keys; signing secrets for inbound webhooks.
  • Kubernetes service accounts. The identity every pod runs as, often bound to cloud permissions through workload identity.
  • Certificates and SSH keys. mTLS client certificates, machine certificates, SSH keys used by automation.
  • AI agents and MCP servers. An agent that reads tickets and opens pull requests is acting with some identity, usually a token someone created for it. An MCP server that wraps your database or SaaS API holds credentials of its own.

Two distinctions matter. First, an identity is not the same as its credential: one service account may have five keys, and one key may be shared by several workloads. Second, many NHIs are "borrowed": a developer's personal access token used by a cron job is technically a human identity doing non-human work, the mirror image of the risk OWASP lists as NHI10, Human Use of NHI.

Why non-human identities need their own program

Human identity controls rely on assumptions that do not hold for machines.

Human identity controlWhy it fails for NHIs
HR-driven offboardingNo HR record exists; the creator may leave while the identity keeps working
MFA at loginNo one is present to answer a prompt; the secret is the only factor
SSO session limitsStatic keys and long-lived tokens never expire unless someone sets an expiry
Manager-led access reviewNobody is listed as the manager; reviewers cannot tell what the identity does
Behavioural anomaly baselinesAutomation is bursty and changes with every deploy

The result is a population of credentials that are powerful, persistent and poorly attributed. Zero trust guidance points the same way: NIST SP 800-207 says authentication and authorisation of every subject should be discrete functions performed before a session to a resource is established, with no implicit trust from network location. A workload inside your VPC is a subject like any other.

The risks, mapped to the OWASP NHI Top 10

The OWASP Non-Human Identities Top 10 (2025) is the most useful shared vocabulary for this problem. Its ten categories, with what each looks like in practice:

  1. NHI1 Improper Offboarding. A contractor's integration token keeps working after the contract ends; a decommissioned service's role still trusts its old pipeline.
  2. NHI2 Secret Leakage. A cloud key committed to git history, printed in a CI log or pasted into a ticket.
  3. NHI3 Vulnerable Third-Party NHI. An OAuth app or GitHub App with broad scopes whose vendor is compromised.
  4. NHI4 Insecure Authentication. Integrations using deprecated or weak flows such as long-lived basic-auth credentials instead of federated tokens.
  5. NHI5 Overprivileged NHI. A deploy role with administrator rights because "it was easier".
  6. NHI6 Insecure Cloud Deployment Configurations. A CI trust policy that accepts tokens from any branch or any repository.
  7. NHI7 Long-Lived Secrets. Keys with no expiry that have not rotated since they were created.
  8. NHI8 Environment Isolation. The same service account used in staging and production.
  9. NHI9 NHI Reuse. One API key shared by four services, so you cannot rotate it or attribute its use.
  10. NHI10 Human Use of NHI. Engineers logging in interactively with a service account's credentials.

A six-step NHI security program

The steps below are ordered so that each one makes the next cheaper. You can run them for one cloud account or business unit first, then expand.

Step 1: Build the inventory

You cannot rotate, scope or review what you have not found. Pull identities from every system that issues them:

  • Cloud IAM: roles, users with access keys, service accounts, managed identities, app registrations, and each one's keys.
  • Identity provider: API tokens, service principals and OAuth apps granted consent.
  • Source control: GitHub Apps, OAuth apps, deploy keys, fine-grained and classic personal access tokens used by automation.
  • CI/CD: secrets stored at organisation, repository and environment level.
  • Secret managers such as Vault or a cloud secrets service: what is stored, and which workloads read it.
  • Kubernetes: service accounts and their cloud bindings.
  • AI tooling: registered agents, the MCP servers they connect to and the credentials those servers hold.

For each identity, record at least: where it lives, credential type, creation date, last-used date, last rotation date, permissions and the workloads that use it. Last-used data is the single most valuable field, because it tells you what you can safely disable.

Step 2: Assign an owner to every identity

Ownership is the control that makes all others work. Assign each identity to a team, not a person, and record the owning service or system. Where you cannot find an owner, use a scream test with a safety net: label the identity, announce a date, disable (do not delete) it and keep the ability to re-enable quickly.

Make ownership a creation-time requirement. Infrastructure-as-code modules for service accounts should require owner and purpose tags, and policy checks should reject resources without them.

Step 3: Replace long-lived secrets with federated, short-lived credentials

The best secret is one that does not exist. Workload identity federation lets a workload present a token from an identity provider it already has, such as the CI platform's OIDC issuer or a Kubernetes cluster, and exchange it for short-lived cloud credentials. Google Cloud, AWS and Microsoft Entra all document this pattern, and GitHub Actions supports it with OIDC.

The trust policy is where the security lives. This AWS role can only be assumed by workflows on the main branch of one repository:

trust-policy.json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
          "token.actions.githubusercontent.com:sub": "repo:example-org/payments-api:ref:refs/heads/main"
        }
      }
    }
  ]
}

The workflow then requests a token instead of reading a stored key:

permissions:
  id-token: write
  contents: read

steps:
  - uses: aws-actions/configure-aws-credentials@v4
    with:
      role-to-assume: arn:aws:iam::111122223333:role/payments-api-deploy
      aws-region: eu-west-1

Where federation is not available, for example with a SaaS API that only issues static keys, store the key in a secret manager, give it an expiry, and make the workload fetch it at runtime rather than baking it into images or environment files.

Step 4: Right-size permissions

Start from what the identity actually used, not what it was granted. Cloud providers expose last-accessed information and access analysers for this purpose; AWS's IAM best practices recommend using last-accessed data to refine permissions and to remove unused users, roles and credentials. A narrowed policy for a reporting job might look like this:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:GetObject"],
      "Resource": "arn:aws:s3:::example-reports/daily/*"
    },
    {
      "Effect": "Allow",
      "Action": ["s3:ListBucket"],
      "Resource": "arn:aws:s3:::example-reports",
      "Condition": { "StringLike": { "s3:prefix": ["daily/*"] } }
    }
  ]
}

Separate identities by environment (NHI8) and by workload (NHI9). Shared identities are not only over-privileged; they make rotation risky because nobody knows what will break.

Step 5: Rotate, detect leaks and practise revocation

For every remaining static secret, define a rotation interval appropriate to its risk and automate it. The OWASP Secrets Management Cheat Sheet recommends automated rotation with a frequency that reflects the credential's privilege and exposure, and rotation triggered immediately on suspected compromise. Practical rules:

  • Where the service allows it, use dual-credential rotation: introduce the new credential, migrate consumers during an overlap, then revoke the old one.
  • Scan git history, not just new commits, for secrets; leaked keys in old commits remain valid until revoked.
  • Scan CI logs, container images and ticket systems, which are common leak points.
  • Write a leaked-secret runbook: revoke first, then rotate, then investigate use since the leak, then fix the root cause.

Step 6: Review access and offboard continuously

Access reviews for NHIs work when they show the reviewer what matters: what the identity can do, what it actually did recently, who owns it and when its credential last rotated. Ask owners three questions per identity: is it still needed, are its permissions still right, is its credential short-lived or rotating?

Tie offboarding to system events rather than to people leaving. Decommissioning a service, ending a vendor contract, archiving a repository or deleting a cluster should each trigger disablement of the identities attached to it.

If you would rather not stitch this inventory together from scripts, TrustIvan provides a non-human identity inventory of keys, tokens and AI agents with owners, access reviews and effective access, using connectors that range from cloud IAM and Okta to GitHub Apps and Vault.

Where AI agents and MCP servers fit

AI agents are non-human identities with a twist: their behaviour is steered by natural-language input, including input from untrusted sources. Everything above applies, plus three additions:

  • Give each agent its own identity. Do not let agents run on a developer's personal token or a shared integration key.
  • Scope tools, not just credentials. An agent's real permission set is the union of the tools it can call and the credentials those tools use. Record both.
  • Treat MCP servers as privileged software. The MCP authorization specification requires servers to validate that access tokens were issued specifically for them, and its security best practices explicitly forbid token passthrough. Inventory which MCP servers exist, who runs them and what they hold.

The companion article on securing AI agents in enterprise environments goes deeper on runtime controls.

Common pitfalls

  • Inventory as a one-off project. Identities are created daily. Schedule collection and alert on new, ownerless identities.
  • Rotating without ownership. Rotating an unowned shared key breaks production and teaches teams to avoid rotation.
  • Counting secret managers as the solution. A vault stores secrets safely; it does not tell you whether a secret should exist or what it can do.
  • Ignoring third-party grants. OAuth consents in your SaaS tenants are identities you did not create but are still responsible for.
  • Deleting before disabling. Disable first and wait; deletion removes the ability to recover quickly and sometimes the audit trail.

Measuring progress

Pick a few measures you can compute from your own inventory and track their trend rather than chasing an external benchmark:

  • Share of identities with a named owning team.
  • Share of workloads using federated or short-lived credentials instead of static keys.
  • Number of static secrets older than your rotation policy.
  • Number of identities unused for 90 days that are still enabled.
  • Mean time from a leaked-secret alert to revocation.

The identity security assessment checklist turns these steps into a tracker you can assign and evidence.

Frequently asked questions

Is a service account the same as a non-human identity?

A service account is one kind of non-human identity. The category also includes API keys, CI tokens, OAuth and GitHub Apps, certificates, Kubernetes service accounts and AI agents.

Should we eliminate every static secret?

Aim to remove the ones you can replace with workload identity federation or short-lived tokens. For services that only issue static keys, store them in a secret manager, give them an owner and an expiry, and automate rotation.

Who should own non-human identity security?

Security usually sets policy and runs the inventory, platform teams provide the paved road for federation and secret storage, and each service team owns the identities its workloads use.

Where should we start if we have no inventory at all?

Start with production cloud accounts and CI/CD, collect last-used data, and disable identities that are clearly unused after notifying likely owners. That reduces risk quickly and builds the habit of ownership.

References

  1. OWASP Non-Human Identities Top 10 (2025)
  2. OWASP Secrets Management Cheat Sheet
  3. GitHub Docs: About security hardening with OpenID Connect
  4. Google Cloud: Workload Identity Federation
  5. AWS IAM: Security best practices
  6. NIST SP 800-207: Zero Trust Architecture

Share this guide

Stay Ahead of What Matters.

Practical guides on cybersecurity & identity and more, delivered to your inbox.