JLSEC-2026-1389

Vulnerability from osv_julia – Published: 2026-11-19 22:47 – Updated: 2026-11-19 22:47 – Source website
VLAI
Summary
Heap buffer overflow when `read_command` on a collection fails in Mongoc.jl
Details

Description

Mongoc.read_command(collection, command) called the wrong libmongoc function. Its binding for mongoc_collection_read_command_with_opts called mongoc_collection_command_simple, which takes one argument fewer, so libmongoc read every argument after read_prefs one place early. libmongoc wrote its bson_error_t 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 bson_t that bson_new allocates on the C heap. A bson_error_t 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 read_command(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 read_command(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 mongoc_collection_read_command_with_opts. Upgrade to 0.10.2 or later.

Workarounds

Mongoc.read_command(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.

Impacted products
Ecosystem Package Version
Julia Mongoc
pkg:julia/Mongoc?uuid=4fe8b98c-fc19-5c23-8ec2-168ff83495f2
Affected: ≥ 0.4.0, < 0.10.2 (semver)

{
  "affected": [
    {
      "package": {
        "ecosystem": "Julia",
        "name": "Mongoc",
        "purl": "pkg:julia/Mongoc?uuid=4fe8b98c-fc19-5c23-8ec2-168ff83495f2"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0.4.0"
            },
            {
              "fixed": "0.10.2"
            }
          ],
          "type": "SEMVER"
        }
      ]
    }
  ],
  "credits": [
    {
      "contact": [
        "https://github.com/hhaensel"
      ],
      "name": "hhaensel",
      "type": "REMEDIATION_DEVELOPER"
    }
  ],
  "database_specific": {
    "license": "CC-BY-4.0"
  },
  "details": "### Description\n\n`Mongoc.read_command(collection, command)` called the wrong libmongoc function. Its binding for\n`mongoc_collection_read_command_with_opts` called `mongoc_collection_command_simple`, which takes one\nargument fewer, so libmongoc read every argument after `read_prefs` one place early. libmongoc wrote\nits `bson_error_t` into the reply document, wrote the reply into the caller\u0027s `options` document (or\ndiscarded it when no options were given), and never filled in the error that Mongoc.jl reads, so\nthe exception thrown for a failure carried no error code or message.\n\nThe reply document is a 128-byte `bson_t` that `bson_new` allocates on the C heap. A `bson_error_t`\nis 512 bytes. When the command fails, libmongoc writes to the last byte of the error, 384 bytes past\nthe end of the allocation. A message longer than about 120 bytes also writes its text past the end.\nThe message comes from the MongoDB server or from libmongoc, and server messages can echo parts of\nthe command: the error for an unknown query operator includes the operator\u0027s name.\n\nCalls that succeeded returned an empty document instead of the reply. A call with `options`\noverwrote the caller\u0027s options document with the reply.\n\nOnly `read_command(collection, ...)` is affected. A comparison of all of the package\u0027s `ccall`s with\nthe libmongoc headers found no other wrong function or argument count.\n\n### Impact\n\nEach failing `read_command(collection, ...)` call corrupts the C heap of the Julia process. This can\ncrash the process or corrupt unrelated memory. A malicious or compromised MongoDB server controls the\ntext written past the allocation. When an application builds the command from user input, that user\ncan influence the text too. No exploit beyond heap corruption was demonstrated.\n\n### Patches\n\nFixed in Mongoc.jl 0.10.2, which calls `mongoc_collection_read_command_with_opts`. Upgrade to 0.10.2\nor later.\n\n### Workarounds\n\n`Mongoc.read_command(collection.database, command; options)` runs the same command through the\ndatabase binding, which calls the correct function.\n\n### Credits\n\nThe binding error was found and fixed by hhaensel in Mongoc.jl pull request #162. The out-of-bounds\nwrite was found while that fix was reviewed.",
  "id": "JLSEC-2026-1389",
  "modified": "2026-11-19T22:47:03.447Z",
  "published": "2026-11-19T22:47:03.447Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/JuliaDatabases/Mongoc.jl/commit/793615d2af2e0e103d2e92e8a3bd725cdf7de2c0"
    },
    {
      "type": "WEB",
      "url": "https://github.com/JuliaDatabases/Mongoc.jl/pull/162"
    },
    {
      "type": "WEB",
      "url": "https://github.com/JuliaDatabases/Mongoc.jl/releases/tag/v0.10.2"
    }
  ],
  "schema_version": "1.8.0",
  "severity": [
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N",
      "source": "SELF",
      "type": "CVSS_V4"
    }
  ],
  "summary": "Heap buffer overflow when `read_command` on a collection fails in Mongoc.jl"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline

Sightings and recorded dates, grouped by day · UTC

JSON
How durations are calculated

Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation.

Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.

Events included in the timeline

Loading timeline…


    Loading…

    Loading…

    Loading…

    Related by attack behaviour

    Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.