Join our Newsletter — 33% off our NHI Course
Home› Guides› NHI Discovery Across Cloud, SaaS, CI/CD and On-Premises…
Guide Non-Human Identity (NHI)

NHI Discovery Across Cloud, SaaS, CI/CD and On-Premises Environments: A source-by-source plan to find every machine identity

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 28 October 2026 13 min read
On this page

You cannot rotate, scope or retire a machine identity you do not know exists, and most organisations hold their non-human identities in a dozen systems that never talk to each other. Service accounts live in Active Directory, roles and access keys in each cloud account, service principals in Entra ID, tokens in SaaS admin consoles, keys in CI/CD variables and secrets in code. This guide gives a practical discovery plan: what counts as an NHI for discovery purposes, the specific APIs, reports and commands that enumerate them on each major platform, how to find the credentials that no platform lists, and how to run discovery as a repeatable process rather than a one-off spreadsheet. It is for identity, cloud security and platform teams starting or rebuilding an NHI inventory.

Key takeaways

  • Discover identities and credentials separately. An identity (a role, service principal or service account) and its credentials (keys, secrets, certificates, tokens) have different owners, lifetimes and risks, and many platforms list one without the other.
  • Use the platform's own usage data. AWS credential reports and last accessed data, Entra service principal sign-in activity, Google Cloud service account insights and Kubernetes legacy token labels tell you not just what exists but whether it is used.
  • Some NHIs only appear in code and logs. API keys for SaaS providers, webhook secrets and tokens pasted into pipelines are found by secret scanning and by reading authentication logs, not by asking an identity system.
  • Discovery is continuous or it is wrong. New roles, apps and keys appear daily; schedule each source, record when it was last collected, and treat a source that stops reporting as an incident.
  • Every finding needs an owner field, even if empty. The output of discovery is a work queue for ownership and reconciliation, not a finished inventory.

What to discover: identities, credentials and trust

A useful discovery programme collects three linked object types. Missing any one of them leaves blind spots that attackers use.

ObjectExamplesWhy it matters
IdentityAWS IAM users and roles, Entra applications, service principals and managed identities, Google Cloud service accounts, Kubernetes ServiceAccounts, AD service accounts and gMSAs, SaaS integration users, GitHub Apps, AI agentsHolds the permissions; the unit you assign an owner to
CredentialAccess keys, client secrets, certificates, service account keys, personal access tokens, API keys, SSH keys, Kerberos keytabs, OAuth refresh tokensWhat leaks; has its own creation date, expiry and last-used date
Trust relationshipRole trust policies, federated credentials (OIDC), workload identity pools, OAuth consents, cross-account roles, impersonation rightsLets an identity be used without any stored credential, so it is easy to miss

Decide early whether personal tokens created by humans (GitHub personal access tokens, SaaS API tokens) count. They should: they are used by scripts and integrations, outlive their purpose and appear in breach after breach. The Non-Human Identity (NHI) Guide covers the full taxonomy.

Discovery sources by environment

Start with the authoritative API of each platform. The table lists the object to enumerate, a concrete way to do it, and the usage signal you can collect at the same time.

EnvironmentEnumerateHowUsage signal
AWSIAM users, access keys, rolesaws iam generate-credential-report then get-credential-report; ListRoles, ListAccessKeysaccess_key_1_last_used_date, last accessed data, IAM Access Analyzer unused access findings
Microsoft Entra IDApplications, service principals, managed identities, their secrets and certificatesMicrosoft Graph /applications and /servicePrincipals (credentials under passwordCredentials and keyCredentials)reports/servicePrincipalSignInActivities and reports/appCredentialSignInActivities (beta)
Google CloudService accounts and user-managed keysgcloud iam service-accounts list, gcloud iam service-accounts keys list, Cloud Asset Inventory across the organisationService account insights google.iam.serviceAccount.Insight (no authentication in 90 days)
KubernetesServiceAccounts, legacy token Secrets, RBAC bindingskubectl get serviceaccounts -A; Secrets of type kubernetes.io/service-account-tokenkubernetes.io/legacy-token-last-used label on legacy token Secrets
Active DirectoryService accounts, gMSAs and dMSAs, accounts with SPNsGet-ADServiceAccount; LDAP query for user objects with servicePrincipalName setlastLogonTimestamp (lags real logons), DC security events
GitHubGitHub Apps, OAuth apps, fine-grained PATs, deploy keysOrganisation settings, Personal access tokens, Active tokens; REST endpoints for org fine-grained PATs (callable only by GitHub Apps)Audit log; classic PATs cannot be listed by owners, only restricted
SaaS (Salesforce, Okta, Slack, others)Integration users, connected apps, API tokens, OAuth grantsEach admin API or console; SSPM or SaaS management toolingPlatform login history and token last-used fields where offered
CI/CDPipeline secrets, service connections, runner identities, OIDC trustPlatform APIs for repository, organisation and environment secrets; cloud trust policies naming CI issuersPipeline run logs; cloud logs of the federated role
Secrets managersStored secrets, their consumers and rotation statusVault, AWS Secrets Manager, Azure Key Vault, Google Secret Manager listingsSecret access logs

