This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/struts-site.git
The following commit(s) were added to refs/heads/asf-site by this push:
new e3ff9301ed Automatic Site Publish by Buildbot
e3ff9301ed is described below
commit e3ff9301ed03597c803ac0adec68feafe3972fc0
Author: buildbot <[email protected]>
AuthorDate: Tue Dec 1 20:50:05 2026 +0000
Automatic Site Publish by Buildbot
---
output/core-developers/default-properties.html | 7 +
output/plugins/plugins-architecture.html | 6 +
output/security/index.html | 310 +++++++++++++++++++++++--
3 files changed, 310 insertions(+), 13 deletions(-)
diff --git a/output/core-developers/default-properties.html
b/output/core-developers/default-properties.html
index ffc64896e7..3d1b9afe81 100644
--- a/output/core-developers/default-properties.html
+++ b/output/core-developers/default-properties.html
@@ -448,6 +448,13 @@ struts.ognl.disallowCustomOgnlMap=true
### which allows every node. Set it to a class name, a bean name or an id
known to the object factory.
# struts.ognl.nodeGuard=com.example.MyNodeGuard
+### Selects the org.apache.struts2.ognl.ParameterNodeGuard asked about each
node of a parameter or cookie name
+### before it is bound. The default one admits the property paths matched by
the default accepted patterns; an
+### application that widens struts.override.acceptedPatterns or
struts.additional.acceptedPatterns to admit other
+### expression shapes has to select a guard that admits them too. Set it to a
class name, a bean name or an id
+### known to the object factory.
+# struts.ognl.parameterNodeGuard=com.example.MyParameterNodeGuard
+
### Whether to enable OGNL allowlist, protects against critical
vulnerabilities, strongly recommended to keep enabled!
struts.allowlist.enable=true
### Whether to require @StrutsParameter annotations on Action parameter
injection methods
diff --git a/output/plugins/plugins-architecture.html
b/output/plugins/plugins-architecture.html
index c432714997..0ca0e4f671 100644
--- a/output/plugins/plugins-architecture.html
+++ b/output/plugins/plugins-architecture.html
@@ -496,6 +496,12 @@ For example, a plugin could provide a new class to create
Action classes or map
<td>singleton</td>
<td>org.apache.struts2.ognl.OgnlNodeGuard</td>
</tr>
+ <tr>
+ <td>struts.ognl.parameterNodeGuard</td>
+ <td>Define a custom ParameterNodeGuard implementation, asked about each
node of a parameter or cookie name before it is bound (since 7.6.0)</td>
+ <td>singleton</td>
+ <td>org.apache.struts2.ognl.ParameterNodeGuard</td>
+ </tr>
<tr>
<td>struts.securityMemberAccess</td>
<td>Define a custom SecurityMemberAccess implementation, used to
restrict OGNL evaluations based on classes involved (since 6.4.0)</td>
diff --git a/output/security/index.html b/output/security/index.html
index 354a38bdfe..685f5a32ce 100644
--- a/output/security/index.html
+++ b/output/security/index.html
@@ -156,6 +156,7 @@
<li><a href="#security-tips" id="markdown-toc-security-tips">Security
tips</a> <ul>
<li><a href="#restrict-access-to-the-config-browser-plugin"
id="markdown-toc-restrict-access-to-the-config-browser-plugin">Restrict access
to the Config Browser Plugin</a></li>
<li><a href="#dont-mix-different-access-levels-in-the-same-namespace"
id="markdown-toc-dont-mix-different-access-levels-in-the-same-namespace">Don’t
mix different access levels in the same namespace</a></li>
+ <li><a href="#restrict-the-http-methods-an-action-accepts"
id="markdown-toc-restrict-the-http-methods-an-action-accepts">Restrict the HTTP
methods an action accepts</a></li>
<li><a href="#never-expose-jsp-files-directly"
id="markdown-toc-never-expose-jsp-files-directly">Never expose JSP files
directly</a></li>
<li><a href="#disable-devmode" id="markdown-toc-disable-devmode">Disable
devMode</a></li>
<li><a href="#reduce-logging-level"
id="markdown-toc-reduce-logging-level">Reduce logging level</a></li>
@@ -171,14 +172,17 @@
<li><a href="#strict-method-invocation"
id="markdown-toc-strict-method-invocation">Strict Method Invocation</a></li>
<li><a href="#resource-isolation-using-fetch-metadata"
id="markdown-toc-resource-isolation-using-fetch-metadata">Resource Isolation
Using Fetch Metadata</a></li>
<li><a href="#cross-origin-isolation-with-coop-and-coep"
id="markdown-toc-cross-origin-isolation-with-coop-and-coep">Cross Origin
Isolation with COOP and COEP</a></li>
+ <li><a href="#limit-what-a-single-request-can-consume"
id="markdown-toc-limit-what-a-single-request-can-consume">Limit what a single
request can consume</a></li>
+ <li><a href="#handle-uploaded-files-as-untrusted-input"
id="markdown-toc-handle-uploaded-files-as-untrusted-input">Handle uploaded
files as untrusted input</a></li>
+ <li><a href="#leave-legacy-features-disabled"
id="markdown-toc-leave-legacy-features-disabled">Leave legacy features
disabled</a></li>
</ul>
</li>
<li><a
href="#proactively-protecting-against-ognl-expression-injections-attacks"
id="markdown-toc-proactively-protecting-against-ognl-expression-injections-attacks">Proactively
protecting against OGNL Expression Injections attacks</a> <ul>
- <li><a href="#run-ognl-expressions-inside-sandbox"
id="markdown-toc-run-ognl-expressions-inside-sandbox">Run OGNL expressions
inside sandbox</a></li>
<li><a href="#restricting-access-to-the-struts-context-actioncontext"
id="markdown-toc-restricting-access-to-the-struts-context-actioncontext">Restricting
access to the Struts Context (ActionContext)</a></li>
<li><a href="#apply-a-maximum-allowed-length-on-ognl-expressions"
id="markdown-toc-apply-a-maximum-allowed-length-on-ognl-expressions">Apply a
maximum allowed length on OGNL expressions</a></li>
<li><a href="#ognl-member-access"
id="markdown-toc-ognl-member-access">OGNL Member Access</a></li>
<li><a href="#struts-ognl-guard"
id="markdown-toc-struts-ognl-guard">Struts OGNL Guard</a></li>
+ <li><a href="#run-ognl-expressions-inside-sandbox"
id="markdown-toc-run-ognl-expressions-inside-sandbox">Run OGNL expressions
inside sandbox</a></li>
</ul>
</li>
</ul>
@@ -211,6 +215,54 @@ by security level.</p>
<span class="nt"></security-constraint></span>
</code></pre></div></div>
+<p>A restriction by URL pattern in front of Struts, such as a <code
class="language-plaintext highlighter-rouge">security-constraint</code>, a
URL-pattern filter or a reverse
+proxy rule, is only as good as the agreement between the path it checks and
the path Struts maps to an action. Since
+Struts 7.5.0 and 6.13.0 the framework maps actions from the servlet path and
path info reported by the container.
+In earlier releases the two paths could differ and such a restriction could be
bypassed, see
+<a href="https://cwiki.apache.org/confluence/display/WW/S2-086">S2-086</a>.
There is no configuration-only mitigation, so upgrade
+if your application relies on this kind of access control. Authorization
enforced inside Struts, for example with
+an <a href="../core-developers/interceptors">interceptor</a> on the action,
applies to the action that actually runs.</p>
+
+<h3 id="restrict-the-http-methods-an-action-accepts">Restrict the HTTP methods
an action accepts</h3>
+
+<p>An action that changes state should not be reachable with <code
class="language-plaintext highlighter-rouge">GET</code>. You can restrict the
HTTP methods an action accepts
+with the <code class="language-plaintext
highlighter-rouge">@AllowedHttpMethod</code>, <code class="language-plaintext
highlighter-rouge">@HttpGet</code>, <code class="language-plaintext
highlighter-rouge">@HttpPost</code>, <code class="language-plaintext
highlighter-rouge">@HttpPut</code>, <code class="language-plaintext
highlighter-rouge">@HttpDelete</code> and <code class="language-plaintext
highlighter-rouge">@HttpGetOrPost</code> annotations and,
+since Struts 7.5.0, with the <code class="language-plaintext
highlighter-rouge">http-method</code> attribute of the <code
class="language-plaintext highlighter-rouge"><action></code> element, see
+<a href="../core-developers/action-configuration#http-methods">HTTP
Methods</a>.</p>
+
+<p>The restriction is enforced by the <code class="language-plaintext
highlighter-rouge">httpMethod</code> interceptor, which is part of <code
class="language-plaintext highlighter-rouge">basicStack</code>, <code
class="language-plaintext highlighter-rouge">defaultStack</code>,
+<code class="language-plaintext
highlighter-rouge">paramsPrepareParamsStack</code> and the stacks built on
them. If you define your own interceptor stack, make sure it includes <code
class="language-plaintext highlighter-rouge">httpMethod</code>, otherwise the
restriction is not enforced.</p>
+
+<p>Where the annotation has to be placed depends on the version:</p>
+
+<table>
+ <thead>
+ <tr>
+ <th>Struts version</th>
+ <th>What is enforced</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>7.5.0 and later</td>
+ <td>An annotation on the action class or on the invoked method, the
default method included, and an annotation inherited from a parent class or an
interface. The default stacks of the REST and Bean Validation plugins enforce
the restrictions as well.</td>
+ </tr>
+ <tr>
+ <td>7.0.0 - 7.4.0, 6.2.0 - 6.13.0</td>
+ <td>An annotation on the action class. An annotation on the action’s
default method is <strong>not</strong> enforced when the action mapping does
not name the method, see <a
href="https://cwiki.apache.org/confluence/display/WW/S2-088">S2-088</a>. The
default stacks of the REST and Bean Validation plugins do not enforce the
restrictions.</td>
+ </tr>
+ <tr>
+ <td>6.9.0 only</td>
+ <td>In addition to the row above, an annotation declared only on the
action class is <strong>not</strong> enforced when the action configuration
names the method to invoke, see <a
href="https://cwiki.apache.org/confluence/display/WW/S2-079">S2-079</a>.
Upgrade to Struts 6.10.0 at least.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>The 6.x line does not carry the S2-088 fix. If you stay on 6.x, or on a 7.x
release before 7.5.0, declare the restriction
+on the action class instead of on the method. On Struts 6.9.0, which is also
affected by S2-079, declare it on both
+the action class and the invoked method, or upgrade to Struts 6.10.0 at least.
From Struts 6.9.0 and 7.2.1 a mapping that names the method explicitly
+with the <code class="language-plaintext highlighter-rouge">method</code>
attribute enforces a method-level annotation as well.</p>
+
<h3 id="never-expose-jsp-files-directly">Never expose JSP files directly</h3>
<p>You must always hide JSP file behind an action, you cannot allow for direct
access to the JSP files as this can leads
@@ -281,6 +333,8 @@ to our <code class="language-plaintext
highlighter-rouge">struts.xml</code> for
<span class="nt"></Configuration></span>
</code></pre></div></div>
+<p>The <code class="language-plaintext
highlighter-rouge">com.opensymphony.xwork2</code> logger is needed on Struts
6.x only, the package no longer exists in Struts 7.</p>
+
<h3 id="use-utf-8-encoding">Use UTF-8 encoding</h3>
<p>Always use <code class="language-plaintext highlighter-rouge">UTF-8</code>
encoding when building an application with the Apache Struts 2, when using JSPs
please add the following
@@ -356,6 +410,14 @@ the <a href="#allowlist-capability">auto-allowlisting
capability</a>, which is a
in any way, so it proves a useful transitioning option for applications that
wish to enable the OGNL allowlist as soon
as possible.</p>
+<p>The annotation is required for values bound from a request. Values copied
from one action to the next by
+the <a
href="../core-developers/chaining-interceptor#parameter-authorization">Chaining
Interceptor</a> are not checked against it
+by default. Since Struts 7.2.0 you can set <code class="language-plaintext
highlighter-rouge">struts.chaining.requireAnnotations=true</code> to apply the
same rule there;
+the option only has an effect when <code class="language-plaintext
highlighter-rouge">struts.parameters.requireAnnotations</code> is enabled too,
and since Struts 7.5.0 it
+also covers values the <a href="../core-developers/alias-interceptor">Alias
Interceptor</a> copies from the value stack.
+On earlier releases, including 6.x, chained values are not checked against the
annotation. The <a
href="../core-developers/struts-parameter-annotation">StrutsParameter
Annotation</a>
+page lists every place where the annotation is checked.</p>
+
<h3 id="do-not-define-setters-when-not-needed">Do not define setters when not
needed</h3>
<blockquote>
@@ -383,6 +445,13 @@ dangerous and should be avoided. See example below,
assuming that an action impl
<p><strong>Never use value of incoming request parameter as part of your
localization logic.</strong></p>
+<p>The same care applies to messages that carry a submitted value. With the <a
href="../plugins/bean-validation/">Bean Validation Plugin</a>,
+before Struts 7.5.0 and 6.13.0, a validation message that places the submitted
value into its text could be evaluated
+as an expression instead of being shown as text (on Struts 7 only when the
OGNL allowlist is disabled), see
+<a href="https://cwiki.apache.org/confluence/display/WW/S2-081">S2-081</a>.
+Upgrade, or give every validation constraint whose message includes the
validated value an explicit message key and
+provide the text for that key in the application’s message resources.</p>
+
<h3
id="do-not-use-incoming-untrusted-user-input-in-forced-expression-evaluation">Do
not use incoming, untrusted user input in forced expression evaluation</h3>
<p>You can use a forced expression evalaution in many tags’ attributes by
using <code class="language-plaintext highlighter-rouge">%{...}</code> syntax.
This is a very powerful option
@@ -398,6 +467,22 @@ Never use a raw <code class="language-plaintext
highlighter-rouge">${}</code> EL
<p>The safest option is to use Struts Tags instead.</p>
+<p>The tags escape the values they write by default. Do not switch the
escaping off for a value that can come from
+a request:</p>
+
+<ul>
+ <li><code class="language-plaintext
highlighter-rouge">escapeHtml="false"</code> on the <code
class="language-plaintext highlighter-rouge"><s:property></code> tag
writes the value as it is,</li>
+ <li>the body of the <code class="language-plaintext
highlighter-rouge"><s:a></code>, <code class="language-plaintext
highlighter-rouge"><s:submit></code> and <code class="language-plaintext
highlighter-rouge"><s:component></code> tags is written as markup unless
<code class="language-plaintext highlighter-rouge">escapeHtmlBody</code>
+is set to <code class="language-plaintext highlighter-rouge">true</code>, on
the tag or globally with <code class="language-plaintext
highlighter-rouge">struts.ui.escapeHtmlBody</code>, see
+<a href="../tag-developers/tag-syntax#escaping-body-of-a-tag">Escaping body of
a tag</a>.</li>
+</ul>
+
+<p>Two defects in the escaping applied by the tags were fixed in Struts 7.5.0
and 6.13.0: additional tag attributes
+rendered by the <a href="../plugins/javatemplates/">Javatemplates Plugin</a>
+(<a href="https://cwiki.apache.org/confluence/display/WW/S2-083">S2-083</a>)
and the <code class="language-plaintext highlighter-rouge">doubleselect</code>
tag used with
+the <code class="language-plaintext highlighter-rouge">doubleMultiple</code>
attribute (<a
href="https://cwiki.apache.org/confluence/display/WW/S2-087">S2-087</a>). Each
bulletin
+describes a workaround for applications that cannot upgrade yet.</p>
+
<h3 id="define-custom-error-pages">Define custom error pages</h3>
<p>As mentioned in <a
href="https://cwiki.apache.org/confluence/display/WW/S2-006">S2-006</a> it’s a
good practicse to define your own
@@ -453,13 +538,91 @@ from <code class="language-plaintext
highlighter-rouge">save()</code> to <code c
<h3 id="accepted--excluded-patterns">Accepted / Excluded Patterns</h3>
-<p>As from version 2.3.20 the framework provides two new interfaces which are
used to accept / exclude param names
+<p>The framework provides two interfaces which are used to accept / exclude
param names
and values - <a
href="../maven/struts2-core/apidocs/org/apache/struts2/security/AcceptedPatternsChecker">AcceptedPatternsChecker</a>
and <a
href="../maven/struts2-core/apidocs/org/apache/struts2/security/ExcludedPatternsChecker">ExcludedPatternsChecker</a>
with default implementations. These two interfaces are used by the <a
href="../core-developers/parameters-interceptor">Parameters Interceptor</a>
and <a href="../core-developers/cookie-interceptor">Cookie Interceptor</a> to
check if param can be accepted or must be excluded.
If you were using <code class="language-plaintext
highlighter-rouge">excludeParams</code> previously please compare patterns used
by you with these provided by the framework in default implementation.</p>
+<h4 id="parameter-node-guard">Parameter node guard</h4>
+
+<blockquote>
+ <p>Note: since Struts 7.6.0.</p>
+</blockquote>
+
+<p>The accepted and excluded patterns check the text of a parameter or cookie
name. Once a name is accepted, the framework
+parses it as an OGNL expression and checks the parsed expression too, before
any part of it is evaluated: every node
+has to be allowed by an <code class="language-plaintext
highlighter-rouge">org.apache.struts2.ognl.ParameterNodeGuard</code>. A name
with a node the guard refuses is not
+set on the value stack. The refusal is logged at debug level; when <code
class="language-plaintext highlighter-rouge">devMode</code> is on it is
reported like any other
+parameter error, and for a cookie the exception propagates from the
interceptor.</p>
+
+<p>The default guard, <code class="language-plaintext
highlighter-rouge">StrutsParameterNodeGuard</code>, admits the property paths
that the default accepted pattern produces:</p>
+
+<table>
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Parsed as</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code class="language-plaintext highlighter-rouge">name</code></td>
+ <td><code class="language-plaintext
highlighter-rouge">ASTProperty</code> with an <code class="language-plaintext
highlighter-rouge">ASTConst</code> child</td>
+ </tr>
+ <tr>
+ <td><code class="language-plaintext highlighter-rouge">user.name</code>,
<code class="language-plaintext highlighter-rouge">list[0]</code>, <code
class="language-plaintext highlighter-rouge">map['key']</code></td>
+ <td>an <code class="language-plaintext
highlighter-rouge">ASTChain</code> of such properties</td>
+ </tr>
+ <tr>
+ <td><code class="language-plaintext highlighter-rouge">users(1)</code>,
<code class="language-plaintext highlighter-rouge">users('key')</code></td>
+ <td><code class="language-plaintext highlighter-rouge">ASTMethod</code>
with exactly one <code class="language-plaintext
highlighter-rouge">ASTConst</code> child</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>Any other node, such as a variable reference (<code
class="language-plaintext highlighter-rouge">#foo</code>), a non-constant index
(<code class="language-plaintext highlighter-rouge">list[a]</code>), a static
member, a
+constructor or a method with no argument or several, is refused.</p>
+
+<p>Names accepted by the default patterns are unaffected. An application that
widens the accepted names with
+<code class="language-plaintext
highlighter-rouge">struts.override.acceptedPatterns</code> or <code
class="language-plaintext
highlighter-rouge">struts.additional.acceptedPatterns</code> to admit other
expression shapes has to
+supply a guard that admits them too. Extending the default guard keeps its
rules and adds one:</p>
+
+<div class="language-java highlighter-rouge"><div class="highlight"><pre
class="highlight"><code><span class="kd">public</span> <span
class="kd">class</span> <span class="nc">TwoIndexMethodGuard</span> <span
class="kd">extends</span> <span class="nc">StrutsParameterNodeGuard</span>
<span class="o">{</span>
+
+ <span class="nd">@Override</span>
+ <span class="kd">public</span> <span class="kt">boolean</span> <span
class="nf">isAllowed</span><span class="o">(</span><span class="nc">Node</span>
<span class="n">node</span><span class="o">)</span> <span class="o">{</span>
+ <span class="k">if</span> <span class="o">(</span><span
class="n">node</span> <span class="k">instanceof</span> <span
class="nc">ASTMethod</span> <span class="o">&&</span> <span
class="n">node</span><span class="o">.</span><span
class="na">jjtGetNumChildren</span><span class="o">()</span> <span
class="o">==</span> <span class="mi">2</span><span class="o">)</span> <span
class="o">{</span>
+ <span class="k">return</span> <span class="n">node</span><span
class="o">.</span><span class="na">jjtGetChild</span><span
class="o">(</span><span class="mi">0</span><span class="o">)</span> <span
class="k">instanceof</span> <span class="nc">ASTConst</span> <span
class="o">&&</span> <span class="n">node</span><span
class="o">.</span><span class="na">jjtGetChild</span><span
class="o">(</span><span class="mi">1</span><span class="o">)</span> <span
class="k">instanceof</s [...]
+ <span class="o">}</span>
+ <span class="k">return</span> <span class="kd">super</span><span
class="o">.</span><span class="na">isAllowed</span><span
class="o">(</span><span class="n">node</span><span class="o">);</span>
+ <span class="o">}</span>
+<span class="o">}</span>
+</code></pre></div></div>
+
+<p>Set the <code class="language-plaintext
highlighter-rouge">struts.ognl.parameterNodeGuard</code> constant to the class
name:</p>
+
+<div class="language-xml highlighter-rouge"><div class="highlight"><pre
class="highlight"><code><span class="nt"><constant</span> <span
class="na">name=</span><span class="s">"struts.ognl.parameterNodeGuard"</span>
<span class="na">value=</span><span
class="s">"com.example.TwoIndexMethodGuard"</span><span class="nt">/></span>
+</code></pre></div></div>
+
+<p>or declare a bean and refer to it by name:</p>
+
+<div class="language-xml highlighter-rouge"><div class="highlight"><pre
class="highlight"><code><span class="nt"><bean</span> <span
class="na">type=</span><span
class="s">"org.apache.struts2.ognl.ParameterNodeGuard"</span> <span
class="na">name=</span><span class="s">"twoIndexMethod"</span> <span
class="na">class=</span><span
class="s">"com.example.TwoIndexMethodGuard"</span><span class="nt">/></span>
+<span class="nt"><constant</span> <span class="na">name=</span><span
class="s">"struts.ognl.parameterNodeGuard"</span> <span
class="na">value=</span><span class="s">"twoIndexMethod"</span><span
class="nt">/></span>
+</code></pre></div></div>
+
+<p>The guard is asked about every node of the parsed name, children included,
so it only needs to judge one node at a
+time. A guard that implements <code class="language-plaintext
highlighter-rouge">ParameterNodeGuard</code> directly must therefore also allow
the <code class="language-plaintext highlighter-rouge">ASTChain</code> and
<code class="language-plaintext highlighter-rouge">ASTConst</code>
+nodes of the names it expects. It is a singleton and is called from many
threads, so it must decide from the node and its children only, never
+from the request or any other state that changes.</p>
+
+<p>This guard applies only to names bound from a request, through the <a
href="../core-developers/parameters-interceptor">Parameters Interceptor</a>,
+the <code class="language-plaintext
highlighter-rouge">ActionMappingParametersInterceptor</code> and the <a
href="../core-developers/cookie-interceptor">Cookie Interceptor</a>.
+Expressions in templates, results and validators are not affected by it. The
<a href="#struts-ognl-guard">Struts OGNL Guard</a>
+covers every evaluated expression, parameter names included: <code
class="language-plaintext
highlighter-rouge">struts.ognl.excludedNodeTypes</code> and
+<code class="language-plaintext
highlighter-rouge">struts.ognl.nodeGuard</code> still apply to them, and the
parameter node guard is checked on top.</p>
+
<h3 id="strict-method-invocation">Strict Method Invocation</h3>
<p>This mechanism was introduced in version 2.5. It allows control what
methods can be accessed with the bang “!” operator
@@ -483,8 +646,23 @@ can be enabled for all endpoints of the application or the
endpoints that are me
can be exempted from applying the policy. Read more about Fetch Metadata and
resource isolation <a href="https://web.dev/fetch-metadata/">here</a>.</p>
<p>This mechanism is implemented in Struts using the <a
href="../core-developers/fetch-metadata-interceptor">FetchMetadata
Interceptor</a>.
- Refer to the documentation for <a
href="../core-developers/fetch-metadata-interceptor">FetchMetadata
Interceptor</a>
- instructions on how to enable Fetch Metadata.</p>
+The interceptor is part of the <code class="language-plaintext
highlighter-rouge">defaultStack</code> and, since Struts 7.4.0 and 6.12.0, of
the REST plugin’s
+<code class="language-plaintext highlighter-rouge">restDefaultStack</code>.
The <code class="language-plaintext highlighter-rouge">basicStack</code> and
<code class="language-plaintext
highlighter-rouge">paramsPrepareParamsStack</code> do not include it; if you
use one of them or define
+your own interceptor stack, add it there.</p>
+
+<p>Releases before Struts 7.5.0 and 6.13.0 accepted some cross-site requests
the policy rejects, see
+<a href="https://cwiki.apache.org/confluence/display/WW/S2-080">S2-080</a>.
The fixed releases reject them with a <code class="language-plaintext
highlighter-rouge">403</code> response,
+which also affects applications that legitimately receive cross-site form
submissions, for example from a single
+sign-on provider or a payment gateway. Exempt such endpoints as described in
+<a
href="../core-developers/fetch-metadata-interceptor#cross-site-form-posts">Cross-site
form posts</a>.</p>
+
+<p>Requests without a <code class="language-plaintext
highlighter-rouge">Sec-Fetch-Site</code> header are always accepted, so do not
rely on Fetch Metadata alone to protect
+state-changing actions. The <a
href="../core-developers/token-interceptor">Token Interceptor</a> and
+the <a href="../core-developers/token-session-interceptor">Token Session
Interceptor</a> check a token issued by the application.
+When an action combines one of them with the <a
href="../core-developers/execute-and-wait-interceptor">Execute and Wait
Interceptor</a>,
+declare the token interceptor before it and submit to the action only from
pages that carry a token. Releases before
+Struts 7.5.0 and 6.13.0 need this ordering to keep the token check effective,
see
+<a href="https://cwiki.apache.org/confluence/display/WW/S2-082">S2-082</a>.</p>
<h3 id="cross-origin-isolation-with-coop-and-coep">Cross Origin Isolation with
COOP and COEP</h3>
@@ -516,6 +694,110 @@ Cross-Origin-Opener-Policy: same-origin;
<p>COOP and COEP are implemented in Struts using <a
href="../core-developers/coop-interceptor">CoopInterceptor</a>
and <a href="../core-developers/coep-interceptor">CoepInterceptor</a>.</p>
+<h3 id="limit-what-a-single-request-can-consume">Limit what a single request
can consume</h3>
+
+<p>Limit the size of a request body ahead of the application, in the reverse
proxy or the servlet container, and set
+the limit as low as your endpoints allow. This bounds every request before the
framework reads it and is
+the mitigation recommended for releases that read a request body without a
bound, see
+<a href="https://cwiki.apache.org/confluence/display/WW/S2-072">S2-072</a>,
+<a href="https://cwiki.apache.org/confluence/display/WW/S2-073">S2-073</a> and
+<a href="https://cwiki.apache.org/confluence/display/WW/S2-077">S2-077</a>.</p>
+
+<p>Inside the framework the following limits apply. Raise a limit only for a
documented need and only as far as needed.</p>
+
+<table>
+ <thead>
+ <tr>
+ <th>Setting</th>
+ <th>Default</th>
+ <th>Bounds</th>
+ <th>Read more</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code class="language-plaintext
highlighter-rouge">struts.multipart.maxSize</code>, <code
class="language-plaintext highlighter-rouge">struts.multipart.maxFiles</code>,
<code class="language-plaintext
highlighter-rouge">struts.multipart.maxFileSize</code>, <code
class="language-plaintext
highlighter-rouge">struts.multipart.maxStringLength</code>, <code
class="language-plaintext
highlighter-rouge">struts.multipart.maxParameterCount</code></td>
+ <td>2 MB, 256, not set, 4096, 256</td>
+ <td>Size of a multipart request, number of files, size of one file,
length of a normal form field, number of normal form fields (since Struts
7.3.0)</td>
+ <td><a
href="../core-developers/action-file-upload#advanced-configuration">Action File
Upload</a></td>
+ </tr>
+ <tr>
+ <td><code class="language-plaintext
highlighter-rouge">struts.json.maxLength</code>, <code
class="language-plaintext highlighter-rouge">struts.json.maxElements</code>,
<code class="language-plaintext
highlighter-rouge">struts.json.maxDepth</code></td>
+ <td>2 MB, 10000, 64</td>
+ <td>JSON request body read by the JSON plugin. <code
class="language-plaintext highlighter-rouge">maxLength</code> bounds the read
since Struts 7.3.0 and 6.11.0</td>
+ <td><a href="../plugins/json/#deserialization-limits">JSON
Plugin</a></td>
+ </tr>
+ <tr>
+ <td><code class="language-plaintext
highlighter-rouge">struts.rest.content.maxLength</code></td>
+ <td>2 MB</td>
+ <td>Request body read by the REST plugin, since Struts 7.4.0 and
6.12.0</td>
+ <td><a href="../plugins/rest/#request-body-size-limit">REST
Plugin</a></td>
+ </tr>
+ <tr>
+ <td><code class="language-plaintext
highlighter-rouge">struts.csp.report.maxSize</code></td>
+ <td>8192</td>
+ <td>Content Security Policy violation report, since Struts 7.3.0 and
6.11.0</td>
+ <td><a href="../core-developers/csp-interceptor#report-action">CSP
Interceptor</a></td>
+ </tr>
+ <tr>
+ <td><code class="language-plaintext
highlighter-rouge">struts.i18n.cacheMaxSize</code></td>
+ <td>10000</td>
+ <td>Entries of each localized-text cache, since Struts 7.3.0 and
6.11.0</td>
+ <td><a
href="../core-developers/localization#tuning-the-localized-text-caches">Localization</a></td>
+ </tr>
+ <tr>
+ <td><code class="language-plaintext
highlighter-rouge">struts.ognl.expressionMaxLength</code></td>
+ <td>256</td>
+ <td>Length of an evaluated OGNL expression</td>
+ <td><a
href="#apply-a-maximum-allowed-length-on-ognl-expressions">below</a></td>
+ </tr>
+ </tbody>
+</table>
+
+<p>Two more recommendations:</p>
+
+<ul>
+ <li>When <code class="language-plaintext
highlighter-rouge">struts.locale</code> is not set, the locale used for message
lookups is taken from the request. Either configure
+a fixed locale with <code class="language-plaintext
highlighter-rouge">struts.locale</code>, or set <code class="language-plaintext
highlighter-rouge">struts.locale.validateRequestLocale=true</code> (since
Struts 7.3.0 and 6.11.0,
+disabled by default) to restrict request-derived locales to the ones available
in the runtime, see
+<a
href="../core-developers/localization#validating-the-request-locale">Validating
the request locale</a> and
+<a
href="https://cwiki.apache.org/confluence/display/WW/S2-074">S2-074</a>.</li>
+ <li>A request parameter bound to a <code class="language-plaintext
highlighter-rouge">java.math.BigDecimal</code> property and rendered by a tag
or passed into a localized
+message could make the framework build a string many orders of magnitude
larger than the request. This is fixed in Struts 7.5.0 and
+6.13.0, see <a
href="https://cwiki.apache.org/confluence/display/WW/S2-076">S2-076</a>,
+<a href="https://cwiki.apache.org/confluence/display/WW/S2-084">S2-084</a> and
+<a href="https://cwiki.apache.org/confluence/display/WW/S2-085">S2-085</a>. On
an earlier release register
+a <a href="../core-developers/type-conversion">type converter</a> for <code
class="language-plaintext highlighter-rouge">java.math.BigDecimal</code> that
rejects values whose scale or
+exponent exceeds what the application needs when they are bound, as the
bulletins describe. This does not cover
+values received through the JSON plugin’s request body.</li>
+</ul>
+
+<h3 id="handle-uploaded-files-as-untrusted-input">Handle uploaded files as
untrusted input</h3>
+
+<p>Use the <a href="../core-developers/action-file-upload">Action File
Upload</a> support and keep its limits on the number and size
+of files as low as the application allows. Restrict the accepted
+<a href="../core-developers/action-file-upload#file-types">file types</a> to
the ones the application expects.</p>
+
+<p>The file name and the content type of an upload are supplied by the client.
Never use the submitted file name to build
+the path under which the file is stored, generate the name on the server
instead, and do not store uploads in
+a location from which the container serves or executes content.</p>
+
+<h3 id="leave-legacy-features-disabled">Leave legacy features disabled</h3>
+
+<p>Some features exist only for backward compatibility and are disabled by
default, or deprecated. Do not enable them
+in a new application and plan to move away from them in an existing one:</p>
+
+<ul>
+ <li>the legacy <code class="language-plaintext
highlighter-rouge">restful</code> and <code class="language-plaintext
highlighter-rouge">restful2</code> action mappers, deprecated since Struts
7.4.0 and 6.12.0, see
+<a href="../core-developers/restful-action-mapper">RestfulActionMapper</a>;
for the <code class="language-plaintext highlighter-rouge">restful</code>
mapper see also
+<a href="https://cwiki.apache.org/confluence/display/WW/S2-075">S2-075</a>.
Use the default action mapper or
+the <a href="../plugins/rest/">REST Plugin</a> instead,</li>
+ <li>the <code class="language-plaintext highlighter-rouge">action:</code>
prefix, controlled by <code class="language-plaintext
highlighter-rouge">struts.mapper.action.prefix.enabled</code> (default <code
class="language-plaintext highlighter-rouge">false</code>), see
+<a href="../core-developers/action-mapper#action-prefix">Action
prefix</a>,</li>
+ <li><a
href="../core-developers/action-configuration#dynamic-method-invocation">Dynamic
Method Invocation</a>, controlled by
+<code class="language-plaintext
highlighter-rouge">struts.enable.DynamicMethodInvocation</code> (default <code
class="language-plaintext highlighter-rouge">false</code>).</li>
+</ul>
+
<h2
id="proactively-protecting-against-ognl-expression-injections-attacks">Proactively
protecting against OGNL Expression Injections attacks</h2>
<p>The framework has a history of critical security bugs, many tied to its use
of OGNL technology; Due to its ability to
@@ -528,15 +810,6 @@ framework with a number of additional security
capabilities, some of which need
to comprehensively test your app UI and functionalities with these enabled.</p>
</blockquote>
-<h3 id="run-ognl-expressions-inside-sandbox">Run OGNL expressions inside
sandbox</h3>
-
-<p>You can do this simply via adding <code class="language-plaintext
highlighter-rouge">-Dognl.security.manager</code> to JVM arguments. OGNL
thereupon utilizes Java Security
-Manager to run OGNL expressions (which includes your actions either!) inside a
sandbox with no permission. It is worth
-noting that it affects only OGNL expression execution and thereafter OGNL
reverts Java Security Manager to its previous
-state.</p>
-
-<p>Note: This feature does not work with JDK 21 and above.</p>
-
<h3 id="restricting-access-to-the-struts-context-actioncontext">Restricting
access to the Struts Context (ActionContext)</h3>
<p>The Struts ActionContext is a core construct of the Struts framework. It is
shared and manipulated throughout the
@@ -799,6 +1072,17 @@ parents only, never from the request, the user or any
other state that changes.<
blocking both raw OGNL expressions and parsed syntax trees. They are
deprecated since Struts 7.6.0 and will be removed
in Struts 8.0.0; they keep working until then.</p>
+<h3 id="run-ognl-expressions-inside-sandbox">Run OGNL expressions inside
sandbox</h3>
+
+<p>This is a legacy option. It relies on the Java Security Manager, which is
deprecated for removal since JDK 17, and
+it does not work with JDK 21 and above. Prefer the <a
href="#allowlist-capability">allowlist</a> and
+the <a href="#struts-ognl-guard">Struts OGNL Guard</a> described above.</p>
+
+<p>You can enable it by adding <code class="language-plaintext
highlighter-rouge">-Dognl.security.manager</code> to JVM arguments. OGNL
thereupon utilizes Java Security
+Manager to run OGNL expressions (which includes your actions either!) inside a
sandbox with no permission. It is worth
+noting that it affects only OGNL expression execution and thereafter OGNL
reverts Java Security Manager to its previous
+state.</p>
+
</section>
</article>