JLSEC-2026-1389: Heap buffer overflow when `read_command` on a collection fails in Mongoc.jl

Published Nov 19, 2026
·
Updated

Description

Mongoc.readcommand(collection, command) called the wrong libmongoc function. Its binding for mongoccollectionreadcommandwithopts called mongoccollectioncommandsimple, which takes one argument fewer, so libmongoc read every argument after readprefs one place early. libmongoc wrote its bsonerrort into the reply document, wrote the reply into the caller's options document (or discarded it when no options were given), and never filled in the error that Mongoc.jl reads, so the exception thrown for a failure carried no error code or message.

The reply document is a 128-byte bsont that bsonnew allocates on the C heap. A bsonerrort is 512 bytes. When the command fails, libmongoc writes to the last byte of the error, 384 bytes past the end of the allocation. A message longer than about 120 bytes also writes its text past the end. The message comes from the MongoDB server or from libmongoc, and server messages can echo parts of the command: the error for an unknown query operator includes the operator's name.

Calls that succeeded returned an empty document instead of the reply. A call with options overwrote the caller's options document with the reply.

Only readcommand(collection, ...) is affected. A comparison of all of the package's ccalls with the libmongoc headers found no other wrong function or argument count.

Impact

Each failing readcommand(collection, ...) call corrupts the C heap of the Julia process. This can crash the process or corrupt unrelated memory. A malicious or compromised MongoDB server controls the text written past the allocation. When an application builds the command from user input, that user can influence the text too. No exploit beyond heap corruption was demonstrated.

Patches

Fixed in Mongoc.jl 0.10.2, which calls mongoccollectionreadcommandwithopts. Upgrade to 0.10.2 or later.

Workarounds

Mongoc.readcommand(collection.database, command; options) runs the same command through the database binding, which calls the correct function.

Credits

The binding error was found and fixed by hhaensel in Mongoc.jl pull request #162. The out-of-bounds write was found while that fix was reviewed.

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade julia/Mongoc to a version that resolves this vulnerability.

    Fixed in 0.10.2
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 0.10.2

Event History

Nov 19, 2026
Advisory Published
via OSV·10:47 PM
Data Sourced
via OSV·10:47 PM
DescriptionSeverityAffected Software

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203