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
strEndsWith
function
strStartsWith
function
FeatureId
filter
jsonArrayContains
function
DWithin
filter
Partial mitigation:
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);
{ "nvd_published_at": "2023-02-21T21:15:00Z", "github_reviewed_at": "2023-02-22T19:16:06Z", "severity": "CRITICAL", "github_reviewed": true, "cwe_ids": [ "CWE-89" ] }