CVE-2026-40478: Improper neutralization of specific syntax patterns for unauthorized expressions in Thymeleaf
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 the expression execution mechanisms. Although the library provides mechanisms to prevent expression injection, it fails to properly neutralize specific syntax patterns that allow for the execution of unauthorized expressions. 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
CVE-2026-40478 is a critical Server-Side Template Injection (SSTI) sandbox escape in Thymeleaf, the dominant Java template engine in the Spring Boot ecosystem. It chains three independent bypass techniques — a TOCTOU race in expression detection via preprocessing directives, a whitespace normalization mismatch (TAB 0x09) that evades keyword scanning while SpEL still parses the constructor call, and an incomplete type blocklist that leaves org.springframework.* and com.fasterxml.jackson.* classes unrestricted. When exploited, an unauthenticated remote attacker can achieve arbitrary file writes or full Remote Code Execution on the server. However, the vulnerability is conditional: it requires the application to pass unvalidated user input directly into Thymeleaf's expression engine or view name resolution (e.g., `return "prefix/" + userInput;`), a pattern that contradicts recommended usage. Applications that use static template names and pass user data only through the Model object are not vulnerable. The initial fix in 3.1.4.RELEASE was incomplete and bypassed by CVE-2026-41901; the complete fix is 3.1.5.RELEASE.
Fix
Upgrade org.thymeleaf:thymeleaf to 3.1.4.RELEASE (3.1.5.RELEASE recommended due to CVE-2026-41901 bypass); Red Hat Fuse 7 (thymeleaf) to No fix planned; Red Hat Single Sign-On 7 (thymeleaf, thymeleaf-spring5, spring-boot-starter-thymeleaf, thymeleaf-extras-java8time) to Not specified. See the affected versions for other product fixes. No fixed version is listed for thymeleaf, org.thymeleaf:thymeleaf-spring5, org.thymeleaf:thymeleaf-spring6; follow the vendor advisory.
Affected versions
| Product | Vulnerable | Fixed in |
|---|---|---|
| thymeleaf | < 3.1.4.RELEASE | Not listed |
| org.thymeleaf:thymeleaf-spring5 | < 3.1.4.RELEASE | Not listed |
| org.thymeleaf:thymeleaf-spring6 | < 3.1.4.RELEASE | Not listed |
| org.thymeleaf:thymeleaf | All versions prior to 3.1.4.RELEASE (2.0.0 through 3.1.3.RELEASE) | 3.1.4.RELEASE (3.1.5.RELEASE recommended due to CVE-2026-41901 bypass) |
| Red Hat Fuse 7 (thymeleaf) | All versions (defaultStatus: affected) | No fix planned |
| Red Hat Single Sign-On 7 (thymeleaf, thymeleaf-spring5, spring-boot-starter-thymeleaf, thymeleaf-extras-java8time) | All versions (defaultStatus: affected) | Not specified |
| Red Hat OpenShift Dev Spaces 3.28 (devspaces/openvsx-rhel9, devspaces/pluginregistry-rhel9) | Versions prior to container builds 1779528224 / 1779359423 | Container builds 1779528224 / 1779359423 |
Seen in 2 sources
- CVE.org
- ENISA EUVD