Thymeleaf's restricted expression mode needed an object boundary
Template engines are often described as presentation layers, but a server-side template can call objects, read properties, and invoke application services. Thymeleaf's restricted expression mode exists to limit that power when a template is not fully trusted. CVE-2026-136410 concerns a bypass that used expression objects to perform actions that restricted mode should have blocked.
The GitHub advisory and VulnCheck describe the issue in Thymeleaf before 3.1.6.RELEASE. The public scoring reaches roughly CVSS 9.0 in some feeds because an unauthenticated remote attacker may influence a template expression. The practical risk depends on whether the application exposes user-controlled expressions, how the expression context is built, and which objects are available to the template.
Restricted mode is a policy, not a sandbox
Thymeleaf evaluates expressions against a context. A restricted expression mode can reduce the set of methods, types, and objects that a template may access. The control is only as strong as the boundary between the template and the application objects. If a permitted object exposes a method that returns a more powerful object, the template may reach functionality outside the intended set.
Expression objects are useful because they provide reusable helpers for formatting, links, and data access. They also enlarge the surface. A bypass may not look like a raw Java call. It may be a chain of property reads and method calls that begins with an object the application intended to expose.
Identify applications that evaluate untrusted templates
Inventory services that use Thymeleaf and allow users, tenants, integrations, or lower-privileged administrators to supply templates or expression fragments. Examples include email templates, report builders, notification editors, CMS integrations, and workflow configuration screens. A template supplied only by developers in a reviewed repository has a different risk profile from a template saved through a web form.
Check the Thymeleaf version and the application's expression context. Search for custom expression objects, utility beans, SpringTemplateEngine, TemplateEngine, and code that constructs variables from request data. Review whether the application enables restricted mode and whether it also passes a broad root object into the evaluation.
Upgrade to 3.1.6.RELEASE or later through the dependency-management path used by the service. A transitive dependency may require an explicit version constraint. Rebuild the image and confirm the runtime classpath. A stale cached artifact can make a source change look successful while the deployed application still uses the old library.
Do not rely on a single template flag
Restricted mode is one layer. Applications should separate developer-controlled templates from user-controlled content. If business users need configurable output, prefer a constrained data model and a small set of safe formatting operations. Avoid exposing service beans or arbitrary object graphs to the expression context.
Apply least privilege to the process that evaluates templates. A template service should have only the credentials and network reach needed for its job. Keep secrets out of the context unless the template truly needs them. Review custom dialects and utility objects for methods that can load classes, access files, execute commands, or make network requests.
Run regression tests with representative malicious expressions in a safe test environment. The tests should assert that restricted mode blocks access to forbidden classes and methods, and they should verify that an application error is not being mistaken for a policy denial. Test chained calls and object properties because that is where a type check can be incomplete.
Detection and response
Review application logs for template compilation or evaluation from unexpected users, repeated render failures, suspicious property names, and template changes outside the normal workflow. Correlate those events with outbound network requests, filesystem access, and process creation by the application server. A template vulnerability can be used as a data read or as a step toward command execution.
If the application evaluates untrusted templates, temporarily disable that feature or restrict it to trusted administrators while the upgrade is completed. Preserve the submitted template and the application context for analysis. Remove stored templates that are no longer approved.
The patch fixes the known bypass. The durable control is a smaller expression context with a clear trust model. CVE-2026-136410 should prompt teams to ask which objects a template can reach and why each one is necessary.
References
- Thymeleaf, GHSA-2wmw-5fmc-m25v
- Thymeleaf, 3.1.6.RELEASE
- CVE Program, CVE-2026-136410
- VulnCheck, Restricted expression mode bypass advisory
Top comments (0)