[
https://issues.apache.org/jira/browse/WW-5846?focusedWorklogId=1053272&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1053272
]
ASF GitHub Bot logged work on WW-5846:
--------------------------------------
Author: ASF GitHub Bot
Created on: 07/Nov/26 17:45
Start Date: 07/Nov/26 17:45
Worklog Time Spent: 10m
Work Description: lukaszlenart opened a new pull request, #2125:
URL: https://github.com/apache/struts/pull/2125
Backport of [PR #2124](https://github.com/apache/struts/pull/2124) to
`support/struts-6-x-x` for 6.13.0. Conflicts were import-only
(`com.opensymphony.xwork2` / `javax.servlet` on 6.x).
Fixes [WW-5846](https://issues.apache.org/jira/browse/WW-5846)
## Summary
`FetchMetadataInterceptor`, `CoopInterceptor` and `CoepInterceptor` compared
each `exemptedPaths` entry with `request.getContextPath()`, which is the same
for every request. An entry naming a path never matched; an entry equal to the
context path exempted the whole application.
They now compare against `RequestUtils.getUri(request)`, the value
`DefaultActionMapper` uses since WW-5842: servlet path plus path info, or the
included servlet path during an include dispatch.
- Matching is **exact**, extension included: `/saml/acs.action`, not
`/saml/acs`. Apps serving an action under several extensions list each form; an
unlisted form stays protected. No prefix or wildcard entries for now.
- The Fetch Metadata rejection log now names the request path — the exact
value to add to `exemptedPaths`.
- `CoopInterceptor.isExempted(String)` keeps its signature.
This gives applications affected by WW-5753 / WW-5754 (cross-site POST
navigations rejected: SAML/OIDC `form_post`, payment returns) a working
per-path opt-out alongside the per-action `<param
name="fetchMetadata.disabled">true</param>`.
## Breaking change
- An `exemptedPaths` entry equal to the context path no longer disables the
interceptor app-wide. Use the interceptor's `disabled` parameter instead.
- Entries naming a request path now take effect. For COOP / COEP that means
the headers are no longer sent on those paths.
Goes into the 7.5.0 / 6.13.0 Version Notes and Migration Guide; the
struts-site interceptor pages are updated in a separate PR.
## Test plan
- [x] New tests per interceptor: servlet-path match, path-info match,
context-path-only entry no longer exempts; Fetch Metadata also covers an
include dispatch
- [x] Existing exemption tests and `struts-testing.xml` fixtures rewritten
to set the servlet path (with `.action`) instead of faking a context path
- [x] `mvn test -DskipAssembly -pl
core,plugins/rest,plugins/bean-validation` — on `support/struts-6-x-x`: 2764 /
93 / 23 tests, 0 failures
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Issue Time Tracking
-------------------
Worklog Id: (was: 1053272)
Time Spent: 20m (was: 10m)
> 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
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> 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)