/

CVE-2026-55405

Severity:

HIGH RISK

(7.6)

SQL Injection (CWE-89) in LangChain4j Embedding Stores

CVE-2026-55405

Awaiting Analysis

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Data Exfiltration and Manipulation via SQL Injection

Severity:

HIGH RISK

(7.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

LangChain4j's MariaDB and pgvector embedding stores construct metadata filter SQL queries by string concatenation without adequate escaping of metadata keys and some values.

An attacker who can supply crafted metadata filters to EmbeddingSearchRequest.filter() may inject arbitrary SQL into search and removeAll(Filter) operations, enabling blind data exfiltration, denial of service, or deletion of arbitrary rows.

Affected context

This vulnerability appears in applications using LangChain4j's MariaDB or pgvector embedding stores where metadata-based filtering is supported.

It becomes relevant when user-controllable metadata keys or string values are passed into EmbeddingSearchRequest.filter() and then used to build SQL WHERE clauses via direct string concatenation.

The risk is higher in deployments where embedding stores share a database with other application tables, or where database accounts used by the stores have broad privileges beyond read-only access to embeddings.

Exploit preconditions

  • Attack surface: API endpoints, services, or internal components that accept metadata filters for embedding search or deletion operations and forward them to LangChain4j embedding stores.
  • Required access: Ability to create or manipulate EmbeddingSearchRequest.filter() contents, either directly through an SDK or indirectly via HTTP/JSON inputs or similar interfaces.
  • Trigger point: Execution of search or removeAll(Filter) operations where filter keys and, for MariaDB, string values are concatenated into SQL statements without proper escaping or parameterization.
  • Why exploitation is possible: The filter keys and some filter values are treated as trusted SQL fragments, not as data, allowing crafted input to break out of the intended comparison context and inject arbitrary SQL expressions or statements.

Why this happens

The underlying issue is the construction of SQL queries from untrusted input using dynamic string concatenation rather than parameterized statements.

In the MariaDB and pgvector embedding stores, metadata filter keys and, in the MariaDB case, string values are directly interpolated into SQL WHERE clauses without robust quoting or validation.

This pattern maps to CWE-89: SQL Injection, where user-controlled data is embedded into SQL commands in a way that allows alteration of the query's structure, making it possible to execute unintended commands against the database.

Potential impact

  • Blind data exfiltration from embedding-related tables and potentially other tables accessible to the database user
  • Denial of service by invoking sleep or resource-intensive SQL functions
  • Deletion of arbitrary rows via crafted filters passed to removeAll(Filter)
  • Unauthorized modification of metadata or embedding records if the database role permits updates
  • Leveraging injected SQL to pivot to other schemas or administrative functions, depending on database privileges and configuration

General mitigation guidance

Effective mitigation focuses on separating untrusted data from SQL command structure and tightening database privileges.

Common defensive patterns include:

  • Using parameterized queries or prepared statements for all dynamic SQL, treating filter keys and values strictly as data rather than SQL fragments.
  • Enforcing an allowlist of valid metadata keys and operators, rejecting or sanitizing anything that does not match expected identifiers.
  • Applying strict validation and normalization on metadata values, avoiding direct interpolation into SQL clauses.
  • Running embedding store database accounts with least privilege, limiting access to only the required tables and operations, and preferring read-only roles for search paths.
  • Structuring application interfaces so that clients cannot directly influence raw SQL filter syntax, instead exposing higher-level filter abstractions that are safely translated into queries.

How teams detect issues like this

Detection typically combines code-level analysis with runtime monitoring:

  • Static analysis rules that flag dynamic SQL construction using string concatenation, especially where input originates from EmbeddingSearchRequest.filter() or other user-facing parameters.
  • Targeted code review focusing on repository modules that interact with MariaDB or pgvector embedding stores, checking for lack of parameterization and missing identifier/value validation.
  • Security testing that attempts SQL injection payloads via metadata filters and observes for anomalous behavior, such as unexpected errors, timing differences, or altered query results.
  • Database monitoring and logging to detect suspicious queries, including those containing sleep functions, concatenated literals, or unusual WHERE clauses, and correlating them with application requests.
  • Integration of automated scanning tools or linters into CI/CD pipelines to enforce policies against constructing SQL queries via direct string concatenation.

Sources

SourceLink
github.comgithub.com/langchain4j/langchain4j/commit/13a0698bdfaf105d8aaf0367881df51358596219
github.comgithub.com/langchain4j/langchain4j/commit/1bc1f60aa58ef5c3c1703caf73362482480351cf
github.comgithub.com/langchain4j/langchain4j/commit/8805d5d128694302f1b0a2650174186862f669e7
github.comgithub.com/langchain4j/langchain4j/commit/ce96291dfb243c7f6753b5d65c7a77914642314f
github.comgithub.com/langchain4j/langchain4j/commit/f14a10ce77e4ea1b8277f67d6a81f46abd7a5bc2
github.comgithub.com/langchain4j/langchain4j/releases/tag/1.16.3
github.comgithub.com/langchain4j/langchain4j/security/advisories/GHSA-2mfg-cc43-9pcj

Frequently asked

questions

Yes, if an application exposes endpoints or interfaces that allow remote users to influence EmbeddingSearchRequest.filter() metadata, the SQL injection can be triggered over the network through those application layers.

An attacker must be able to supply or control metadata keys or values that are forwarded into the embedding stores' filter mechanism. This may be direct (using the LangChain4j API) or indirect (via web or service APIs built on top of LangChain4j).

The safest approach is to eliminate dynamic SQL concatenation entirely by using parameterized queries and prepared statements, combined with an allowlist of valid metadata keys and strict validation for all filter inputs.

Adopt a standard practice of never embedding untrusted input into SQL command text, enforce secure query construction guidelines in code review, use static analysis to detect concatenated SQL, and design APIs so that clients interact with high-level filter abstractions rather than raw query fragments.

Find out what's already
exploitable in your codebase.