Skip to content
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ public void setFreemarkerConfiguration( Configuration freemarkerConfiguration )
{
}
this.freemarkerConfiguration.setLocalizedLookup( false );

// Security fix: Block dangerous class instantiation via ?new operator to prevent SSTI attacks
try
{
this.freemarkerConfiguration.setSetting( Configuration.NEW_BUILTIN_CLASS_RESOLVER_KEY, "safer" );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this constant exists in any freemarker version? I - think you should catch Exception instead of catching TemplateException

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angelozerr Thanks for the question!
Configuration.NEW_BUILTIN_CLASS_RESOLVER_KEY was introduced in FreeMarker 2.3.30, so it is supported in the FreeMarker version currently used in XDocReport (2.3.32).

}
catch ( TemplateException e )
{
// Ignore configuration errors to maintain compatibility
}
}

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