CRITICAL 9.8
CVE-2023-25158
GeoTools OGC Filter SQL Injection Vulnerabilities
Description
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:
PropertyIsLikefilter- Requires PostGIS DataStore with "encode functions" enabled
- Or any JDBCDataStore (all relational databases) with String field (no mitigation)
strEndsWithfunction- Requires PostGIS DataStore with "encode functions" enabled
strStartsWithfunction- Requires PostGIS DataStore with "encode functions" enabled
FeatureIdfilter- 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)
jsonArrayContainsfunction- Requires PostGIS and Oracle DataStore with String or JSON field
DWithinfilter- 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
- OGC Filter SQL Injection Vulnerabilities (GeoServer)
Affected Maven artifacts (1)
| Artifact | Affected versions | Fixed in |
|---|---|---|
| org.geotools » gt-jdbc | < 24.7>= 25.0, < 25.7>= 26.0, < 26.7>= 27.0, < 27.4>= 28.0, < 28.2 | 24.7, 25.7, 26.7, 27.4, 28.2 |
Blast radius
1affected artifacts
264affected versions
886dependent artifacts (est.)
34,685dependent versions
73% of the dependent artifacts (655) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 2,610 |
| 2 hops | 16,152 |
| 3 hops | 9,287 |
| 4 hops | 4,381 |
| 5 hops | 1,609 |
| 6 hops | 646 |
Most used dependents
- org.geotools » gt-shapefile361 usages
- org.geoserver » gs-main300 usages
- org.geoserver.web » gs-web-core195 usages
- org.geoserver » gs-wms103 usages
- org.geomajas » geomajas-impl82 usages
- org.geoserver » gs-wfs75 usages
- org.geoserver » main70 usages
- org.geotools » gt-process67 usages
- org.geomajas » geomajas-gwt-client65 usages
- org.geoserver » gs-restconfig60 usages
- org.geotools » gt-geopkg58 usages
- org.geomajas.plugin » geomajas-layer-geotools55 usages
- org.geotools » gt-process-feature53 usages
- org.geoserver.extension » gs-wps-core52 usages
- org.geoserver » gs-rest45 usages
Computed from the dependency graph of build 20261205.2030 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.
References
| Advisory | NVD CVE-2023-25158 | nvd.nist.gov |
| Package | geotools/geotools | github.com |
| Web | geotools/geotools advisory GHSA-99c3-qc2q-p94m | github.com |
| Web | geotools/geotools commit 64fb4c4 | github.com |
