LangChain4j: SQL injection via metadata filters in langchain4j-mariadb and langchain4j-pgvector
langchain4j
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| dev.langchain4j:langchain4j-mariadb Maven |
|
|
langchain4j
| Product | Affected | Fixed in |
|---|---|---|
| dev.langchain4j:langchain4j-mariadb Maven |
|
|
1.16.3-beta26| dev.langchain4j:langchain4j-pgvector Maven |
|
|
LangChain4j is a Java library for building LLM-powered applications on the JVM. Prior to 1.2.1-beta8, 1.5.1-beta11, 1.11.8-beta19, and 1.16.3-beta26, the MariaDB and pgvector embedding stores build metadata-filter SQL by string-concatenating filter keys, and in MariaDB string values, directly into the query without adequate escaping. A crafted metadata key in EmbeddingSearchRequest.filter() can break out of its SQL context and inject arbitrary SQL into the statements executed by the stores' search and removeAll(Filter) operations, enabling blind data exfiltration, denial of service via sleep functions, and deletion of arbitrary rows through removeAll(Filter). This issue is fixed in langchain4j-mariadb and langchain4j-pgvector versions 1.2.1-beta8, 1.5.1-beta11, 1.11.8-beta19, and 1.16.3-beta26.
From the CVE record · GitHub_M
The MariaDB and pgvector embedding stores build metadata-filter SQL without adequately escaping filter keys; MariaDB also inserts string values without adequate escaping. If an attacker can supply a crafted metadata filter, they can inject SQL into search or removeAll(Filter) operations, potentially exfiltrating data, causing denial of service, or deleting rows. The input does not specify whether authentication or user interaction is required.
Check applications using Maven packages dev.langchain4j:langchain4j-mariadb or dev.langchain4j:langchain4j-pgvector in the affected ranges below 1.2.1-beta8, from 1.3.0-beta9 to below 1.5.1-beta11, from 1.6.0-beta12 to below 1.11.8-beta19, or from 1.12.1-beta21 to below 1.16.3-beta26.