[
https://issues.apache.org/jira/browse/WW-5846?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lukasz Lenart updated WW-5846:
------------------------------
Description:
Spun off from [WW-5754|https://issues.apache.org/jira/browse/WW-5754].
{{FetchMetadataInterceptor}}, {{CoopInterceptor}} and {{CoepInterceptor}} all
compare each {{exemptedPaths}} entry with the web application's context path:
{code:java}String contextPath = request.getContextPath();
if (exemptedPaths.contains(contextPath)) {
return invocation.invoke();
}
{code}
The context path is the same for every request to the application, so since
[WW-5083|https://issues.apache.org/jira/browse/WW-5083] (6.0.0):
* An entry naming an action or URL path, for example {{/saml/acs}}, never
matches and silently has no effect.
* An entry equal to the context path, for example {{/myapp}}, matches every
request and disables the interceptor for the whole application.
The tests mask this: {{struts-testing.xml}} configures action-like entries
({{/fetchMetadataExempted}}), and {{FetchMetadataInterceptorTest}} sets
{{request.setContextPath("/fetchMetadataExempted")}} to produce a match.
All three interceptors are in {{defaultStack}}. Since WW-5753 / WW-5754 the
Fetch Metadata policy rejects cross-site POST navigations (SAML/OIDC
{{form_post}}, payment-gateway returns), which makes a working per-path
exemption more important.
h2. Proposed fix
* Match entries in all three interceptors against the request path inside the
application, {{RequestUtils.getServletPath(request)}} (servlet path plus path
info, as used for action mapping since WW-5842).
* Use the same value in the log messages, which currently log the context path.
* Rewrite the exemption tests to set the servlet path / path info and leave the
context path alone; add a case where the context path equals an entry and the
request path does not.
h2. Compatibility
This changes behaviour in both directions and needs a Version Notes / Migration
Guide entry:
* Applications that listed their context path to disable an interceptor
app-wide lose that. The replacement is the interceptor's {{disabled}}
parameter, e.g. {{<param name="fetchMetadata.disabled">true</param>}}.
* Entries that never matched will start exempting the paths they name. For COOP
/ COEP that means the headers are no longer sent on those paths.
The matching semantics (exact match vs. prefix/wildcard) are documented on the
Fetch Metadata, COOP and COEP interceptor pages.
was:
Spun off from [WW-5754|https://issues.apache.org/jira/browse/WW-5754].
{{FetchMetadataInterceptor}} compares each {{exemptedPaths}} entry with the web
application's context path:
{code:java}String contextPath = request.getContextPath();
if (exemptedPaths.contains(contextPath)) {
return invocation.invoke();
}
{code}
The context path is the same for every request to the application, so since
[WW-5083|https://issues.apache.org/jira/browse/WW-5083] (6.0.0):
* An entry naming an action or URL path, for example {{/saml/acs}}, never
matches and silently has no effect.
* An entry equal to the context path, for example {{/myapp}}, matches every
request and disables the interceptor for the whole application.
The tests mask this: {{struts-testing.xml}} configures action-like entries
({{/fetchMetadataExempted}}), and {{FetchMetadataInterceptorTest}} sets
{{request.setContextPath("/fetchMetadataExempted")}} to produce a match.
h2. Proposed fix
* Match entries against the request path inside the application (servlet path
plus path info), as the name {{exemptedPaths}} suggests.
* Use the same value in the rejection log message, which currently logs the
context path.
* Rewrite the exemption tests to set the servlet path / path info and leave the
context path alone; add a case where the context path equals an entry and the
request path does not.
h2. Compatibility
This changes behaviour in both directions and needs a Version Notes / Migration
Guide entry:
* Applications that listed their context path to disable the interceptor
app-wide will start receiving 403s for cross-site non-navigation requests. The
replacement is {{<param name="fetchMetadata.disabled">true</param>}}.
* Entries that never matched will start exempting the paths they name.
Decide whether entries are exact matches only or also support a prefix or
wildcard form, and document the chosen semantics on the Fetch Metadata
interceptor page.
> FetchMetadata, COOP and COEP interceptors match exemptedPaths against the
> context path instead of the request path
> ------------------------------------------------------------------------------------------------------------------
>
> Key: WW-5846
> URL: https://issues.apache.org/jira/browse/WW-5846
> Project: Struts 2
> Issue Type: Bug
> Components: Core
> Reporter: Lukasz Lenart
> Assignee: Lukasz Lenart
> Priority: Major
> Fix For: 6.13.0, 7.5.0
>
>
> Spun off from [WW-5754|https://issues.apache.org/jira/browse/WW-5754].
> {{FetchMetadataInterceptor}}, {{CoopInterceptor}} and {{CoepInterceptor}} all
> compare each {{exemptedPaths}} entry with the web application's context path:
> {code:java}String contextPath = request.getContextPath();
> if (exemptedPaths.contains(contextPath)) {
> return invocation.invoke();
> }
> {code}
> The context path is the same for every request to the application, so since
> [WW-5083|https://issues.apache.org/jira/browse/WW-5083] (6.0.0):
> * An entry naming an action or URL path, for example {{/saml/acs}}, never
> matches and silently has no effect.
> * An entry equal to the context path, for example {{/myapp}}, matches every
> request and disables the interceptor for the whole application.
> The tests mask this: {{struts-testing.xml}} configures action-like entries
> ({{/fetchMetadataExempted}}), and {{FetchMetadataInterceptorTest}} sets
> {{request.setContextPath("/fetchMetadataExempted")}} to produce a match.
> All three interceptors are in {{defaultStack}}. Since WW-5753 / WW-5754 the
> Fetch Metadata policy rejects cross-site POST navigations (SAML/OIDC
> {{form_post}}, payment-gateway returns), which makes a working per-path
> exemption more important.
> h2. Proposed fix
> * Match entries in all three interceptors against the request path inside the
> application, {{RequestUtils.getServletPath(request)}} (servlet path plus path
> info, as used for action mapping since WW-5842).
> * Use the same value in the log messages, which currently log the context
> path.
> * Rewrite the exemption tests to set the servlet path / path info and leave
> the context path alone; add a case where the context path equals an entry and
> the request path does not.
> h2. Compatibility
> This changes behaviour in both directions and needs a Version Notes /
> Migration Guide entry:
> * Applications that listed their context path to disable an interceptor
> app-wide lose that. The replacement is the interceptor's {{disabled}}
> parameter, e.g. {{<param name="fetchMetadata.disabled">true</param>}}.
> * Entries that never matched will start exempting the paths they name. For
> COOP / COEP that means the headers are no longer sent on those paths.
> The matching semantics (exact match vs. prefix/wildcard) are documented on
> the Fetch Metadata, COOP and COEP interceptor pages.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)