Skip to content

WW-5879 fix(convention): keep result lookups inside the configured result path - #2199

Open
g0w6y wants to merge 2 commits into
apache:mainfrom
g0w6y:ww5879-mine
Open

g0w6y wants to merge 2 commits into
apache:mainfrom
g0w6y:ww5879-mine

Conversation

@g0w6y

@g0w6y g0w6y commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes WW-5879

ConventionUnknownHandler built its resource lookup paths from the request namespace and action name without resolving dot segments, so a request such as /../../../a could make it probe resources outside the configured result path (struts.convention.result.path / @ResultPath).

Both lookups are fixed: handleUnknownAction (findResource) and handleUnknownResult (findResult). The path is now resolved with StaticContentLoader.Validator.canonicalisePath and skipped unless it stays under the trusted result root. The root is taken from conventionsService without the request-derived namespace appended, so .. segments cannot consume part of it and still pass the check.

findResource(Map, String...) and findResult(String, ...) are protected, so their signatures gain a requiredRoot argument. Nothing else in the repository overrides them. canonicalize(String) is kept as deprecated for source compatibility.

Tests: one regression test per lookup, plus one for a result root containing // or ./ segments (namespace and action name for handleUnknownAction, action name and result code for handleUnknownResult). Convention plugin: 106 tests, 0 failures.

I reported this on Nov 1 with a patch and, per Łukasz's reply, am opening this PR from it. #2193 covers the same code; whichever is preferred is fine.

g0w6y added 2 commits December 5, 2026 14:15
…sult path

ConventionUnknownHandler built resource lookup paths from the request
namespace and action name without resolving dot segments, so a crafted
request could make the handler probe resources outside the configured
result root. Resolve dot segments and reject any path that does not stay
under the trusted result root, for both the unknown-action and the
unknown-result lookups.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant