# CVE-2026-40478: Improper neutralization of specific syntax patterns for unauthorized expressions in Thymeleaf

> An unauthenticated remote attacker can achieve Server-Side Template Injection and execute arbitrary code by bypassing expression protections in Thymeleaf.

- **Severity:** Critical 9.1 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 17 Apr 2026
- **Updated:** 18 Aug 2026
- **Also known as:** GHSA-xjw8-8c5c-9r79

## What is CVE-2026-40478?

CVE-2026-40478 is a critical code injection vulnerability in org.thymeleaf:thymeleaf-spring5, published on 17 Apr 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official 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.

Weakness: CWE-917 (Improper Neutralization of Special Elements used in an Expression Language Statement), CWE-1336 (Improper Neutralization of Special Elements Used in a Template Engine)

## Which versions are affected by CVE-2026-40478?

6 open source packages ship an affected version, including org.thymeleaf:thymeleaf-spring5, org.thymeleaf:thymeleaf and org.thymeleaf:thymeleaf-spring6. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.thymeleaf:thymeleaf-spring5` | Maven | All versions | 3.1.4.RELEASE |
| `org.thymeleaf:thymeleaf-spring5` | Maven | All versions | 3.1.4.RELEASE |
| `org.thymeleaf:thymeleaf` | Maven | All versions | 3.1.4.RELEASE |
| `org.thymeleaf:thymeleaf` | Maven | All versions | 3.1.4.RELEASE |
| `org.thymeleaf:thymeleaf-spring6` | Maven | All versions | 3.1.4.RELEASE |
| `org.thymeleaf:thymeleaf-spring6` | Maven | All versions | 3.1.4.RELEASE |

Products: Thymeleaf Thymeleaf.

## How do I fix CVE-2026-40478?

Upgrade org.thymeleaf:thymeleaf-spring5 to 3.1.4.RELEASE or later.

## Is CVE-2026-40478 being exploited?

There is no known exploitation of CVE-2026-40478 in the wild and no public exploit code.

## Other vulnerabilities in org.thymeleaf:thymeleaf-spring5

- [CVE-2021-43466](https://insights.sbomify.com/CVE-2021-43466/): Template injection in thymeleaf-spring5 (critical 9.8)
- [CVE-2026-40477](https://insights.sbomify.com/CVE-2026-40477/): Improper restriction of the scope of accessible objects in Thymeleaf expressions (critical 9.1)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-40478 and fix it if it is affected.

What it is: CVE-2026-40478 is a critical code injection vulnerability in org.thymeleaf:thymeleaf-spring5, published on 17 Apr 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2026-40478 in the wild and no public exploit code.

Affected packages and fixed versions:
- org.thymeleaf:thymeleaf-spring5 (Maven): affected all versions; fixed in 3.1.4.RELEASE
- org.thymeleaf:thymeleaf-spring5 (Maven): affected all versions; fixed in 3.1.4.RELEASE
- org.thymeleaf:thymeleaf (Maven): affected all versions; fixed in 3.1.4.RELEASE
- org.thymeleaf:thymeleaf (Maven): affected all versions; fixed in 3.1.4.RELEASE
- org.thymeleaf:thymeleaf-spring6 (Maven): affected all versions; fixed in 3.1.4.RELEASE
- org.thymeleaf:thymeleaf-spring6 (Maven): affected all versions; fixed in 3.1.4.RELEASE

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-40478/ (Markdown: https://insights.sbomify.com/CVE-2026-40478/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-40478
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-40478
- OSV: https://osv.dev/vulnerability/CVE-2026-40478

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-40478/
Summaries are generated and may contain mistakes; the official description above is the record.
