All reports
Medium

mongodb: Using $sample can trigger invariant when connecting directly to shards

Affected versions

Affected versions
Unknown
Fixed version
Not reported

Exploitation

CVE-2021-32037

Probability of exploitation in the next 30 days: 1.24%

FIRST EPSS · 2026-11-22

Description

An authorized user may trigger an invariant which may result in denial of service or server exit if a relevant aggregation request is sent to a shard. Usually, the requests are sent via mongos and special privileges are required in order to know the address of the shards and to log in to the shards of an auth enabled environment. This issue affects MongoDB Server v5.0 versions prior to and including 5.0.2.

An assertion flaw was found in the mongodb server where an aggregation request could trigger an invariant. An authorized user could exploit this flaw by sending a relevant aggregation request to a shard, which could result in a denial of service or server exit. Requests are usually sent via mongos and special privileges are required in order to know the address of the shards and to log in to the shards of an auth-enabled environment.