Vulnerabilities in pkg:maven/org.geotools/gt-jdbc

PACKAGE
Advisory Identifier: GHSA-99c3-qc2q-p94m
Advisory Summary

CVE-2023-25158 is a CRITICAL (CVSS 9.8) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Gt jdbc libraries in the Maven ecosystem. The issue involves geotools ogc filter sql injection vulnerabilities. Remediation is available by upgrading affected packages to version 28.2, 27.4, 26.7, 25.7, 24.7.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:maven/org.geotools/gt-jdbc

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:maven/org.geotools/gt-jdbc. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-99c3-qc2q-p94m CVE-2023-25158 CRITICAL GeoTools OGC Filter SQL Injection Vulnerabilities

CVE-2023-25158 at a Glance

CVE Identifier CVE-2023-25158
GHSA Identifier GHSA-99c3-qc2q-p94m
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Gt jdbc
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 9.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2023-25158

To remediate this vulnerability, upgrade all affected Gt jdbc dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

org.geotools:gt-jdbc fixed: 28.2
<dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt-jdbc</artifactId>
    <version>28.2</version>
</dependency>
org.geotools:gt-jdbc fixed: 27.4
<dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt-jdbc</artifactId>
    <version>27.4</version>
</dependency>
org.geotools:gt-jdbc fixed: 26.7
<dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt-jdbc</artifactId>
    <version>26.7</version>
</dependency>
org.geotools:gt-jdbc fixed: 25.7
<dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt-jdbc</artifactId>
    <version>25.7</version>
</dependency>
org.geotools:gt-jdbc fixed: 24.7
<dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt-jdbc</artifactId>
    <version>24.7</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=org.geotools

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2023-25158, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=org.geotools

Analyze the terminal output to locate any version of Gt jdbc in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 28.2), your application is affected.

Note: The mvn dependency:tree -Dincludes=org.geotools command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Gt jdbc, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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) 3. ``strEndsWith`` function * Requires PostGIS DataStore with "encode functions" enabled 5. ``strStartsWith`` function * Requires PostGIS DataStore with "encode functions" enabled 6. ``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) 7. ``jsonArrayContains`` function * Requires PostGIS and Oracle DataStore with String or JSON field 8. ``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) ```java 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 * [OGC Filter SQL Injection Vulnerabilities](https://github.com/geoserver/geoserver/security/advisories/GHSA-7g5f-wrx8-5ccf) (GeoServer)

CVE-2023-25158 Affected Gt jdbc Versions

5 component(s)
Fixed Versions:
28.227.426.725.724.7
Product / Package Ecosystem Affected Versions Fixed Version
org.geotools:gt-jdbc
Maven
≥ 28.0
< 28.2
28.2
org.geotools:gt-jdbc
Maven
≥ 27.0
< 27.4
27.4
org.geotools:gt-jdbc
Maven
≥ 26.0
< 26.7
26.7
org.geotools:gt-jdbc
Maven
≥ 25.0
< 25.7
25.7
org.geotools:gt-jdbc
Maven
< 24.7
24.7

References

Frequently Asked Questions

What is CVE-2023-25158?
CVE-2023-25158 is a security vulnerability in Gt jdbc involving GeoTools OGC Filter SQL Injection Vulnerabilities under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Gt jdbc versions are affected?
Affected versions include releases prior to 28.2, 27.4, 26.7, 25.7, 24.7 across affected packages: org.geotools:gt-jdbc.
What version fixes CVE-2023-25158?
Upgrading to 28.2, 27.4, 26.7, 25.7, 24.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gt-jdbc affected?
Yes, org.geotools:gt-jdbc is affected in releases prior to 28.2, 27.4, 26.7, 25.7, 24.7. Upgrade your dependency to 28.2, 27.4, 26.7, 25.7, 24.7 or later.
What is the CVSS score of CVE-2023-25158?
CVE-2023-25158 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2023-25158?
CVE-2023-25158 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check Maven dependencies for CVE-2023-25158?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.geotools'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-99c3-qc2q-p94m",
  "modified" : "2023-02-22T19:16:06Z",
  "published" : "2023-02-22T19:16:06Z",
  "aliases" : [ "CVE-2023-25158" ],
  "summary" : "GeoTools OGC Filter SQL Injection Vulnerabilities",
  "details" : "### Impact\n\nGeoTools includes support for OGC Filter expression language parsing, encoding and execution against a range of datastore.\n\nSQL Injection Vulnerabilities have been found when executing OGC Filters with JDBCDataStore implementations:\n\n1. ``PropertyIsLike`` filter\n   * Requires PostGIS DataStore with \"encode functions\" enabled\n   * Or any JDBCDataStore (all relational databases) with String field (no mitigation)\n3. ``strEndsWith`` function\n   * Requires PostGIS DataStore with \"encode functions\" enabled\n5. ``strStartsWith`` function\n   * Requires PostGIS DataStore with \"encode functions\" enabled\n6. ``FeatureId`` filter\n   * 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)\n7. ``jsonArrayContains`` function\n   * Requires PostGIS and Oracle DataStore with String or JSON field\n8. ``DWithin`` filter\n   * Happens only in Oracle DataStore, no mitigation\n\n### Patches\n\n* GeoTools 28.2\n* GeoTools 27.4\n* GeoTools 26.7\n* GeoTools 25.7\n* GeoTools 24.7\n\n### Workarounds\n\nPartial mitigation:\n\n* In PostGIS DataStore disable \"encode functions\"\n* In any PostGIS enable \"prepared statements\" (only database with such settings)\n\n```java\n        Map<String, Object> params = new HashMap<>();\n        params.put(\"dbtype\", \"postgis\");\n        params.put(\"host\", \"localhost\");\n        params.put(\"port\", 5432);\n        params.put(\"schema\", \"public\");\n        params.put(\"database\", \"database\");\n        params.put(\"user\", \"postgres\");\n        params.put(\"passwd\", \"postgres\");\n        params.put(\"preparedStatements\", true ); // mitigation\n        params.put(\"encode functions\", false ); // mitigation\n\n        DataStore dataStore = DataStoreFinder.getDataStore(params);\n```\n\n### References\n\n* [OGC Filter SQL Injection Vulnerabilities](https://github.com/geoserver/geoserver/security/advisories/GHSA-7g5f-wrx8-5ccf) (GeoServer)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.geotools:gt-jdbc"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "28.0"
      }, {
        "fixed" : "28.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.geotools:gt-jdbc"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "27.0"
      }, {
        "fixed" : "27.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.geotools:gt-jdbc"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "26.0"
      }, {
        "fixed" : "26.7"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.geotools:gt-jdbc"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "25.0"
      }, {
        "fixed" : "25.7"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.geotools:gt-jdbc"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "24.7"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/geotools/geotools/security/advisories/GHSA-99c3-qc2q-p94m"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-25158"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/geotools/geotools/commit/64fb4c47f43ca818c2fe96a94651bff1b3b3ed2b"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/geotools/geotools"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-02-22T19:16:06Z",
    "nvd_published_at" : "2023-02-21T21:15:00Z"
  }
}