Severity:

HIGH RISK

(7.4)

Stale Authentication State / Race Conditions in Security

CVE-2026-5795

Modified

Vulnerability type

Category:

Stale Authentication State / Race Conditions in Security Context

CWE:

CWE-226, CWE-287

Impact:

Broken Access Control and Privilege Escalation

Severity:

HIGH RISK

(7.4)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Eclipse Jetty's JASPIAuthenticator can leave authentication data in ThreadLocal variables when it exits early, causing subsequent requests on the same thread to inherit stale security context.

Under these conditions, a user may gain access with another user's privileges, resulting in broken access control and potential privilege escalation.

Affected context

This vulnerability appears in Jetty deployments using the JASPIAuthenticator where authentication state is stored in ThreadLocal variables.

It manifests when certain authentication flows cause JASPIAuthenticator to return early, skipping the cleanup of those ThreadLocals.

Environments that reuse worker threads heavily (such as typical servlet containers under load) are more likely to encounter cross-request leakage of authentication state.

Exploit preconditions

  • Attack surface: HTTP endpoints handled by Jetty where JASPIAuthenticator performs authentication.
  • Required access: Ability to send crafted or timed HTTP requests to the affected Jetty server.
  • Trigger point: An initial request that partially triggers JASPIAuthenticator, sets ThreadLocal authentication values, and then exits via a code path that omits cleanup.
  • Why exploitation is possible: ThreadLocal variables are bound to threads, not requests. When cleanup does not occur on early return, the next request reusing that thread can see the previous authentication state, causing the server to treat the new request as if it were authenticated as the prior user.

Why this happens

The core issue is incomplete lifecycle management of per-request security state stored in ThreadLocal variables.

JASPIAuthenticator sets two ThreadLocal values during authentication checks but relies on certain control-flow paths to clear them.

When early-return code paths bypass the cleanup logic, the ThreadLocals remain populated and leak into subsequent requests that reuse the same thread.

This maps to CWE-226: Sensitive Information Uncleared Before Release, where resources (here, threads and their ThreadLocal state) are returned to a pool while still holding sensitive or security-relevant data.

The resulting behavior also relates to CWE-287: Improper Authentication, because a request can be treated as authenticated based on stale state rather than its own credentials.

Potential impact

  • Requests may be processed under another user's identity and privileges.
  • Unauthorized access to protected resources that the current caller should not reach.
  • Escalation from low-privileged to high-privileged roles in multi-user systems.
  • Violation of tenant isolation in multi-tenant applications.
  • Audit and logging inconsistencies, misattributing actions to the wrong user.

General mitigation guidance

Mitigation focuses on robust cleanup of per-request authentication state and defensive handling of ThreadLocals:

  • Ensure all code paths in authentication filters/handlers, including early returns and error paths, explicitly clear ThreadLocal security context.
  • Prefer request-scoped or context objects passed through the call chain instead of ThreadLocal for security-sensitive data where feasible.
  • Use well-defined lifecycle hooks (e.g., finally blocks or container callbacks) to guarantee cleanup, independent of authentication outcome.
  • Minimize the amount of authentication and authorization state stored in thread-bound structures, favoring immutable, per-request tokens.
  • Apply least privilege defaults so that in ambiguous or inconsistent state, access is denied rather than granted.

How teams detect issues like this

Detection commonly involves a combination of code-level and behavior-level checks:

  • Static analysis rules that flag use of ThreadLocal for authentication or authorization data without corresponding cleanup in all control flows.
  • Code review guidelines requiring that any ThreadLocal used in security code be set and cleared symmetrically, ideally within try/finally constructs.
  • Dynamic tests that simulate concurrent and sequential requests on the same connection pool, checking for cross-request leakage of user identity or roles.
  • Security testing that repeatedly alternates authenticated and unauthenticated requests, inspecting whether the server ever treats unauthenticated requests as authenticated.
  • Application-level monitoring for anomalous access patterns, such as sudden privilege jumps or actions attributed to users without proper login events.

Sources

SourceLink
github.comgithub.com/jetty/jetty.project/security/advisories/GHSA-r7p8-xq5m-436chttps://
gitlab.eclipse.orggitlab.eclipse.org/security/cve-assignment/-/issues/92
access.redhat.comaccess.redhat.com/errata/RHSA-2026:17668
access.redhat.comaccess.redhat.com/errata/RHSA-2026:25089
access.redhat.comaccess.redhat.com/errata/RHSA-2026:28573
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-5795
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2456519
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-5795.json

Frequently asked

questions

Yes. An attacker who can send HTTP requests to a vulnerable Jetty instance can potentially exploit this issue by influencing how authentication flows execute and how threads are reused.

Not necessarily. While having an account can make it easier to shape authentication flows, the core problem is the reuse of stale ThreadLocal state. In some scenarios, an unauthenticated attacker may benefit from a previous legitimate user's state being leaked onto their request.

Ensure that all ThreadLocal-based authentication state is cleared in a guaranteed way, such as wrapping the entire authentication and request processing in a try/finally block that always removes or resets ThreadLocal values, even on early exit or error.

Avoid relying on ThreadLocal for critical security context when possible; if it must be used, enforce strict patterns that pair every set with a clear in all code paths, codify this in coding standards, and use automated checks or reviews to verify compliance.

Find out what's already
exploitable in your codebase.