{"id":"CVE-2023-25158","aliases":["GHSA-99c3-qc2q-p94m"],"url":"https://o3.security/vulnerability/CVE-2023-25158","summary":"Unfiltered SQL Injection in Geotools","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","published":"2023-02-21T20:57:47.754Z","modified":"2026-08-12T14:50:36.549809Z","cvss":{"score":9.8,"severity":"CRITICAL","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"},"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"Maven","name":"org.geotools:gt-jdbc","fixedVersion":"28.2"},{"ecosystem":"Maven","name":"org.geotools:gt-jdbc","fixedVersion":"27.4"},{"ecosystem":"Maven","name":"org.geotools:gt-jdbc","fixedVersion":"26.7"},{"ecosystem":"Maven","name":"org.geotools:gt-jdbc","fixedVersion":"25.7"},{"ecosystem":"Maven","name":"org.geotools:gt-jdbc","fixedVersion":"24.7"}],"fix":{"url":"https://github.com/geotools/geotools/commit/64fb4c47f43ca818c2fe96a94651bff1b3b3ed2b","label":"geotools/geotools@64fb4c4"},"references":[{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/25xxx/CVE-2023-25158.json"},{"type":"ADVISORY","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":"FIX","url":"https://github.com/geotools/geotools/commit/64fb4c47f43ca818c2fe96a94651bff1b3b3ed2b"},{"type":"PACKAGE","url":"https://github.com/geotools/geotools"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T14:50:36.549809Z"}}