# CVE-2023-25158: Unfiltered SQL Injection in Geotools

> Attackers can execute arbitrary SQL commands via OGC Filters in GeoTools JDBCDataStore implementations, potentially reading or modifying database contents.

- **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:** 21 Feb 2023
- **Updated:** 10 Mar 2025
- **Also known as:** GHSA-99c3-qc2q-p94m

## What is CVE-2023-25158?

CVE-2023-25158 is a critical SQL injection vulnerability in geotools, published on 21 Feb 2023. 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. GeoTools includes support for OGC Filter expression language parsing, encoding and execution against a range of datastore. SQL Injection Vulnerabilities have been found when executing OGC Filters with JDBCDataStore implementations. Users are advised to upgrade to either version 27.4 or to 28.2 to resolve this issue. Users unable to upgrade may disable `encode functions` for PostGIS DataStores or enable `prepared statements` for JDBCDataStores as a partial mitigation.

Weakness: CWE-89 (Improper Neutralization of Special Elements used in an SQL Command)

## Which versions are affected by CVE-2023-25158?

10 open source packages ship an affected version, including org.geotools:gt-jdbc. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.geotools:gt-jdbc` | Maven | All versions | 24.7 |
| `org.geotools:gt-jdbc` | Maven | All versions | 24.7 |
| `org.geotools:gt-jdbc` | Maven | From 25.0 | 25.7 |
| `org.geotools:gt-jdbc` | Maven | From 25.0 | 25.7 |
| `org.geotools:gt-jdbc` | Maven | From 26.0 | 26.7 |
| `org.geotools:gt-jdbc` | Maven | From 26.0 | 26.7 |
| `org.geotools:gt-jdbc` | Maven | From 27.0 | 27.4 |
| `org.geotools:gt-jdbc` | Maven | From 27.0 | 27.4 |
| `org.geotools:gt-jdbc` | Maven | From 28.0 | 28.2 |
| `org.geotools:gt-jdbc` | Maven | From 28.0 | 28.2 |

Products: Geotools Geotools.

## How do I fix CVE-2023-25158?

Upgrade org.geotools:gt-jdbc to a fixed version for your release line: 24.7, 25.7, 26.7 or 27.4.

## Is CVE-2023-25158 being exploited?

There is no known exploitation of CVE-2023-25158 in the wild and no public exploit code.

## Other vulnerabilities in geotools

- [CVE-2025-30220](https://insights.sbomify.com/CVE-2025-30220/): GeoTools, GeoServer, and GeoNetwork XML External Entity (XXE) Processing Vulnerability in XSD schema handling (critical 9.9)
- [CVE-2022-24818](https://insights.sbomify.com/CVE-2022-24818/): Unchecked JNDI lookups in GeoTools (high 8.2)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-25158 and fix it if it is affected.

What it is: CVE-2023-25158 is a critical SQL injection vulnerability in geotools, published on 21 Feb 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2023-25158 in the wild and no public exploit code.

Affected packages and fixed versions:
- org.geotools:gt-jdbc (Maven): affected all versions; fixed in 24.7
- org.geotools:gt-jdbc (Maven): affected all versions; fixed in 24.7
- org.geotools:gt-jdbc (Maven): affected from 25.0; fixed in 25.7
- org.geotools:gt-jdbc (Maven): affected from 25.0; fixed in 25.7
- org.geotools:gt-jdbc (Maven): affected from 26.0; fixed in 26.7
- org.geotools:gt-jdbc (Maven): affected from 26.0; fixed in 26.7
- org.geotools:gt-jdbc (Maven): affected from 27.0; fixed in 27.4
- org.geotools:gt-jdbc (Maven): affected from 27.0; fixed in 27.4
- org.geotools:gt-jdbc (Maven): affected from 28.0; fixed in 28.2
- org.geotools:gt-jdbc (Maven): affected from 28.0; fixed in 28.2

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-2023-25158/ (Markdown: https://insights.sbomify.com/CVE-2023-25158/index.md)
```

## Sources

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

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