Skip to content

Commit b4d312f

Browse files
fix: SSTI freemarker
1 parent 4841df5 commit b4d312f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

template/fr.opensagres.xdocreport.template.freemarker/src/main/java/fr/opensagres/xdocreport/template/freemarker/FreemarkerTemplateEngine.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@ public void setFreemarkerConfiguration( Configuration freemarkerConfiguration )
197197
{
198198
}
199199
this.freemarkerConfiguration.setLocalizedLookup( false );
200+
201+
// Security fix: Block dangerous class instantiation via ?new operator to prevent SSTI attacks
202+
try
203+
{
204+
this.freemarkerConfiguration.setSetting( Configuration.NEW_BUILTIN_CLASS_RESOLVER_KEY, "safer" );
205+
}
206+
catch ( TemplateException e )
207+
{
208+
// Ignore configuration errors to maintain compatibility
209+
}
200210
}
201211

202212
public void extractFields( Reader reader, String entryName, FieldsExtractor extractor )

0 commit comments

Comments
 (0)