Non-Human Identities: Managing Machine Credentials at Scale

· David Park · 11 min read

Every API call between microservices, every CI/CD pipeline run, every monitoring agent scrape, and every edge function invocation requires an identity. These non-human identities (NHIs) — service accounts, API keys, machine certificates, and workload tokens — now outnumber human users by ratios of 45:1 in typical enterprise environments and 100:1 in cloud-native organizations. Yet most identity and access management programs focus almost exclusively on human users, leaving machine credentials governed by ad hoc processes that create significant security blind spots. Understanding how to manage NHIs at scale is essential for any infrastructure team operating distributed architectures where hundreds of services communicate autonomously.

What Are Non-Human Identities and Why Do They Matter More Than Human Identities?

Non-human identities represent any entity that authenticates to a system without direct human interaction at the point of authentication. This includes service accounts used by applications to access databases and APIs, API tokens issued to third-party integrations, machine certificates used for mutual TLS between services, CI/CD pipeline credentials that deploy code and manage infrastructure, and monitoring agents that collect metrics from production systems.

The scale disparity is staggering. A company with 500 engineers might run 200 microservices, each with 3-5 service accounts for different downstream dependencies, 50 CI/CD pipelines with deployment credentials, 100+ monitoring and observability agents, and dozens of third-party SaaS integrations — easily totaling 25,000+ non-human identities. Each one represents an authentication credential that could be compromised, rotated incorrectly, or forgotten.

NHIs matter more than human identities from a security perspective for three reasons. First, they typically have broader access than individual humans because services need to operate across multiple systems. Second, they operate 24/7 without session timeouts or multi-factor authentication, meaning a compromised NHI provides persistent access. Third, they are rarely monitored with the same rigor as human accounts — no one notices when a service account logs in at 3 AM because that is normal behavior.

What Types of Machine Credentials Exist and When Should Each Be Used?

Machine credential types vary in security properties, lifecycle characteristics, and appropriate use cases. Choosing the right credential type for each machine-to-machine interaction is the foundation of NHI management.

Performance Comparison: Edge vs Origin Processing
Metric Edge Processing Origin Processing Improvement
Latency (p50)8–15 ms120–300 ms15–20x faster
Cache Hit Ratio85–95%N/AReduces origin load
TLS Handshake1–5 ms (nearby PoP)50–150 ms10–30x faster
Bandwidth Cost$0.01–0.04/GB$0.05–0.12/GB3–5x cheaper
Availability99.99% (multi-PoP)99.9% (single DC)10x fewer outages

API keys are static string tokens that authenticate API requests. They are simple to implement but provide no built-in expiration, rotation, or scope limitation. API keys are appropriate for low-risk, read-only integrations where the blast radius of compromise is limited. They should never be used for write access to production data or infrastructure management. When used, API keys should be scoped to specific IP addresses or service identities and stored in secrets management systems rather than application configuration files.

OAuth 2.0 client credentials use the client credentials grant flow where a service authenticates with a client ID and secret to obtain a time-limited access token. The OAuth token exchange model provides significant advantages: tokens expire automatically, scopes restrict access to specific resources, and token revocation is immediate. Client credentials are ideal for service-to-service API calls, particularly when the API gateway enforces token validation at the edge.

mTLS certificates provide the strongest machine identity guarantee through cryptographic proof based on X.509 certificates. Both client and server present certificates during the TLS handshake, establishing mutual authentication. mTLS is ideal for service mesh communication, database connections, and any interaction requiring cryptographic non-repudiation. The operational overhead is higher than token-based approaches but justified for high-security paths.

Workload identity tokens (SPIFFE SVIDs, Kubernetes service account tokens, cloud IAM temporary credentials) represent the modern approach where the platform itself attests workload identity without pre-shared secrets. These ephemeral credentials are issued automatically, rotated frequently, and tied to the workload's runtime environment rather than a static configuration.

