# GHSA-M8GQ-FMC8-F582: MongoDB: operator object in em.upsert() data is used as the update filter

- Database: GitHub
- Severity: CVSS 7.1 (High)
- Published: 2026-11-27
- Modified: 2026-11-27

## Affected versions

- @mikro-orm/mongodb (npm): from 7.0.0, through 7.2.12
- @mikro-orm/mongodb (npm): through 6.6.19

## Description

## Summary

`em.upsert()` and `em.upsertMany()` build the filter of the update from the values of the unique properties (or of `onConflictFields`) found in the entity data. With the MongoDB driver, a value that is an object with operator keys such as `$ne` or `$in` is interpreted as a query operator instead of a literal value, so the upsert matches and updates existing documents.

## Impact

Applications using the MongoDB driver are affected when a request-controlled value is used for a unique property or an `onConflictFields` property in upsert data without checking its type, e.g. `em.upsert(User, { email: body.email, ... })` where `body.email` comes from parsed JSON.

Passing an operator object instead of a string lets the caller choose which existing documents the upsert updates. The update is not restricted by entity filters, so documents of other users or tenants can be overwritten with the rest of the submitted data. The entity returned from the call is loaded with the same filter and contains the data of a matched document.

**Not** affected:

* SQL drivers, where the object is bound as a single value,
* upserts keyed by the primary key, as the resulting query is rejected by MongoDB,
* applications that validate the types of the incoming data before calling `em.upsert()`.

## Affected versions

| Line | Package | Affected versions |
|---|---|---|
| v7 | `@mikro-orm/mongodb` | `<= 7.2.12` |
| v6 | `@mikro-orm/mongodb` | `<= 6.6.19` |

## Patches

Fixed in **7.2.13** and **6.6.20**.

## Workarounds

Validate that the values used for unique properties in upsert data are scalars of the expected type.

## References

- https://github.com/mikro-orm/mikro-orm/security/advisories/GHSA-m8gq-fmc8-f582

Page: https://cve.now/GHSA-M8GQ-FMC8-F582

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