Two platform caveats matter for coverage. The AWS credential report includes only the first two access keys per user and excludes service-specific credentials, so use ListAccessKeys and ListServiceSpecificCredentials for completeness. GitHub organisation owners can view and revoke fine-grained PATs with access to organisation resources, but cannot view classic PATs in that interface, so the control for classic tokens is to restrict them. For the pipeline layer, see the CI/CD Pipeline Identity Security Guide.

Finding what no platform lists

API enumeration finds identities a platform manages. It does not find a third-party API key in a configuration file, a database password in a pipeline variable or a token embedded in a container image. Use four further methods:

MethodFindsStrengthLimitation
Platform API enumerationManaged identities and their registered credentialsAuthoritative, includes metadataBlind to unmanaged secrets
Secret scanning (repositories, images, wikis, tickets)Hard-coded keys and tokens for any providerFinds credentials no system listsNeeds validity checks and owner tracing; history matters
Log-derived discoveryIdentities that authenticate, including ones missing from the CMDBShows real use and sourceMisses idle identities; depends on log retention
Configuration and IaC analysisIdentities defined in Terraform, Helm, CloudFormation and pipeline filesLinks identities to repositories and teamsDrift between code and live state
Owner interviews and attestationPurpose, criticality, external integrationsOnly source of business contextSlow; inaccurate without data in front of the owner

Log-derived discovery is the bridge. Authentication logs show the identity name, the credential identifier and the source address: an access key ID in CloudTrail, an appId and key ID in Entra sign-in logs, a service account key ID in Google Cloud audit logs. An identifier that appears in logs but not in your inventory is a discovery finding in its own right. See the Git Secret Scanning Guide and the Secrets in Container Images Guide for the scanning side.

Discovering trust that has no stored credential

Workload identity federation removes secrets but adds trust relationships that are easy to overlook, because nothing shows up in a key list. Collect them explicitly:

  • AWS: IAM OIDC identity providers (aws iam list-open-id-connect-providers) and every role trust policy that names one, plus trust policies that allow other accounts or broad principals. Record the conditions on sub and aud; a trust policy that accepts any repository from a CI issuer is a finding.
  • Microsoft Entra ID: federated identity credentials on applications and user-assigned managed identities, with issuer and subject, alongside the secrets and certificates already collected.
  • Google Cloud: workload identity pools and providers, and IAM bindings that grant roles/iam.workloadIdentityUser or roles/iam.serviceAccountTokenCreator, which let one principal act as a service account.
  • SaaS and OAuth: consented OAuth applications and their scopes, which act with delegated or application permissions without any credential your teams hold.

Treat each trust relationship as a credential with an owner, a scope and a review date. When you later retire an identity, the trust relationship must go with it, or a pipeline in another organisation may still be able to assume it.

What to record for each finding

Collect enough to act. CIS Controls v8.1 Safeguard 5.5 (Establish and Maintain an Inventory of Service Accounts) names department owner, review date and purpose as the minimum, with review at least quarterly. Add the technical fields that let you rotate and retire:

  • Identity: platform, tenant or account, unique identifier (ARN, object ID, email, SID), display name, type, creation date, creator.
  • Credentials: each credential's identifier (key ID, thumbprint, token name, never the value), type, creation date, expiry, last used date.
  • Access: roles and permissions, privileged flag, trust relationships, resources reached.
  • Context: owning team, technical contact, purpose, application or service, environment (production, test), data classification.
  • Provenance: which discovery source reported it, and when each source last saw it.

Use the Service Account Inventory Template for column definitions and the Machine Identity Naming and Tagging Standard Template so new identities arrive with owner tags already set.

A phased discovery plan

  1. Weeks 1 to 2, scope and access. List every cloud account, subscription, project, tenant, cluster, domain, source control organisation, CI platform and top SaaS application. Create read-only collection identities for each (for example the AWS IAM Get* and List* actions plus iam:GenerateCredentialReport, Entra Reports Reader for sign-in activity). These collectors are NHIs too: inventory them first.
  2. Weeks 2 to 4, cloud and directory pass. Pull AWS, Entra, Google Cloud and Active Directory, including credentials and usage signals. These usually hold the largest and most privileged population.
  3. Weeks 4 to 6, code and pipeline pass. Run historical secret scanning across repositories, container registries and CI logs; enumerate pipeline secrets and OIDC trust relationships.
  4. Weeks 6 to 8, SaaS and Kubernetes pass. Enumerate connected apps, integration users and API tokens in the top SaaS platforms by data sensitivity, then cluster ServiceAccounts and legacy tokens.
  5. Weeks 8 to 10, reconcile and assign. Join the sources, remove duplicates and open ownership tasks. See the NHI Inventory Reconciliation guide.
  6. From then on, schedule. Daily for cloud and identity provider sources, weekly for SaaS, continuous for secret scanning, with alerts when a collector fails.

