Repository navigation
fix(springmvc): restore classpath: prefix support in path traversal check - #1200
Open
princejain756 wants to merge 1 commit into
Open
princejain756 wants to merge 1 commit into
princejain756 wants to merge 1 commit into
Conversation
This branch has not been deployed
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 #1199
The GHSA-pvrx-3g7m-fpgv containment check in
SpringTemplateLoader.getResourcerejects legitimateclasspath:prefixed templates on 4.5.5. Two failure modes, both reported in the issue:new File("/templates/"), a filesystem-root path, while the resolved resource lives under.../target/classes/templates/. ThestartsWithcheck could never succeed.url.getPath()returns the fullnested:/jar:path including the archive location, compared against/templates/prefix. Same guaranteed failure.Changes:
loader.getResource(getPrefix())), soclasspath:/templates/maps to the real classpath directory instead of the filesystem root. When the prefix has no file-resolvable resource, the previous literal-strip behavior is kept as fallback, sofile:prefixes keep identical semantics.!, against the normalized prefix viacontains. The classpath URL namespace cannot produce percent-decoded traversal anyway (the class loader does not decode resource names), so containment stays meaningful while legitimate entries pass.Tests: two new cases in SpringTemplateLoaderTest, both red on master and green here:
classpath:/templates/resolving an exploded classpath resource via a real DefaultResourceLoader, and a mockedjar:file:entry URL. The existing traversal, fragment, query, and percent-encoding tests all still pass (10/10 in the module).