CVE-2023-25158
JSON

9.8critical

Unfiltered SQL Injection in Geotools

Severity
9.8critical CVSS:3.1 by GitHub_M
Exploit likelihood
1.09% (higher than 66% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-99c3-qc2q-p94m

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.

Affected

Product or packageVersionsReported by
geotools geotools>= 28.0, < 28.2, < 27.4CVE List
org.geotools:gt-jdbc (Maven)from 28.0 before 28.2, from 27.0 before 27.4, from 26.0 before 26.7, from 25.0 before 25.7, before 24.7GitHub Advisory Database
osgeo geotoolsbefore 24.7, from 25.0 before 25.7, from 26.0 before 26.7, from 27.0 before 27.4, from 28.0 before 28.2NVD

All scores

GitHub_M9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
GitHub9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
NVD9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-89

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact total.

What each source says

CVE List

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.

GitHub Advisory Database
Impact

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:

  1. PropertyIsLike filter
    • Requires PostGIS DataStore with "encode functions" enabled
    • Or any JDBCDataStore (all relational databases) with String field (no mitigation)
  2. strEndsWith function
    • Requires PostGIS DataStore with "encode functions" enabled
  3. strStartsWith function
    • Requires PostGIS DataStore with "encode functions" enabled
  4. FeatureId filter
    • Requires JDBCDataStore (all relational databases) with prepared statements disabled and table with String primary key (Oracle not affected, SQL Server and MySQL have no settings to enabled prepared statements, PostGIS does)
  5. jsonArrayContains function
    • Requires PostGIS and Oracle DataStore with String or JSON field
  6. DWithin filter
    • Happens only in Oracle DataStore, no mitigation
Patches
  • GeoTools 28.2
  • GeoTools 27.4
  • GeoTools 26.7
  • GeoTools 25.7
  • GeoTools 24.7
Workarounds

Partial mitigation:

  • In PostGIS DataStore disable "encode functions"
  • In any PostGIS enable "prepared statements" (only database with such settings)
        Map<String, Object> params = new HashMap<>();
        params.put("dbtype", "postgis");
        params.put("host", "localhost");
        params.put("port", 5432);
        params.put("schema", "public");
        params.put("database", "database");
        params.put("user", "postgres");
        params.put("passwd", "postgres");
        params.put("preparedStatements", true ); // mitigation
        params.put("encode functions", false ); // mitigation

        DataStore dataStore = DataStoreFinder.getDataStore(params);
References

References

Sources

SourceRecordLicence
CVE ListCVE-2023-25158 changed 2025-03-10CVE Terms of Use
GitHub Advisory DatabaseGHSA-99c3-qc2q-p94m changed 2023-11-08CC-BY-4.0
NVDCVE-2023-25158 changed 2026-11-30Public domain