Discovery is read-only, so there is little to roll back. The test is coverage: before declaring a source complete, compare its count against the platform console and against identifiers seen in that platform's authentication logs over the last 30 days.

Choosing an approach: small and large estates

  • Small organisations (one cloud, one IdP, a few SaaS apps): scripts against the native reports above, written to a shared table, are enough. Spend the effort on secret scanning and on GitHub and SaaS tokens, which usually outnumber cloud identities.
  • Large or multi-cloud estates: use organisation-level collection (AWS Organizations with Access Analyzer at organisation scope, Google Cloud Asset Inventory at organisation level, Entra across all tenants) and a dedicated NHI or identity security platform to normalise sources. See the NHI Security Platform Buyer's Guide.
  • Build or buy: building is reasonable for the cloud layer, where APIs are documented and stable. Buying pays off when SaaS coverage, secret validity checking and owner workflows are needed across many platforms.
  • Agents and AI workloads: agent identities often run on service principals, API keys or OAuth grants created by individual teams. Include them from the start; the Shadow AI Discovery Guide covers the unsanctioned side.

Measuring discovery

Log and alert on the collectors themselves: last successful run per source, record counts per run, and sudden drops. Then track:

  • Source coverage: share of known accounts, tenants, clusters and SaaS apps with an active collector.
  • Log-to-inventory gap: number of credential identifiers seen authenticating in logs that are not in the inventory (target: falling to zero).
  • Ownership rate: share of discovered identities with a named owning team.
  • Freshness: share of records seen by at least one source in the last seven days.
  • Unmanaged secrets: live secrets found by scanning that have no matching managed credential.
  • Time to inventory: median hours from an identity's creation to its appearance in the inventory.

Framework mapping

FrameworkReferenceRelevance
NIST CSF 2.0ID.AM-02, PR.AA-01Inventories of software, services and systems; identities and credentials for services managed
NIST SP 800-53 Rev 5CM-8, AC-2, IA-5, PM-5Component inventory, account management, authenticator management, system inventory
CIS Controls v8.1Safeguards 5.1 and 5.5Inventory of accounts; inventory of service accounts with owner, purpose and review date
OWASP Non-Human Identities Top 10 2025NHI1 Improper Offboarding, NHI2 Secret Leakage, NHI7 Long-Lived SecretsRisks that cannot be addressed without discovery
MITRE ATT&CKT1078.004 Cloud Accounts, T1552.001 Credentials In FilesAttacker use of unknown cloud identities and unmanaged secrets

Common failure patterns

  • Discovering only one cloud. Teams inventory their primary platform and miss test tenants and acquired environments. The Microsoft Midnight Blizzard breach began with a legacy test tenant and a test OAuth application with elevated access to the corporate environment.
  • Listing identities but not credentials. A role inventory says nothing about the three access keys or two client secrets attached to an identity, which are what leak.
  • Ignoring source control applications. GitHub Apps and PATs are created by developers outside identity teams. The leaked GitHub App private keys research found 474 keys still authenticating, mostly from small, internal or abandoned Apps nobody tracked.
  • One-off spreadsheets. An inventory built once for an audit is stale within weeks and gives false assurance.
  • Collectors with excess rights. A discovery account with write access to every tenant becomes the most valuable NHI in the estate. Keep collectors read-only and monitored.
  • Storing secret values. Copying discovered secret values into the inventory creates a new leak; record identifiers and fingerprints only.

Lessons from incidents

The recurring lesson across NHI breaches is that the credential used was one nobody was looking at. In the Klue OAuth breach, a GitHub personal access token issued in 2022 for an abandoned pilot was still active and could change code in the integration service. A discovery process that included source control tokens, with a creation date and purpose for each, would have put that token in front of an owner years earlier.

Practitioner checklist

  • List every platform boundary (accounts, tenants, projects, clusters, domains, organisations, SaaS apps) before collecting anything.
  • Create read-only collectors per platform and inventory them as NHIs.
  • Collect identities, credentials and trust relationships as separate linked records.
  • Capture native usage signals (credential report, sign-in activity, service account insights, legacy token labels) at collection time.
  • Run historical secret scanning across code, images and CI logs and record identifiers, not values.
  • Compare authentication log identifiers with the inventory weekly and treat gaps as findings.
  • Schedule each source, record its last successful run and alert on failures.
  • Open an ownership task for every identity without a named owning team.
  • Restrict classic GitHub PATs and other credentials that cannot be enumerated.

Standards and references

Related NHI Mgmt Group resources: Non-Human Identity (NHI) Guide · NHI Inventory Reconciliation · NHI Dormancy Detection · NHI Ownership Guide · CI/CD Pipeline Identity Security Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 28 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.