VYPR
Critical severityOSV Advisory· Published Jan 20, 2026· Updated Jan 21, 2026

CVE-2025-64087

CVE-2025-64087

Description

A Server-Side Template Injection (SSTI) vulnerability in the FreeMarker component of opensagres XDocReport v1.0.0 to v2.1.0 allows attackers to execute arbitrary code via injecting crafted template expressions.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
fr.opensagres.xdocreport:fr.opensagres.xdocreport.template.freemarkerMaven
< 2.2.02.2.0

Affected products

1
  • Range: xdocreport-parent-1.0.5, xdocreport-parent-1.0.6, xdocreport-parent-2.0.0, …

Patches

1
3b35d105e5ae

Fix: Harden FreeMarker against SSTI (#705)

https://github.com/opensagres/xdocreportcuongnhNov 15, 2025via ghsa
2 files changed · +82 0
  • template/fr.opensagres.xdocreport.template.freemarker/src/main/java/fr/opensagres/xdocreport/template/freemarker/FreemarkerTemplateEngine.java+15 0 modified
    @@ -197,6 +197,21 @@ public void setFreemarkerConfiguration( Configuration freemarkerConfiguration )
             {
             }
             this.freemarkerConfiguration.setLocalizedLookup( false );
    +        
    +        // Security fix: Block dangerous class instantiation via ?new operator to prevent SSTI attacks
    +        // 
    +        // This setting prevents Server-Side Template Injection (SSTI) attacks where malicious users
    +        // By setting NEW_BUILTIN_CLASS_RESOLVER_KEY to "safer", FreeMarker will block instantiation
    +        // of dangerous classes while still allowing legitimate template operations.
    +        try
    +        {
    +            this.freemarkerConfiguration.setSetting( Configuration.NEW_BUILTIN_CLASS_RESOLVER_KEY, "safer" );
    +        }
    +        catch ( Exception e )
    +        {
    +            // Ignore configuration errors to maintain compatibility with older FreeMarker versions
    +            // that might not support this security setting
    +        }
         }
     
         public void extractFields( Reader reader, String entryName, FieldsExtractor extractor )
    
  • template/fr.opensagres.xdocreport.template.freemarker/src/test/java/fr/opensagres/xdocreport/template/freemarker/FreemarkerTemplateEngineSecurityTestCase.java+67 0 added
    @@ -0,0 +1,67 @@
    +package fr.opensagres.xdocreport.template.freemarker;
    +
    +import java.io.Reader;
    +import java.io.StringReader;
    +import java.io.StringWriter;
    +import java.io.Writer;
    +
    +import junit.framework.TestCase;
    +import fr.opensagres.xdocreport.core.XDocReportException;
    +import fr.opensagres.xdocreport.template.IContext;
    +import freemarker.template.Configuration;
    +import freemarker.template.TemplateException;
    +
    +/**
    + * Test case to verify security fixes for Server-Side Template Injection (SSTI) vulnerabilities
    + * in the FreeMarker template engine.
    + */
    +public class FreemarkerTemplateEngineSecurityTestCase
    +    extends TestCase
    +{
    +
    +    /**
    +     * Test that legitimate template operations still work after security fix.
    +     */
    +    public void testLegitimateTemplateOperationsStillWork()
    +        throws Exception
    +    {
    +        FreemarkerTemplateEngine templateEngine = new FreemarkerTemplateEngine();
    +        
    +        // Test basic variable substitution
    +        String legitimateTemplate = "Hello ${name}!";
    +        Reader reader = new StringReader( legitimateTemplate );
    +        Writer writer = new StringWriter();
    +        IContext context = templateEngine.createContext();
    +        context.put( "name", "World" );
    +
    +        templateEngine.process( "", context, reader, writer );
    +        assertEquals( "Hello World!", writer.toString() );
    +    }
    +
    +
    +    /**
    +     * Test protection against SSTI payload with freemarker.template.utility.Execute.
    +     */
    +    public void testSSTIProtectionAgainstExecutePayload()
    +        throws Exception
    +    {
    +        FreemarkerTemplateEngine templateEngine = new FreemarkerTemplateEngine();
    +        
    +        String maliciousTemplate ="${\"freemarker.template.utility.Execute\"?new()(\"whoami\")}";
    +        Reader reader = new StringReader( maliciousTemplate );
    +        Writer writer = new StringWriter();
    +        IContext context = templateEngine.createContext();
    +
    +        try
    +        {
    +            templateEngine.process( "", context, reader, writer );
    +            fail( "Security fix failed: Execute payload should be blocked" );
    +        }
    +        catch ( XDocReportException e )
    +        {
    +            assertTrue( "Expected security-related exception", 
    +                       e.getCause() instanceof TemplateException );
    +        }
    +    }
    +}
    +
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

6

News mentions

0

No linked articles in our index yet.