By NHI Mgmt Group Editorial TeamPublished 2023-04-18Domain: Best PracticesSource: 1Kosmos

TL;DR: JWT authentication improves scalability by making each request self-contained, but it also shifts risk onto token storage, signature validation, expiration discipline, and revocation, according to 1Kosmos. The governance issue is not JWT itself, but the assumption that stateless tokens remain trustworthy without lifecycle controls.


At a glance

What this is: JWT authentication is a stateless access model that reduces server-side session handling while placing more trust in token integrity, storage, and expiry enforcement.

Why it matters: It matters to IAM practitioners because JWT design decisions affect application access control, secrets handling, revocation, and the boundary between authentication and authorisation across human, NHI, and workload identity flows.

👉 Read 1Kosmos's guidance on JWT authentication and token security


Context

JWT authentication is a stateless way to verify identity between a client and server, which means the token itself carries the claims the application needs to make an access decision. That design is efficient for APIs and microservices, but it also means security depends heavily on how tokens are signed, stored, and invalidated.

For identity programmes, the real issue is governance rather than transport. A JWT can behave like a portable access artefact across sessions and services, so teams have to treat it as part of the access lifecycle, not as a one-time login convenience. That makes token validation, expiration, and revocation part of the control plane, not optional hygiene.


Key questions

Q: How should security teams implement JWT authentication safely in web applications?

A: Security teams should validate every token on every request, keep claims minimal, store tokens in the least exposed client context available, and enforce short expiry with a clear renewal path. They also need a revocation mechanism for compromise, offboarding, and role changes. Without those controls, JWTs become portable bearer credentials rather than controlled access artefacts.

Q: Why do JWTs create governance risk even when signatures are valid?

A: A valid signature only proves the token was issued and not altered. It does not prove the token is still appropriate, unexposed, or within policy. Governance risk appears when a stolen or stale token remains usable after access should have ended, which is why expiry, revocation, and lifecycle control matter as much as cryptography.

Q: What do security teams get wrong about token expiration in JWT authentication?

A: Teams often assume that short expiration alone solves token risk. In reality, expiry only limits the time window, and a compromised token is still usable until it expires unless revocation exists. Effective control needs both short-lived tokens and an explicit way to invalidate them when access changes or compromise is suspected.

Q: How do JWTs compare with traditional session-based authentication for access control?

A: JWTs reduce server-side session state and work well for distributed APIs, while session-based authentication gives the server more direct control over ongoing access. The trade-off is that JWTs shift more responsibility to token handling, claim validation, and invalidation. Choose JWTs when scale matters and you can support the lifecycle controls they require.


Technical breakdown

JWT structure and signature validation

A JWT has three parts: header, payload, and signature. The header identifies the token type and signing algorithm, the payload carries claims such as user ID or token metadata, and the signature proves the token was issued and not altered. In practice, the server must verify the signature and also validate the claims it trusts, such as issuer, audience, and expiration. If validation is weak, a token can become a reusable access bearer rather than an authenticated assertion.

Practical implication: require strict signature and claim validation on every request path that accepts JWTs.

Token storage and replay exposure

JWTs are often stored in cookies or local storage and then replayed on subsequent requests. That makes the storage location a security boundary, because any actor that can steal the token can reuse it until the token expires or is revoked. Long-lived tokens increase exposure, and sensitive claims inside the payload increase the impact of theft. The problem is not only interception in transit, but also browser, endpoint, and application-layer leakage.

Practical implication: minimize token lifetime and treat client-side storage as an exposure point, not a neutral implementation detail.

Revocation and lifecycle control for stateless sessions

Stateless authentication reduces server-side session state, but it does not remove the need to end access. Without revocation, a valid token remains usable even after the underlying account, role, or business relationship changes. That creates a lifecycle gap: the authentication event is easy to issue, but hard to unwind. Mature implementations pair JWTs with short expiry, refresh discipline, and server-side denylisting or equivalent invalidation logic for compromised tokens.

Practical implication: design JWT use with explicit revocation and expiry controls so access can actually be terminated.


NHI Mgmt Group analysis

JWT authentication is an access token pattern, not a governance model. The article correctly describes how JWTs scale authentication, but scaling is not the same as controlling identity risk. Once the token leaves the issuer, the enterprise inherits a bearer-credential problem that sits closer to NHI governance than classic session management. Practitioners should treat every JWT as a lifecycle object with issuance, storage, use, and invalidation states.

The weakest point in JWT use is usually not the signature algorithm, but the trust boundary around the token. A valid JWT can still be dangerous if it is copied into logs, exposed in browser storage, or kept alive after access should end. That makes token handling an identity security issue, not just an application security issue. The practical conclusion is that access control must extend beyond login to the full token lifecycle.

