From 5539cf12f4b5fe3d52c02a2da615441e5b00b58f Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Sun, 20 Jun 2021 16:35:34 +0800 Subject: [PATCH] fix(security): freemarker SSTI vulnerability. (#1402) --- .../app/listener/freemarker/FreemarkerConfigAwareListener.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/run/halo/app/listener/freemarker/FreemarkerConfigAwareListener.java b/src/main/java/run/halo/app/listener/freemarker/FreemarkerConfigAwareListener.java index 3ebaaba02d..9c37775710 100644 --- a/src/main/java/run/halo/app/listener/freemarker/FreemarkerConfigAwareListener.java +++ b/src/main/java/run/halo/app/listener/freemarker/FreemarkerConfigAwareListener.java @@ -2,6 +2,7 @@ import static run.halo.app.model.support.HaloConst.OPTIONS_CACHE_KEY; +import freemarker.core.TemplateClassResolver; import freemarker.template.Configuration; import freemarker.template.TemplateModel; import freemarker.template.TemplateModelException; @@ -78,6 +79,7 @@ private Map freemarkerLayoutDirectives() { private void initFreemarkerConfig() throws TemplateModelException { configuration.setSharedVariable("layout", freemarkerLayoutDirectives()); + configuration.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER); } @EventListener