GHSA-wf6j-gr27-g7ch: High severity maven/org.geoserver.web:gs-web-app vulnerability
Summary A server-side template injection (SSTI) vulnerability exist that allows an authenticated administrator to upload FreeMarker templates containing malicious content that can execute OS commands and read from or write to arbitrary files on the server. These FreeMarker templates are used in a plain GeoServer instance (no extension or community modules) for WMS GetFeatureInfo HTML and JSON and WMS GetMap KML and GeoRSS output formats.
Details The org.geoserver.template.TemplateUtils.getSafeConfiguration() method attempts to block access to the class freemarker.template.utility.Execute but it is still possible to gain access to it and other sensitive functionality by chaining a specific sequence of method calls.
Impact This vulnerability can lead to executing arbitrary code and reading and writing arbitrary files.
Resolution GeoServer 2.27.0 addresses this vulnerability with several new application properties:
GEOSERVERFREEMARKERBLOCKLIST GEOSERVERFREEMARKERALLOWLIST GEOSERVERFREEMARKERAPIEXPOSED
These application properties default to restricting the objects template authors can access, and limit access to "getter" methods used to access object properties.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
maven/org.geoserver.web:gs-web-appto a version that resolves this vulnerability.Fixed in 2.27.0 - Upgrade
Upgrade
maven/org.geoserver:gs-wmsto a version that resolves this vulnerability.Fixed in 2.27.0 - Upgrade
Upgrade
maven/org.geoserver:gs-mainto a version that resolves this vulnerability.Fixed in 2.27.0 - Upgrade
Upgrade
GeoServerto a version that resolves this vulnerability.Fixed in 2.27.0 - Configuration
Ensure GEOSERVER_FREEMARKER_ALLOW_LIST is set to the default restrictive allow-list of FreeMarker objects for template authors (GeoServer 2.27.0 adds these properties to restrict template author access).
GeoServer application properties (FreeMarker SSTI protections) GEOSERVER_FREEMARKER_ALLOW_LIST = (default restriction enabled per vendor description) - Configuration
Ensure GEOSERVER_FREEMARKER_API_EXPOSED is set to the default restrictive set that limits access to getter methods used to access object properties (introduced in GeoServer 2.27.0).
GeoServer application properties (FreeMarker SSTI protections) GEOSERVER_FREEMARKER_API_EXPOSED = (default restriction enabled per vendor description) - Configuration
Ensure GEOSERVER_FREEMARKER_BLOCK_LIST is set to the default restrictive block list of sensitive FreeMarker objects (GeoServer 2.27.0 adds this to restrict access despite TemplateUtils.getSafeConfiguration attempts).
GeoServer application properties (FreeMarker SSTI protections) GEOSERVER_FREEMARKER_BLOCK_LIST = (default restriction enabled per vendor description)
Event History
Frequently Asked Questions
Who can exploit this issue?
An authenticated GeoServer administrator who can upload FreeMarker templates can exploit it. The vulnerable templates are used by WMS GetFeatureInfo HTML and JSON outputs and WMS GetMap KML and GeoRSS outputs.
Is a plain GeoServer installation affected?
Yes. The issue affects a plain GeoServer instance and does not require extensions or community modules.
What can successful exploitation allow?
An attacker can execute operating-system commands and read from or write to arbitrary files on the server. This can result in arbitrary code execution and compromise of confidentiality, integrity, and availability.
What configuration changes are available in the fixed release?
GeoServer 2.27.0 introduces GEOSERVER_FREEMARKER_BLOCK_LIST, GEOSERVER_FREEMARKER_ALLOW_LIST, and GEOSERVER_FREEMARKER_API_EXPOSED. Their default settings restrict objects accessible to template authors and limit access to getter methods.