Subscribe to the Non-Human & AI Identity Journal

What is the difference between JWE and JWS for identity teams?

JWS proves a token was not altered and identifies the signer. JWE keeps the token contents unreadable to anyone except the intended recipient. Identity teams often need both, because authentication workflows need integrity, while federated or partner-facing claims may also require confidentiality.

Why This Matters for Security Teams

JWE and JWS solve different identity-team problems, and mixing them up creates avoidable risk. JWS is about authenticity and integrity: the receiver can tell the token was signed and not modified. JWE is about confidentiality: only the intended recipient can read the contents. In practice, identity teams often need JWS for federation assertions, then JWE when claims include partner-sensitive data, internal routing details, or other secrets that should not be visible in transit. That distinction matters because token design influences trust boundaries, logging, support workflows, and incident response.

For teams managing NHIs, the issue is not academic. A signed but readable token may still expose overbroad claims, while an encrypted token without clear validation steps can break downstream authorization checks. The broader NHI risk context is well documented in the Ultimate Guide to NHIs, and the same governance gap appears in breach patterns such as the 52 NHI Breaches Analysis. NIST also frames identity assurance and trust decisions as part of a broader control strategy in the NIST Cybersecurity Framework 2.0.

In practice, many security teams encounter token exposure only after a partner integration, logging pipeline, or support export has already leaked data.

How It Works in Practice

Identity teams should treat JWS and JWE as complementary, not competing, mechanisms. A JWS token is signed so consumers can verify the issuer and confirm the payload has not changed. A JWE token is encrypted so only the recipient can read the claims. In federated identity, that usually means the issuer signs first, then the token may be encrypted for the recipient. The operational question is not “which one is better,” but “which claims need integrity, and which claims need confidentiality?”

For example, an access token carrying only a subject identifier and scope may not need encryption if the transport and audience controls are strong. A token containing tenant identifiers, delegated rights, or partner-specific attributes may need JWE to reduce exposure if intercepted, logged, or replayed into the wrong system. The Top 10 NHI Issues research highlights how often secrets and identity material end up in unsafe locations, and that same pattern applies to sensitive token contents when teams rely on “security through obscurity.”

  • Use JWS when the verifier needs to trust origin and integrity.
  • Use JWE when the token body contains data that should not be readable by intermediaries.
  • Keep claims minimal so encrypted tokens are not overloaded with unnecessary data.
  • Define whether signing, encryption, or both are required for each trust boundary.
  • Validate audience, issuer, algorithm, and key lifecycle regardless of token format.

Current guidance suggests aligning token handling with the data classification of the claims, not with a blanket “always encrypt” or “always sign” rule. Where teams adopt workload identity patterns, the choice should also fit their runtime controls and rotation model. These controls tend to break down when multiple gateways, proxies, or legacy consumers rewrite tokens because the original trust chain becomes hard to verify.

Common Variations and Edge Cases

Tighter token protection often increases implementation complexity, key-management overhead, and troubleshooting time, so organisations must balance confidentiality against operational simplicity. That tradeoff is especially visible when identity teams support both internal services and external partners. There is no universal standard for when JWE is mandatory versus merely recommended; current guidance suggests using the minimum protection that still matches the sensitivity of the claims and the exposure of the transport path.

One common edge case is nested JWTs, where a signed token is then encrypted. That can preserve both integrity and confidentiality, but it also makes debugging harder and key rotation more sensitive. Another is downstream services that need to inspect claims for authorization decisions. If those services cannot decrypt, they may force the team to duplicate claims in a readable header or side channel, which can weaken the original design. The Ultimate Guide to NHIs — What are Non-Human Identities and the JetBrains GitHub plugin token exposure case both reinforce a simple point: token contents are operational data, not just crypto artifacts. For baseline control mapping, NIST guidance on identity and access management in the NIST Cybersecurity Framework 2.0 remains a sensible reference.

In practice, the right design often depends on who must read the claims, where the token travels, and how much the surrounding infrastructure can be trusted.

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 AI RMF set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP Non-Human Identity Top 10 NHI-01 Token signing and encryption affect NHI trust boundaries and credential exposure.
NIST CSF 2.0 PR.AC-4 JWS/JWE choices support least-privilege access and controlled information disclosure.
NIST AI RMF Identity token handling is part of governance for autonomous and data-driven systems.

Map token audience, issuer, and claim visibility to least-privilege access rules and review them regularly.