Skip to content

[3.0.x] MYFACES-4761: Facelet path validation - #1046

Merged
volosied merged 8 commits into
apache:3.0.xfrom
volosied:facelet-path-validation-3.0.x
Aug 18, 2026
Merged

[3.0.x] MYFACES-4761: Facelet path validation#1046
volosied merged 8 commits into
apache:3.0.xfrom
volosied:facelet-path-validation-3.0.x

Conversation

@volosied

Copy link
Copy Markdown
Contributor

No description provided.

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.
@tandraschko

Copy link
Copy Markdown
Member

Please also create a issue for Tracking
And dont forget 4.0

@volosied volosied changed the title Facelet path validation 3.0.x [3.0.x] Facelet path validation Aug 18, 2026
@volosied
volosied force-pushed the facelet-path-validation-3.0.x branch from 68b1d98 to d5ac285 Compare August 18, 2026 14:35
@volosied
volosied merged commit 4021958 into apache:3.0.x Aug 18, 2026
1 check passed
@volosied volosied changed the title [3.0.x] Facelet path validation [3.0.x] MYFACES-4761: Facelet path validation Aug 18, 2026
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.

2 participants