Short-lived tokens only work when expiry is paired with revocation discipline. The article’s best-practice advice points in the right direction, but short expiration alone does not solve stolen-token reuse or post-offboarding access. In governance terms, expiry without invalidation is delayed exposure, not control. IAM and IGA teams should map JWT use to revocation, offboarding, and exception handling just as they would for other non-human credentials.

JWTs make the boundary between human and machine access blur faster than many programmes expect. The same token pattern often supports user sessions, API authentication, and service-to-service calls, which means one weak control can affect multiple actor types. That is why JWT governance should be assessed as part of the broader identity fabric rather than as an isolated web authentication pattern. Practitioners need one lifecycle view across human, workload, and application access.

From our research:

  • 64% of valid secrets leaked in 2022 are still valid and exploitable today, proving that detection alone is not enough without automated revocation, according to The State of Secrets Sprawl 2026.
  • GitGuardian also reports that 28% of secrets incidents now originate outside code repositories, in Slack, Jira, and Confluence, and are 13% more likely to be critical than code-based leaks.
  • For a broader control lens, read Ultimate Guide to NHIs for the lifecycle and revocation patterns that apply across bearer credentials.

What this signals

Token lifetimes are only as strong as the invalidation process behind them. JWT adoption tends to expand fastest in environments that want stateless scale, but the governance burden shifts to expiration, revocation, and monitoring. That means teams should measure how quickly they can invalidate a credential after compromise, not just how elegantly they issue it.

Bearer-token design creates an identity blast radius when storage is weak. A JWT that is copied into local storage, logs, or a browser session can be replayed without reauthentication, which collapses the distinction between session and secret. The operational question is whether your programme can detect and terminate that exposure before it becomes persistent access.

The lifecycle lesson is broader than JWTs. Any access artefact that survives beyond the moment it was intended to be used needs the same scrutiny as other non-human credentials. Teams that already use the Ultimate Guide to NHIs as a reference should extend those lifecycle controls to token-based authentication flows as well. The control objective is not just secure issuance, but usable revocation.


For practitioners

  • Validate JWT claims at every trust boundary Require issuer, audience, subject, and expiration checks on every service that accepts a JWT. Do not rely on a single upstream validation step if the token crosses microservices or gateways.
  • Keep sensitive data out of token payloads Use JWT claims for identity and session metadata only. Store payment data, secrets, and other sensitive attributes server-side so token disclosure does not expose business-critical information.
  • Set short token lifetimes and enforce renewal rules Use brief expiry windows and define how refresh or reauthentication works when tokens age out. Pair the expiry policy with logging so unusual token reuse can be investigated quickly.
  • Plan revocation for offboarding and compromise Document how a token is invalidated when a user leaves, a device is lost, or a credential is suspected compromised. Stateless authentication still needs an explicit invalidation path.

Key takeaways

  • JWTs improve scalability, but they shift more security responsibility onto token handling, validation, and invalidation.
  • A valid token can still represent unacceptable risk if it is stored badly, kept too long, or never revoked.
  • Identity teams should govern JWTs as lifecycle artefacts, not as one-time authentication events.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0 and NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-03JWTs require expiry and revocation discipline similar to other bearer credentials.
NIST CSF 2.0PR.AC-1Token-based authentication depends on verified identities and controlled access paths.
NIST Zero Trust (SP 800-207)AC-3Zero trust requires continuous authorization, not trust based only on token issuance.

Treat each JWT-bearing request as a fresh authorization decision and deny stale or out-of-policy tokens.


Key terms

  • JSON Web Token: A JSON Web Token is a compact bearer credential that carries claims about an identity and is signed so the recipient can verify it has not been altered. In practice, it is often used for API and web authentication, but its security depends on validation, storage, and invalidation controls.
  • Stateless Authentication: Stateless authentication is an access model where the server does not keep a session record between requests. Each request carries the information needed to authenticate and authorize access, which improves scale but makes token integrity, expiry, and revocation critical to security.
  • Token Revocation: Token revocation is the process of invalidating a credential before its natural expiry. It is essential when access ends, a token is exposed, or an account is compromised, because a valid but no longer appropriate token can still be replayed if no invalidation path exists.
  • Bearer Credential: A bearer credential is a secret that grants access to whoever presents it, without requiring an additional proof of possession at the moment of use. JWTs can behave this way when they are accepted as-is, which makes storage, transport, and lifecycle control central to risk reduction.

Deepen your knowledge

NHI governance, agentic AI identity, and machine identity lifecycle are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are responsible for identity security strategy or NHI governance in your organisation, it is worth exploring.

This post draws on content published by 1Kosmos: JWT authentication and implementation best practices. Read the original.

NHIMG Editorial Note
Published by the NHIMG editorial team on 2023-04-18.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org