Summary
OpenMetadata versions prior to 1.11.4 contain a server-side template injection vulnerability in FreeMarker-based email templates, allowing attacker-controlled template expressions to be evaluated on the server.
In deployments where an attacker has obtained or possesses administrative privileges, crafted input passed into these templates can lead to remote code execution in the OpenMetadata server environment.
Affected context
This vulnerability occurs in OpenMetadata instances that use FreeMarker for rendering dynamic email templates and allow administrator-controlled content or configuration to influence template data or structure.
It becomes relevant when administrator-level users can supply or alter values that are interpolated into FreeMarker templates without strict sanitization or isolation.
The issue is confined to server-side template rendering paths, but exploitability depends on how much control an administrator has over template inputs and configuration in a given deployment.
Exploit preconditions
- Attack surface: HTTP(S) management and configuration endpoints that ultimately trigger FreeMarker email rendering.
- Required access: Valid OpenMetadata administrative privileges (or compromise of an admin account/API key).
- Trigger point: Sending or previewing emails, notifications, or workflows that render FreeMarker templates containing attacker-controlled expressions or data.
- Why exploitation is possible: The template engine interprets untrusted template expressions with access to server-side objects and APIs, allowing arbitrary code-like operations instead of treating the data as plain text.
Why this happens
The root cause maps to CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine and is closely related to CWE-94: Improper Control of Generation of Code.
FreeMarker is a powerful template engine that supports access to server-side objects, method calls, and dynamic evaluation.
When template expressions can be influenced by untrusted or loosely trusted input (even from privileged users) and are rendered in a context that exposes powerful objects or APIs, the template engine may execute attacker-supplied directives.
This insecure pattern arises when the application treats template syntax and data as equally trusted, failing to:
- Clearly separate static template logic from runtime data
- Restrict which objects and methods are exposed to the template
- Enforce strict validation or neutralization of special template elements
Potential impact
- Remote code execution in the context of the OpenMetadata server process
- Access to sensitive configuration, secrets, and environment variables available to the application runtime
- Unauthorized interaction with backend systems such as databases, message queues, or other services reached from the server
- Lateral movement within the hosting environment or infrastructure if combined with other weaknesses
- Complete compromise of metadata integrity and confidentiality within the OpenMetadata platform
General mitigation guidance
Effective mitigation focuses on limiting what templates can do, constraining what data they receive, and reducing their privileges:
- Prefer data-only templating patterns where templates are static and user-controlled values are injected as escaped text, not as template code.
- Configure FreeMarker in a locked-down mode that:
- Restricts access to arbitrary classes, methods, and reflection
- Limits the object graphs exposed to templates to minimal, pre-sanitized view models
- Enforce strong separation between template logic and data sources:
- Do not allow dynamic construction of template fragments from administrator input where possible
- Treat any administrator-editable content rendered into templates as untrusted data that must be escaped
- Apply least-privilege to the OpenMetadata runtime environment:
- Run the service under a dedicated, low-privilege OS account
- Limit filesystem, network, and process-level permissions so that even successful template abuse has constrained impact
- Introduce centralized validation or encoding utilities for any values rendered into templates, especially those that may be interpreted as template directives, expressions, or code.
How teams detect issues like this
Detection typically combines code-level analysis with runtime monitoring:
- Static analysis and code scanning:
- Search for FreeMarker configuration that exposes broad object graphs (e.g., unrestricted beans, reflection, or direct access to system objects).
- Flag paths where template content or critical template parameters are directly influenced by administrative or user input without canonicalization or escaping.
- Identify explicit uses of powerful methods or objects in templates that could be abused if user-controlled.
- Code review indicators:
- Templates that embed business logic, method calls, or environment access rather than just presentation.
- Facilities that allow administrators to edit or upload templates, email bodies, or notification formats that are rendered server-side.
- Missing or inconsistent use of escaping functions before inserting user-controlled values into templates.
- Policy and pipeline enforcement:
- Add CI/CD checks that enforce a secure template API usage policy and reject changes that expose sensitive objects or unsafe FreeMarker features.
- Use SAST/IAST tools that have explicit rules for SSTI patterns in Java template engines such as FreeMarker.
- Runtime monitoring:
- Log and review template rendering errors, unusual expressions, or access to unexpected classes/methods during template evaluation.
- Monitor for anomalous process behavior (sudden command execution, abnormal outbound connections) originating from the application process.

