Don't Panic: The Thymeleaf Template Injection That Only Hurts If You Let It (CVE-2026-40478)
Blog post from Snyk
CVE-2026-40478 highlights a significant server-side template injection vulnerability in Thymeleaf, a Java-based templating engine used for server-side webpage rendering, with a high CVSS score of 9.1, potentially leading to remote code execution if exploited. This vulnerability allows bypassing Thymeleaf's security sandbox via a tab character, but it only becomes a threat if the code improperly allows user input to directly interact with the expression engine, which signifies a misuse of the framework. Developers are advised to patch to Thymeleaf 3.1.4 or later, regardless of their perceived risk, and to audit their use of dynamic templates or view names constructed from user data. Ensuring that user input is correctly handled and static within templates is crucial to maintaining security. Additionally, developers should scan dependencies and monitor them with tools like Snyk to prevent similar vulnerabilities.