Threat Feed

CVE-2026-40477: Improper restriction of the scope of accessible objects in Thymeleaf expressions

Exploitation: In the wild · CVSS 9.1 Critical · Unauthenticated · Published 2026-04-17

Description

Thymeleaf is a server-side Java template engine for web and standalone environments. Versions 3.1.3.RELEASE and prior contain a security bypass vulnerability in the expression execution mechanisms. Although the library provides mechanisms to prevent expression injection, it fails to properly restrict the scope of accessible objects, allowing specific potentially sensitive objects to be reached from within a template. If an application developer passes unvalidated user input directly to the template engine, an unauthenticated remote attacker can bypass the library's protections to achieve Server-Side Template Injection (SSTI). This issue has ben fixed in version 3.1.4.RELEASE.

Enclave's analysis

Thymeleaf up to 3.1.3.RELEASE doesn't fully lock down its restricted expression mode. Objects like #ctx stay reachable, so an attacker can get to the request, response and servlet context. It only works if the app feeds unvalidated user input into the template engine. A documented proof of concept exists, but there's no known in-the-wild use. Upgrade to 3.1.4 or later, and never pass user input to templates.

Fix

Upgrade org.thymeleaf:thymeleaf to 3.1.4.RELEASE; Thymeleaf 3.0.x (end-of-life line) to 3.0.17 (HeroDevs commercial build only). No fixed version is listed for thymeleaf, org.thymeleaf:thymeleaf-spring5, org.thymeleaf:thymeleaf-spring6 and others; follow the vendor advisory.

Affected versions

ProductVulnerableFixed in
thymeleaf< 3.1.4.RELEASENot listed
org.thymeleaf:thymeleaf-spring5< 3.1.4.RELEASENot listed
org.thymeleaf:thymeleaf-spring6< 3.1.4.RELEASENot listed
org.thymeleaf:thymeleaf<= 3.1.3.RELEASE (OSV lists 2.0.0-beta1 onward)3.1.4.RELEASE
Thymeleaf 3.0.x (end-of-life line)All 3.0.x releases; no upstream fix3.0.17 (HeroDevs commercial build only)
Red Hat Fuse 7 (thymeleaf)Affected by default; marked will not fixNot listed
Red Hat Single Sign-On 7 (thymeleaf packages)Affected by default per vendor dataNot listed

Seen in 2 sources