Skip to content

fix(theme): exclude JSP and similar server-side files from static themes - #3466

Merged
marevol merged 1 commit into
mainfrom
fix/static-theme-exclude-jsp
Sep 23, 2026
Merged

marevol merged 1 commit into
mainfrom
fix/static-theme-exclude-jsp

Conversation

@marevol

@marevol marevol commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Why

A static theme is plain files (HTML, JS, CSS, images, JSON) served as they are. Nothing kept a theme archive from also carrying a .jsp file, though. Such a file was extracted with the rest of the theme, and the servlet container could then treat it as a JSP page rather than as a theme file.

What changes

  • StaticThemeInstaller refuses an archive that has a .jsp, .jspx or .jspf entry, with EXTRACT_FAILED, before anything is moved into the themes directory. This covers both the ZIP upload and the install from a Maven repository, which go through installZip.
  • StaticThemeFilter answers 404 for those extensions under /themes/, whatever the method and whichever theme is active. A file already on disk from an earlier install is therefore never handed to the JSP servlet. The check uses the servlet path and path info the container decoded, which is the path the container maps to a servlet.
  • Other theme files are unaffected. A plain file of a theme that is not active still passes through as before.

Verification

  • mvn test -Dtest=StaticThemeFilterTest,StaticThemeInstaller*Test,ThemeArtifactHelperTest,AdminThemeActionTest,StaticThemeResponderTest,BundledBootstrapThemeTest: 286 tests passed.
    • New installer tests cover x.jsp, sub/x.jspx, inc/x.jspf and X.JSP; nothing is left in the themes directory.
    • New filter tests cover GET/HEAD/POST, active and inactive themes, and an encoded or ;param request path.
  • Built the zip and uploaded a theme ZIP that contains a .jsp file:
    • Before: the upload succeeds and the file is extracted into the theme directory.
    • After: the upload is refused with "Server-side page not allowed in a static theme: x.jsp", and no theme directory is created. With a theme directory holding a .jsp file placed on disk directly, a request for that file under /themes/ returns 404. The theme's index.html, the bootstrap theme's assets and / are still served.

A static theme is plain files served as they are, but nothing kept a
theme archive from carrying a .jsp file. Such a file was extracted with
the rest of the theme, and the servlet container could then treat it as
a JSP page rather than as a theme file.

- StaticThemeInstaller refuses an archive with a .jsp, .jspx or .jspf
  entry (EXTRACT_FAILED), for both ZIP upload and the Maven repository
  install, before anything is moved into the themes directory.
- StaticThemeFilter answers 404 for those extensions under /themes/,
  for any method and whichever theme is active, so such a file already
  on disk is never handed to the JSP servlet. It checks the path the
  container decoded, which is the one the container maps to a servlet.
@marevol marevol added this to the 15.9.0 milestone Sep 23, 2026
@marevol marevol self-assigned this Sep 23, 2026
@marevol
marevol merged commit 4b655ce into main Sep 23, 2026
2 of 3 checks passed
marevol added a commit that referenced this pull request Sep 23, 2026
… command line (#3473)

The admin screen's theme installer refuses an archive carrying a .jsp,
.jspx or .jspf entry (#3466), but `fess-setup install theme` extracted
such an archive and installed it. Fess already answers 404 for those
extensions under /themes/, so this brings the command-line path in line
with the admin screen rather than closing an open hole.

- ThemeInstaller checks the extracted files in the staging directory,
  after the manifest check and before anything installed is moved aside,
  and fails with a message naming the offending file; the staging
  directory is removed and fess-setup exits non-zero.
- The extension list and the case-insensitive match mirror
  StaticThemeInstaller. The check is reimplemented in the setup package
  because fess-setup.jar runs with only the JDK on its class path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant