GitHub Advisory Database
GHSA-99c3-qc2q-p94m
GeoTools OGC Filter SQL Injection Vulnerabilities
Details
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:
- `
PropertyIsLike` filter - Requires PostGIS DataStore with "encode functions" enabled
- Or any JDBCDataStore (all relational databases) with String field (no mitigation)
- `
strEndsWith` function - Requires PostGIS DataStore with "encode functions" enabled
- `
strStartsWith` function - Requires PostGIS DataStore with "encode functions" enabled
- `
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)
- `
jsonArrayContains` function - Requires PostGIS and Oracle DataStore with String or JSON field
- `
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
- OGC Filter SQL Injection Vulnerabilities (GeoServer)
Affected packages
| Ecosystem | Package | Affected versions |
|---|---|---|
| Maven | org.geotools:gt-jdbc | From 28.0 before 28.2 (fixed in 28.2) |
| Maven | org.geotools:gt-jdbc | From 27.0 before 27.4 (fixed in 27.4) |
| Maven | org.geotools:gt-jdbc | From 26.0 before 26.7 (fixed in 26.7) |
| Maven | org.geotools:gt-jdbc | From 25.0 before 25.7 (fixed in 25.7) |
| Maven | org.geotools:gt-jdbc | All versions before 24.7 (fixed in 24.7) |