Introduction
Thymeleaf's restricted expression mode exists to contain the damage when an application lets attacker input reach a template expression. In versions before 3.1.6.RELEASE, several expression objects and code paths let injected expressions reach exactly the capabilities that mode was supposed to forbid. For Java and Spring applications that already have a server-side template injection (SSTI) path, CVE-2026-136410 turns a contained injection into one the project rates 9.0 under CVSS 3.1, with changed scope and high confidentiality, integrity and availability impact.
Thymeleaf is an open-source, server-side Java template engine for web and standalone environments, distributed under the Apache License 2.0. Its natural templates display as ordinary HTML prototypes while also serving as live application templates. The reviewed sources give no deployment count or market share, but the project ships Spring modules, and the Spring Framework reference documentation states that the Spring MVC integration is managed by the Thymeleaf project itself. That is why this advisory covers the Spring 5 and Spring 6 integration packages as well as the core library.
Technical Information
What restricted mode is meant to do
Thymeleaf automatically switches to a stricter restricted evaluation mode in sinks where attacker-controlled data is especially dangerous:
| Context | Documented behaviour |
|---|---|
__...__ preprocessing | The preprocessing result becomes part of the expression that is subsequently executed |
th:utext | Produces unescaped output and uses restricted evaluation |
th:on* handlers | Event handler expressions are automatically restricted |
| Template and fragment names | Restrictions cover names and fragment parameters used in fragment expressions and insertion attributes |
| URL bases | Evaluated in restricted mode |
TEXT templates | All output expressions are restricted, escaped or unescaped |
In these contexts the engine forbids object construction with new, static access, request parameter access through ${param.*}, @bean references to the Spring application context, and some context-level utility objects. These are places where the engine intentionally applies extra controls. VulnCheck lists them as the relevant contexts for this CVE, but they are not a published list of independently demonstrated exploit endpoints.
Root cause
The maintainer advisory (GHSA-2wmw-5fmc-m25v) describes the flaw as improper restriction of the scope of specific potentially harmful objects in Thymeleaf expressions: affected versions fail to restrict certain objects that can be used indirectly to perform forbidden actions. NVD classifies it as CWE-917 (expression language injection), and the advisory also lists CWE-1336 (improper neutralization in a template engine).
The advisory does not name the objects, the method chain or a payload. The 3.1.6.RELEASE diff is more informative. The maintainer has not said which commit addresses which part of the report, so what follows is our reading of the restricted mode changes in the release, mapped onto the advisory's description of improperly scoped expression objects. Before the fix:
#conversionswas unrestricted. It could convert a value to any class whose name was passed in, even in restricted mode.- The context object was callable. In restricted mode an injected expression could call methods on the context object itself, for example
#ctx.getVariable(...),#root.getVariable(...)or#vars.getVariable(...), sidestepping the variable-level filters. - Restricted and normal evaluations shared cached state. SpEL nodes cache the accessors and executors they resolve, and compiled SpEL skips the evaluation context for some operations. An expression first parsed in normal mode could later run in a restricted context with its earlier decisions still in place. On the OGNL side, restricted evaluations could still take the
OGNLShortcutExpressionfast path, andOGNLExpressionObjectsWrapperdecided whether it was restricted by looking for a marker key inside the same map that backs theOgnlContextduring evaluation. - Some sinks were not actually restricted.
AbstractStandardInlinercalledexpressionObj.execute(context), which means normal mode, so unescaped inlining[(...)]and inlining inTEXTtemplates were not restricted. Link parameters were hard coded to normal mode. Event handler coverage depended on known attribute names rather than on everyon*attribute produced byth:attr,th:attrappend/th:attrprependor the default attribute processor, and attribute names computed from expressions were not validated, so a value like'x onclick'could smuggle in a second attribute. The WebFluxThymeleafReactiveViewalso lacked thecheckViewNameNotInRequestguard used by the servlet view.
Attack flow
The advisory describes an unauthenticated remote attacker, but the attack is explicitly conditional on application behaviour:
- The application passes unvalidated attacker input into a Thymeleaf expression. Per the project security policy, that input can originate from request parameters, path segments, headers, cookies, request bodies, session attributes, database contents or third-party service responses, and can land in template names, view names, fragment names, fragment parameters, expression fragments or template content.
- The injected expression is evaluated in one of the restricted contexts above.
- The attacker uses an improperly scoped expression object or code path to reach capabilities restricted mode forbids, expanding what the injected expression can do beyond the intended limits.
The CVSS vectors reflect this: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H records high attack complexity, and the CVSS 4.0 assessment (9.5) records attack requirements as present (AT:P). The current advisory does not document a specific operating system command execution chain. Praetorian's research on a separate restricted mode bypass, CVE-2026-40477, showed SSTI leading to remote code execution in versions through 3.1.3.RELEASE. That shows how serious this class of bug can be, but its outcome should not be assumed for this CVE.
On exploitation status, the reviewed advisory and CVE record do not confirm exploitation in the wild, name a threat actor or establish CISA KEV membership. LHeiakim and Daniel Birtwhistle are credited with responsible disclosure. Absence of public reports is an unknown status, not evidence of safety.
Patch Information
The fix is in Thymeleaf 3.1.6.RELEASE, tagged on November 8, 2026. GHSA-2wmw-5fmc-m25v marks org.thymeleaf:thymeleaf, thymeleaf-spring5 and thymeleaf-spring6 <= 3.1.5.RELEASE as vulnerable and names 3.1.6.RELEASE as the patched version for all three. The GHSA has no CVE ID of its own. The link to CVE-2026-136410 comes from VulnCheck's NVD record, which cites this advisory and this release.
No single fix commit has been published. The advisory's patch note says only: "This has been fixed in Thymeleaf 3.1.6.RELEASE." The 3.1.5.RELEASE...3.1.6.RELEASE comparison contains 61 commits, and a group committed between November 2 and November 3 targets restricted expression mode directly.
1. Expression objects get a restricted variant (#conversions)
In 3.1.6, a restricted mode lookup of conversions returns a separate conversions[restricted] object, or nothing if that variant is not provided:
if (RESTRICTED_VARIANT_VARIABLE_NAMES.contains(name)) { return lookupRestrictedVariant(this.expressionObjects, name); }
The variant is built as new Conversions(context, true) and checks every conversion target against an allowlist:
private void checkConversionAllowed(final String className) { // Conversion target types are subject to the same type restrictions as expressions. // In restricted mode, only an allowlist of value types can be used as conversion targets. if (this.restricted) { if (!ExpressionUtils.isTypeAllowedForRestrictedInstantiation(className)) {
Array component types are checked at every dimension, so wrapping a forbidden type in an array no longer passes. The same lookup was added to OGNLExpressionObjectsWrapper and to both Spring evaluation contexts.
2. The context object (#ctx, #root, #vars) is locked down
The Spring ACL method resolver now intercepts any method call on an IContext target:
if (targetObject instanceof IContext) { checkContextMemberCallAllowed(context, name); // Resolved executors are cached in parsed expressions, which can be executed in different modes return new ContextMethodExecutor(methodExecutor, name); }
The wrapper exists because SpEL caches resolved executors. ContextMethodExecutor repeats the check on every execution, so an executor cached during a normal render cannot be reused in a restricted one. On the OGNL side, ThymeleafACLMemberAccess.isAccessible(...) now throws whenever the target is an IContext and evaluation is restricted. New tests confirm that th:utext="${#ctx.getVariable('somevar')}", #root.getVariable(...) and #vars.getVariable(...) are rejected.
3. Restricted and normal evaluations no longer share cached state
Restricted evaluations get their own cache key and are never compiled:
final String cacheType = (restricted ? EXPRESSION_CACHE_TYPE_SPEL_RESTRICTED : EXPRESSION_CACHE_TYPE_SPEL);
SPELContextPropertyAccessor.read() now repeats the param restriction check, because, as the code comment notes, canRead() may never have been called on a cached path. SPELContextMapWrapper.get() also blocks param in restricted mode.
OGNL received equivalent changes. Restricted evaluations skip the OGNLShortcutExpression fast path and use a fully parsed expression. Before execution, the parsed AST is walked and rejected if it contains a constructor call, static method or field access, or a typed map such as #@Map@{...}:
if (node instanceof ASTCtor || node instanceof ASTStaticMethod || node instanceof ASTStaticField || (node instanceof ASTMap && node.toString().startsWith("#@"))) {
The tests include a static call like @java.lang.Math@max(1,2) with a Unicode character (U+02C2) inserted into it, used in th:utext, which is now refused. Because enforcement happens on the parsed AST rather than on text patterns, that kind of obfuscation no longer helps. Finally, the restricted flag in OGNLExpressionObjectsWrapper is now fixed when the wrapper is constructed instead of being read from a marker key in the evaluation map.
4. Restricted mode now covers every intended sink
- Inlined expressions:
AbstractStandardInlinernow matches theth:text/th:utextprocessors:
final StandardExpressionExecutionContext expContext = (escape && this.templateMode != TemplateMode.TEXT)? StandardExpressionExecutionContext.NORMAL : StandardExpressionExecutionContext.RESTRICTED; expressionResult = expressionObj.execute(context, expContext);
- Event handlers: In HTML mode, any attribute whose name starts with
onnow usesRESTRICTED_FORBID_UNSAFE_EXP_RESULTS, including attributes created by the default attribute processor,th:attrandth:attrappend/th:attrprepend. The list of known DOM events was extended (onpointerdown,ontoggle,onwheeland others), and attribute names computed from expressions are validated, so'x onclick'can no longer inject a second attribute. - Link parameters: Previously hard coded to
NORMAL, they are now evaluated withexpContext.forLinkParameters(). Onlyth:hrefandth:srckeep normal mode parameters, via the newRESTRICTED_WITH_NORMAL_LINK_PARAMETERS. Detection of thejavascript:scheme now ignores leading control characters and embedded tabs and newlines, as the WHATWG URL parser does. - WebFlux fragment view names:
ThymeleafReactiveViewnow applies the samecheckViewNameNotInRequestguard as the servlet view, and also checks request form data (issue #1116).
5. A wider class denylist (defense in depth)
Under issue #1112, ExpressionUtils blocks many more packages for type references, including ognl., org.apache.tomcat./catalina., the commons io, commons text and commons beanutils packages, the collections functors, JDBC drivers, org.hibernate., org.slf4j. and ch.qos.logback.. Array type names are reduced to their component type before the check, so [Lognl.Ognl; counts as forbidden. The Atomic*FieldUpdater classes were removed from the allowlist, and OGNL was upgraded from 3.3.4 to 3.4.17.
6. The security model is written down
The release adds an "Expression Evaluation Security Model" section to SECURITY.md, stating: "These mechanisms are defense-in-depth, not a primary security boundary." Future restricted mode bypasses will still be fixed, but scored as conditional on the application passing unvalidated input into an expression.
Behaviour changes to test after upgrading
Upgrade all three artifacts together to 3.1.6.RELEASE. Templates that previously worked may now fail in these cases:
#conversionscalls in restricted contexts#ctx/#varsmethod calls insideth:utextorTEXTtemplateson*attributes that receive string (text) resultsth:uerrorsoutput, which now keeps only basic formatting markup- OGNL expressions like
flag?.5:1, which no longer parse because?.is now the safe navigation operator
The advisory's only workaround is to ensure applications do not pass unvalidated user input directly to the template engine. It offers no configuration switch or filtering rule as an alternative, and it still strongly recommends upgrading. Treat the upgrade and input validation as two separate layers rather than substitutes.
Affected Systems and Versions
| Maven package | Affected versions | Patched version |
|---|---|---|
org.thymeleaf:thymeleaf | 3.1.5.RELEASE and earlier | 3.1.6.RELEASE |
org.thymeleaf:thymeleaf-spring5 | 3.1.5.RELEASE and earlier | 3.1.6.RELEASE |
org.thymeleaf:thymeleaf-spring6 | 3.1.5.RELEASE and earlier | 3.1.6.RELEASE |
The CVE record expresses the same boundary as versions below 3.1.6.RELEASE. Versions 3.1.4.RELEASE and 3.1.5.RELEASE fixed earlier expression bypasses but are still affected by this one.
Presence of the library alone does not establish remote exploitability. The vulnerable configuration is an application on an affected version that passes unvalidated input into an expression evaluated in a restricted context such as preprocessing, th:utext, th:on* handlers, template or fragment names, inlined output or TEXT templates.
Severity: 9.0 (CVSS 3.1, from the project advisory) and 9.5 (CVSS 4.0, from the CVE record). Both are Critical. When communicating risk, keep the scoring version attached to the number.
Vendor Security History
This is the latest in a series of 2026 advisories against Thymeleaf's expression restrictions:
| Advisory | Documented mechanism | Affected through | Patched version |
|---|---|---|---|
| GHSA-r4v4-5mwr-2fwr | Scope of accessible objects | 3.1.3.RELEASE | 3.1.4.RELEASE |
| GHSA-xjw8-8c5c-9r79 | Unauthorized expression syntax patterns | 3.1.3.RELEASE | 3.1.4.RELEASE |
| GHSA-c9ph-gxww-7744 (CVE-2026-41901) | Unauthorized syntax in sandboxed expressions | 3.1.4.RELEASE | 3.1.5.RELEASE |
| GHSA-2wmw-5fmc-m25v (CVE-2026-136410) | Specific objects indirectly permit forbidden actions | 3.1.5.RELEASE | 3.1.6.RELEASE |
The first two were published on April 15, 2026. Praetorian separately documented CVE-2026-40477, a restricted mode bypass discovered by Thomas Reburn that yielded remote code execution through SSTI in versions through 3.1.3.RELEASE. A release that fixes one expression bypass can still be affected by a later, distinct one, so check the fix boundary per advisory.
On process, the project publishes a security reporting address ([email protected]), asks researchers to avoid public GitHub issues for vulnerabilities, and credits reporters. The disclosure timeline for this CVE:
| Event | Date |
|---|---|
| Project advisory published | November 8, 2026 |
| 3.1.6.RELEASE published | November 8, 2026 |
| CVE record published | November 24, 2026 |
| NVD record published | November 24, 2026 |
The NVD date therefore should not be read as the start of public disclosure or of fix availability. The advisory does not disclose the initial private report date, so response time cannot be calculated.
References
- NVD: CVE-2026-136410
- CVE Record: CVE-2026-136410
- CVE JSON record (cveawg.mitre.org)
- Thymeleaf advisory GHSA-2wmw-5fmc-m25v
- GHSA-2wmw-5fmc-m25v via GitHub API
- Thymeleaf 3.1.6.RELEASE release
- Thymeleaf 3.1.6.RELEASE release via GitHub API
- Comparison of 3.1.5.RELEASE and 3.1.6.RELEASE
- Thymeleaf 3.1.6 milestone issues via GitHub API
- Thymeleaf 3.1.6 milestone
- VulnCheck advisory: Thymeleaf before 3.1.6.RELEASE restricted expression mode bypass via expression objects
- Thymeleaf Security Policy
- Thymeleaf ChangeLog (3.1 branch)
- GHSA-r4v4-5mwr-2fwr: scope of accessible objects
- GHSA-xjw8-8c5c-9r79: unauthorized expression syntax patterns
- GHSA-c9ph-gxww-7744: unauthorized syntax in sandboxed expressions
- Praetorian: Thymeleaf RESTRICTED mode bypass, SSTI
- Tutorial: Using Thymeleaf 3.1
- Thymeleaf project site
- Spring Framework reference: Thymeleaf
- CISA Known Exploited Vulnerabilities Catalog



