CVE-2024-45747: 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
Set GeoServer's GEOSERVER_FREEMARKER_ALLOW_LIST to its default value (new in GeoServer 2.27.0) so FreeMarker template authors are restricted to the allowed objects.
GeoServer application properties GEOSERVER_FREEMARKER_ALLOW_LIST = (use default restricting objects template authors can access) - Configuration
Set GeoServer's GEOSERVER_FREEMARKER_API_EXPOSED to its default value (new in GeoServer 2.27.0) to limit access to getter methods used to retrieve object properties.
GeoServer application properties GEOSERVER_FREEMARKER_API_EXPOSED = (use default restricting access to getter methods) - Configuration
Set GeoServer's GEOSERVER_FREEMARKER_BLOCK_LIST to its default value (new in GeoServer 2.27.0) to block access to sensitive functionality such as freemarker.template.utility.Execute.
GeoServer application properties GEOSERVER_FREEMARKER_BLOCK_LIST = (use default blocking dangerous APIs)
Event History
Frequently Asked Questions
Who can exploit this vulnerability?
An authenticated GeoServer administrator who can upload FreeMarker templates can exploit it. The issue affects templates used for WMS GetFeatureInfo HTML and JSON output and WMS GetMap KML and GeoRSS output.
Does a standard GeoServer deployment use the affected functionality?
Yes. The affected FreeMarker template usage is present in a plain GeoServer instance; no extension or community modules are required.
What access does exploitation provide?
An attacker can execute operating-system commands and read from or write to arbitrary files on the GeoServer host. The vulnerable configuration can be bypassed to access freemarker.template.utility.Execute and other sensitive functionality.
What changes are available in the resolved release?
GeoServer 2.27.0 adds GEOSERVER_FREEMARKER_BLOCK_LIST, GEOSERVER_FREEMARKER_ALLOW_LIST, and GEOSERVER_FREEMARKER_API_EXPOSED. Their defaults restrict objects available to template authors and limit access to getter methods.