Spring Data MongoDB - String query logic injection via function operator bind parameter

MEDIUM | NOVEMBER 19, 2026 | CVE-2026-59342

Description

Spring Data MongoDB's parameter binding mechanism for JSON-based query and aggregation using placeholder syntax did not contextually escape bound String argument values when those placeholders appeared inside a quoted string literal.

The application is vulnerable if all of the following are true:

  • MongoDB server-side JavaScript functions are enabled.
  • The application accepts input parameters from untrusted sources and uses them without prior sanitization as repository query method argument of type String.
  • The repository method is annotated with an MQL query template (e.g. @Query, @Aggregation) that uses a value placeholder inside a script expression (e.g. $accumulator, $function, $where, ...)

Affected Spring Products and Versions

Spring Data MongoDB:

  • 5.1.0 - 5.1.2
  • 5.0.0 - 5.0.8
  • 4.5.0 - 4.5.14
  • 4.4.0 - 4.4.16
  • 3.4.21 and earlier

Mitigation

Users of affected versions should upgrade to the corresponding fixed version.
Fix versionAvailability
5.1.3OSS
5.1.2.1Enterprise Support Only
5.0.9OSS
5.0.8.1Enterprise Support Only
4.5.15Enterprise Support Only
4.4.17Enterprise Support Only
3.4.22Enterprise Support Only

Upgrade to the latest supported version and enclose placeholders intended to receive String value inside quotes to enforce escaping.

Example:

@Query("{ $where : 'return this.firstname == \"?0\"' }")

Credit

The issue was reported responsibly by Tim Zheng (tim.zheng) - https://github.com/EaEa0001

History

  • 2026-11-19: Initial vulnerability report published.

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

TrueSource Spring Enterprise offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all