# CVE-2024-36404: GeoTools Remote Code Execution (RCE) vulnerability in evaluating XPath expressions

> Attackers can execute arbitrary code via XPath injection in GeoTools if user input is evaluated, requiring library upgrades or removal of the gt-complex module.

- **Severity:** Critical 9.8 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 2 Jul 2024
- **Updated:** 2 Aug 2024
- **Also known as:** GHSA-w3pj-wh35-fq8w

## What is CVE-2024-36404?

CVE-2024-36404 is a critical code injection vulnerability in geotools, published on 2 Jul 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

GeoTools is an open source Java library that provides tools for geospatial data. Prior to versions 31.2, 30.4, and 29.6, Remote Code Execution (RCE) is possible if an application uses certain GeoTools functionality to evaluate XPath expressions supplied by user input. Versions 31.2, 30.4, and 29.6 contain a fix for this issue. As a workaround, GeoTools can operate with reduced functionality by removing the `gt-complex` jar from one's application. As an example of the impact, application schema `datastore` would not function without the ability to use XPath expressions to query complex content. Alternatively, one may utilize a drop-in replacement GeoTools jar from SourceForge for versions 31.1, 30.3, 30.2, 29.2, 28.2, 27.5, 27.4, 26.7, 26.4, 25.2, and 24.0. These jars are for download only and are not available from maven central, intended to quickly provide a fix to affected applications.

Weakness: CWE-95 (Improper Neutralization of Directives in Dynamically Evaluated Code)

## Which versions are affected by CVE-2024-36404?

24 open source packages ship an affected version, including org.geotools.xsd:gt-xsd-core, org.geotools:gt-app-schema and org.geotools:gt-complex.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.geotools.xsd:gt-xsd-core` | Maven | All versions | 28.6 |
| `org.geotools.xsd:gt-xsd-core` | Maven | All versions | 28.6 |
| `org.geotools.xsd:gt-xsd-core` | Maven | From 29.0 | 29.6 |
| `org.geotools.xsd:gt-xsd-core` | Maven | From 29.0 | 29.6 |
| `org.geotools.xsd:gt-xsd-core` | Maven | From 30.0 | 30.4 |
| `org.geotools.xsd:gt-xsd-core` | Maven | From 30.0 | 30.4 |
| `org.geotools.xsd:gt-xsd-core` | Maven | From 31.0 | 31.2 |
| `org.geotools.xsd:gt-xsd-core` | Maven | From 31.0 | 31.2 |
| `org.geotools:gt-app-schema` | Maven | All versions | 28.6 |
| `org.geotools:gt-app-schema` | Maven | All versions | 28.6 |
| `org.geotools:gt-app-schema` | Maven | From 29.0 | 29.6 |
| `org.geotools:gt-app-schema` | Maven | From 29.0 | 29.6 |
| `org.geotools:gt-app-schema` | Maven | From 30.0 | 30.4 |
| `org.geotools:gt-app-schema` | Maven | From 30.0 | 30.4 |
| `org.geotools:gt-app-schema` | Maven | From 31.0 | 31.2 |
| `org.geotools:gt-app-schema` | Maven | From 31.0 | 31.2 |
| `org.geotools:gt-complex` | Maven | All versions | 28.6 |
| `org.geotools:gt-complex` | Maven | All versions | 28.6 |
| `org.geotools:gt-complex` | Maven | From 29.0 | 29.6 |
| `org.geotools:gt-complex` | Maven | From 29.0 | 29.6 |
| `org.geotools:gt-complex` | Maven | From 30.0 | 30.4 |
| `org.geotools:gt-complex` | Maven | From 30.0 | 30.4 |
| `org.geotools:gt-complex` | Maven | From 31.0 | 31.2 |
| `org.geotools:gt-complex` | Maven | From 31.0 | 31.2 |

## How do I fix CVE-2024-36404?

Upgrade org.geotools.xsd:gt-xsd-core to a fixed version for your release line: 28.6, 29.6, 30.4 or 31.2.

## Is CVE-2024-36404 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-36404 exists.

Public exploit code:

- GeoServer and GeoTools - Remote Code Execution (nuclei): http/cves/2024/CVE-2024-36404.yaml

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-36404 and fix it if it is affected.

What it is: CVE-2024-36404 is a critical code injection vulnerability in geotools, published on 2 Jul 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-36404 exists.

Affected packages and fixed versions:
- org.geotools.xsd:gt-xsd-core (Maven): affected all versions; fixed in 28.6
- org.geotools.xsd:gt-xsd-core (Maven): affected all versions; fixed in 28.6
- org.geotools.xsd:gt-xsd-core (Maven): affected from 29.0; fixed in 29.6
- org.geotools.xsd:gt-xsd-core (Maven): affected from 29.0; fixed in 29.6
- org.geotools.xsd:gt-xsd-core (Maven): affected from 30.0; fixed in 30.4
- org.geotools.xsd:gt-xsd-core (Maven): affected from 30.0; fixed in 30.4
- org.geotools.xsd:gt-xsd-core (Maven): affected from 31.0; fixed in 31.2
- org.geotools.xsd:gt-xsd-core (Maven): affected from 31.0; fixed in 31.2
- org.geotools:gt-app-schema (Maven): affected all versions; fixed in 28.6
- org.geotools:gt-app-schema (Maven): affected all versions; fixed in 28.6
- org.geotools:gt-app-schema (Maven): affected from 29.0; fixed in 29.6
- org.geotools:gt-app-schema (Maven): affected from 29.0; fixed in 29.6

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-36404/ (Markdown: https://insights.sbomify.com/CVE-2024-36404/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-36404
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-36404
- OSV: https://osv.dev/vulnerability/CVE-2024-36404

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-36404/
Summaries are generated and may contain mistakes; the official description above is the record.
