Repository navigation
Conversation
…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.
…ment check, trim docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes WW-5879
ConventionUnknownHandlerbuilt its resource lookup paths from the request namespace and action name without resolving dot segments, so a request such as/../../../acould make it probe resources outside the configured result path (struts.convention.result.path/@ResultPath).Both lookups are fixed:
handleUnknownAction(findResource) andhandleUnknownResult(findResult). The path is now resolved withStaticContentLoader.Validator.canonicalisePathand skipped unless it stays under the trusted result root. The root is taken fromconventionsServicewithout the request-derived namespace appended, so..segments cannot consume part of it and still pass the check.findResource(Map, String...)andfindResult(String, ...)are protected, so their signatures gain arequiredRootargument. 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 forhandleUnknownAction, action name and result code forhandleUnknownResult). 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.