[4.1.x] MYFACES-4761: Facelet path validation - #1043
Merged
Conversation
melloware
approved these changes
Aug 13, 2026
pnicolucci
reviewed
Aug 13, 2026
| // Path-validation helpers | ||
|
|
||
| private static final Set<String> BLOCKED_SCHEMES = new HashSet<>( | ||
| Arrays.asList("http", "https", "ftp", "ftps", "mailto", "tel", |
Contributor
There was a problem hiding this comment.
Would it be better to have an allowed scheme(s) rather than blocked?
Member
|
Please provide some unittests |
Strengthen resolveURL() with four layered guards to prevent unsafe Facelet resource resolution: 1. Scheme check — rejects remote/network URI schemes (http, https, ftp, etc.) using a fast colon-index scan; OSGi/container schemes (jar, wsjar, file, zip) are intentionally allowed. 2. Traversal guard — for relative paths, verifies the resolved URL remains within the application base (WAR/EAR root) to prevent directory traversal attacks. 3. WEB-INF XML guard (scaffolded, currently disabled) — isWebInfConfigFile() is in place to block XML config descriptors under WEB-INF/ if .xml is ever added as a Facelet suffix. 4. Extension/suffix check — rejects paths whose extension is not in the configured Facelet suffix set (jakarta.faces.FACELETS_SUFFIX / jakarta.faces.FACELETS_VIEW_MAPPINGS), cached after the first call. Also adds FINE-level logging at each rejection point and a log of the computed allowed-suffix set on first initialisation. UnitTest project stage bypasses guards 2-4 to allow tests that use synthetic paths not backed by a real WAR layout.
Add InvalidFileException (extends IOException) with a typed Reason enum to replace the generic MalformedURLException throws in resolveURL(). Reason values: DISALLOWED_SCHEME — blocked remote/network URI scheme PATH_TRAVERSAL — resolved URL escapes the application base INVALID_EXTENSION — extension not a configured Facelet suffix Callers can now catch InvalidFileException and inspect getReason() to programmatically distinguish between rejection causes without parsing exception messages.
volosied
force-pushed
the
facelet-path-validation
branch
from
August 17, 2026 18:58
b7f90a2 to
db5f058
Compare
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.
No description provided.