Skip to main content
Menu
Advisories

Memory leak on duplicate fields in key vault documents in libmongocrypt

GHSA-2XQV-J3JP-FG52Published Updated GitHub

Description

libmongocrypt parses encryption key documents from the key vault collection, which can be written by any user authorized to manage client-side encryption keys. When a key vault document repeats a field, libmongocrypt parses the earlier occurrence and then overwrites it with the later one without releasing the earlier value.

Affected versions

  • >= 1.0.0, < 1.21.2

Impact

An improper handling of repeated fields in encryption key documents in the MongoDB encryption support library may allow memory to be retained without release. A party able to write to the key storage collection, or a database endpoint returning such a document, may cause the memory use of the calling application process to grow for each document parsed, which may reduce performance of that process.

A key vault document that repeats the _id, keyMaterial, or keyAltNames field retains the earlier value for the lifetime of the process.

Patches

libmongocrypt now rejects key vault documents that repeat a known field instead of parsing and overwriting the earlier occurrence.

Workarounds

Restrict write access to the key vault collection to trusted parties. Applications that cannot upgrade should validate key vault documents before use and reject any document that repeats a field.

References

References

GitHub · mongodb/libmongocrypt