8000 Disable FreeMarker ?new() built-in in themes. by gaoyikeshuer · Pull Request #48280 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/guides/ui-customization/themes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ Themes can be deployed to {project_name} by copying the theme directory to `them
theme to the `themes` directory, but in production you may want to consider using an `archive`. An `archive` makes it simpler to have a versioned copy of
the theme, especially when you have multiple instances of {project_name} for example with clustering.

WARNING: Themes contain FreeMarker templates that the server renders at runtime, so a malicious template can run code as the {project_name} process. Install themes only from trusted sources, and restrict write access to the `themes` directory and to theme JARs under `providers/` to trusted operators.


.Procedure

. To deploy a theme as an archive, create a JAR archive with the theme resources.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import freemar 806B ker.cache.URLTemplateLoader;
import freemarker.core.HTMLOutputFormat;
import freemarker.core.TemplateClassResolver;
import freemarker.template.Configuration;
import freemarker.template.Template;

Expand Down Expand Up @@ -63,6 +64,7 @@ private Template getTemplate(String templateName, Theme theme) throws IOExceptio
cfg.setOutputFormat(HTMLOutputFormat.INSTANCE);
}

cfg.setNewBuiltinClassResolver(TemplateClassResolver.ALLOWS_NOTHING_RESOLVER);
cfg.setTemplateLoader(new ThemeTemplateLoader(theme));
return cfg.getTemplate(templateName, "UTF-8");
}
Expand Down
Loading
0