Machine Credential Types Comparison Machine Credential Type Spectrum Simple / Less Secure Complex / Most Secure API Keys Static string tokens No built-in expiry Manual rotation No scope control Low-risk read APIs Lifetime: Months-Years Risk: HIGH OAuth Client Client ID + secret Token auto-expiry Scoped access Revocable tokens Service-to-service Token: Minutes-Hours Risk: MEDIUM mTLS Certs X.509 certificates Mutual authentication Crypto non-repudiation Certificate pinning High-security paths Lifetime: Days-Weeks Risk: LOW Workload ID Platform-attested Auto-issued + rotated Ephemeral by design No pre-shared secrets Cloud-native infra Lifetime: Minutes Risk: LOWEST

How Does SPIFFE/SPIRE Solve the Workload Identity Bootstrap Problem?

The fundamental challenge in machine identity is bootstrapping: how does a new workload prove its identity when it has no pre-existing credentials? Traditional approaches require pre-provisioning secrets into configuration management systems, container images, or instance metadata — each of which creates a static credential that must be managed, rotated, and protected.

SPIFFE (Secure Production Identity Framework for Everyone) solves this through platform-level attestation. When a workload starts, the SPIRE agent on its host verifies the workload's identity through properties of its execution environment — the Kubernetes namespace and service account, the AWS instance identity document, the process UID and binary hash, or a combination of these attestation methods. No pre-shared secret is required because the platform itself provides the proof of identity.

Once attested, SPIRE issues the workload a SPIFFE Verifiable Identity Document (SVID) — an X.509 certificate or JWT token with a URI-formatted identity like spiffe://production.example.com/payment-service/v2. This SVID is short-lived (typically 1-24 hours), automatically rotated before expiration, and can be used for mTLS connections to other SPIFFE-identified workloads without any application-level credential management.

The trust model uses federation to span organizational boundaries. Two SPIRE deployments can establish trust by exchanging trust bundles, enabling workloads in different organizations or cloud providers to authenticate each other. This is particularly valuable for origin server protection in CDN architectures where edge nodes from different providers need to authenticate against origin servers.

What Does a Secrets Management Architecture Look Like at Scale?

Even with workload identity solving the bootstrap problem, many applications still require managed secrets — database passwords, encryption keys, third-party API credentials, and TLS certificates that cannot be replaced with workload identity tokens. A centralized secrets management architecture provides secure storage, access control, rotation automation, and audit logging for these credentials.

HashiCorp Vault is the most widely deployed open-source secrets manager. Vault stores secrets in an encrypted backend (typically Consul, DynamoDB, or integrated storage), provides dynamic secret generation for databases and cloud platforms, handles automatic certificate issuance via its PKI secrets engine, and offers transit encryption as a service. Vault's auth methods integrate with Kubernetes, AWS IAM, GCP, Azure, LDAP, and OIDC providers, allowing workloads to authenticate using their platform identity rather than a separate Vault credential.

Cloud-native KMS solutions (AWS Secrets Manager, GCP Secret Manager, Azure Key Vault) offer managed secrets storage integrated with their respective IAM systems. These services handle encryption, rotation for supported credential types (like RDS passwords), and audit logging through cloud-native monitoring. The trade-off is vendor lock-in — secrets stored in AWS Secrets Manager are tightly coupled to AWS IAM policies and cannot easily migrate to other providers.

The architecture pattern that balances portability and operational simplicity uses a hybrid approach: a central Vault cluster manages cross-platform secrets and PKI, while cloud-native KMS handles cloud-specific credentials within each provider. The security layer enforces least-privilege access through policy-as-code, ensuring each workload can only access the specific secrets it requires.

Secrets Management Architecture Secrets Management Architecture Central Vault Cluster Encrypted storage + PKI + Transit AWS Secrets Manager RDS, ElastiCache, Redshift IAM role-based access GCP Secret Manager Cloud SQL, Pub/Sub Workload Identity access Azure Key Vault Cosmos DB, Service Bus Managed Identity access AWS Workloads EKS, ECS, Lambda GCP Workloads GKE, Cloud Run, Functions Azure Workloads AKS, App Service, Functions SPIFFE/SPIRE Trust Domain Cross-cloud workload attestation + automatic SVID rotation Federated trust for multi-cloud mTLS authentication

How Should Credential Lifecycle Management Be Automated?

Manual credential rotation is the primary failure mode in NHI management. When rotation depends on human action, credentials inevitably age beyond safe lifetimes. Automation must cover the complete lifecycle: provisioning, distribution, rotation, monitoring, and revocation.

Provisioning automation creates credentials through infrastructure-as-code workflows. When a new service is deployed via Terraform or similar tools, the deployment pipeline automatically provisions the required credentials, registers them in the secrets manager, and configures access policies. No human manually creates service accounts or generates API keys. The provisioning process records the credential's owner (the deploying team), purpose (the service it supports), and authorized consumers in a metadata registry.

Rotation automation uses scheduled jobs to rotate credentials before expiration. The rotation process follows a dual-write pattern: generate a new credential, update all consumers to use the new credential, verify the new credential works, then revoke the old credential. This overlap period prevents downtime during rotation. For database passwords, Vault's dynamic secrets engine generates unique, time-limited credentials for each requesting workload, eliminating the need for traditional rotation entirely.

Revocation automation triggers when a service is decommissioned, a credential is suspected compromised, or a team member with access to shared credentials departs. The revocation pipeline disables the credential immediately, rotates any downstream credentials that might have been exposed, generates an audit report of all access during the credential's lifetime, and creates alerts for any post-revocation access attempts that might indicate credential caching or duplication.

Monitoring and compliance continuously audits the NHI inventory against policy. Automated checks flag: credentials older than their rotation policy allows, service accounts with unused permissions, credentials not associated with an active service or team owner, and access patterns that deviate from established baselines. The monitoring system feeds into the same compliance framework used for human identity governance.

What Does Zero Trust Mean for Machine-to-Machine Communication?

Applying zero trust principles to machine-to-machine communication means abandoning the assumption that services within the same network perimeter are trustworthy. Every service-to-service request must be authenticated, authorized, and encrypted regardless of network location.

Authentication at the transport layer uses mTLS with short-lived certificates issued by SPIFFE/SPIRE or a managed PKI. At the application layer, JWT tokens carry service identity and authorization claims. The combination ensures both transport-level identity (which service is connecting) and application-level authorization (what the service is allowed to do).

Authorization enforces least-privilege access through policy engines like Open Policy Agent (OPA) or cloud-native IAM policies. Each service declares its dependencies explicitly, and the authorization layer permits only those declared communication paths. A payment service can call the ledger API but not the user profile API, even though both are on the same network. Policy changes propagate through the same canary deployment process as code changes, with gradual rollout and automated rollback on policy violation spikes.

Encryption uses TLS 1.3 for all service-to-service traffic, including within private networks. Service meshes like Istio and Linkerd automate mTLS enforcement without requiring application code changes, using sidecar proxies that handle certificate management and connection encryption transparently. The origin protection model extends this to CDN-to-origin connections, ensuring that even traffic within the CDN provider's network is encrypted and authenticated.

Managing non-human identities at scale requires treating machine credentials with the same governance rigor applied to human accounts — and in many cases more, given the volume disparity and the always-on nature of machine access. Organizations that invest in workload identity platforms, automated lifecycle management, and zero trust architecture for machine communication dramatically reduce their attack surface while enabling the service-to-service connectivity that modern distributed architectures demand. The alternative — static API keys stored in environment variables and rotated when someone remembers — is a breach waiting to happen.

Explore Other Topics

External References

References & Standards: Cloudflare documentation · OWASP CDN Security