Sep 9, 2026·7 min read·71 visits
Improper input validation in MongoDB's PHP libraries allows attackers to inject dot characters and null bytes into database and collection name parameters, silently retargeting database queries and writes to administrative or system collections.
A high-severity namespace injection vulnerability in both the MongoDB Client Library for PHP (mongodb/mongodb) and the native PHP C Extension (ext-mongodb) allows unauthenticated remote attackers to bypass logical database separation and execute database commands inside unauthorized storage compartments via dot (".") and null byte ("\0") injection.
The MongoDB Client Library for PHP (mongodb/mongodb) and the underlying native PHP C Extension (ext-mongodb) are vulnerable to database and collection namespace injection. The flaw arises from an architectural pattern where fully qualified namespace strings are built by joining database and collection names with a period delimiter. When applications dynamically construct these names using untrusted inputs, they expose a highly sensitive interface to manipulation.
The vulnerability stems from the improper neutralization of special structural characters within these identifier inputs. Specifically, the software fails to reject period (.) characters in database names and null bytes (\0) in both database and collection names. This oversight allows remote users to alter the logical boundaries of database operations.
By injecting these characters, attackers can break out of their designated tenant databases and access administrative or restricted system namespaces. This vulnerability represents a class of injection that bypasses logical access controls, threatening data confidentiality and integrity across multi-tenant deployments.
MongoDB uses fully qualified namespace strings of the format databaseName.collectionName to direct read and write operations. The period character acts as a structural separator between the database component and the collection component. If an application accepts a database name containing a period character, the server parses the string using the first period as the delimiter. This shifts the target database and collection boundaries, allowing dot injection attacks.
In addition to dot injection, a severe binary-to-string representation mismatch exists between the PHP engine and the native C extension. PHP handles strings as length-prefixed, binary-safe structures that can natively contain null bytes (\0) without indicating string termination. Conversely, the underlying C library, libmongoc, relies on standard null-terminated C-style strings.
When a PHP string containing a null byte is passed to the C layer, the C library stops parsing at the first null byte. This causes string truncation, dropping the remainder of the namespace. An attacker can construct a string that passes user-land validation checks in PHP but is truncated in the C driver, silently redirecting operations to unauthorized databases.
The vulnerability in the PHP userland library was addressed by introducing strict validation within the Database and Collection class constructors. The patch introduces a centralized validation helper, create_namespace(), to enforce structural rules before names are combined.
// File: src/functions.php - Centered validation helper
function create_namespace(string $databaseName, string $collectionName): string
{
if ($databaseName === '' || str_contains($databaseName, '.') || str_contains($databaseName, "\0")) {
throw new InvalidArgumentException('$databaseName is invalid: ' . $databaseName);
}
if ($collectionName === '' || str_contains($collectionName, "\0")) {
throw new InvalidArgumentException('$collectionName is invalid: ' . $collectionName);
}
return $databaseName . '.' . $collectionName;
}Prior to this fix, the constructors in Collection.php only verified that the length of the database and collection names was greater than zero. This allowed arbitrary characters, including dots and null bytes, to propagate down to the native driver.
// File: src/Collection.php - Updated validation check
public function __construct(private Manager $manager, private string $databaseName, private string $collectionName, array $options = [])
{
if (strlen($databaseName) < 1 || str_contains($databaseName, '.') || str_contains($databaseName, "\0")) {
throw new InvalidArgumentException('$databaseName is invalid: ' . $databaseName);
}
if (strlen($collectionName) < 1 || str_contains($collectionName, "\0")) {
throw new InvalidArgumentException('$collectionName is invalid: ' . $collectionName);
}
}In the C extension layer (ext-mongodb), safety checks were added using memchr() to guarantee validation even when developers bypass the PHP library. The C function phongo_validate_dbname() now checks for the presence of null bytes and dots using the explicit length of the Zend string.
/* Rejects database name with NUL or period */
bool phongo_validate_dbname(const char* db, size_t db_len)
{
if (db == NULL) {
return true;
}
if (memchr(db, '\0', db_len) != NULL) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s", "Invalid database name provided: database names may not contain a null byte");
return false;
}
if (memchr(db, '.', db_len) != NULL) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s: %s", "Invalid database name provided: database names may not contain a '.' character", db);
return false;
}
return true;
}Exploiting this vulnerability requires an application to use untrusted user input to select or build the database or collection names. This pattern is commonly found in multi-tenant SaaS applications where tenant IDs are used directly to partition databases dynamically. An attacker must have network access to the application interface that processes these database-backed requests.
In a dot injection scenario, the attacker supplies a payload containing a dot character in a parameter intended to define the database name. For example, supplying admin.system as the database name causes the combined namespace to become admin.system.collectionName. The MongoDB server interprets admin as the database name and system.collectionName as the target collection, bypassing tenant database constraints.
In a null byte truncation scenario, the attacker injects a null character into the database name parameter, such as admin\x00tenant_db. PHP validates the full string length, but when passed to the C driver, the namespace string is truncated to admin. Any subsequent write or query commands are executed within the context of the administrative database, leading to privilege escalation.
The severity of CVE-2026-81525 is categorized as High, with a CVSS v3.1 score of 8.1 and a CVSS v4.0 score of 8.6. The primary impact is the collapse of logical access boundaries between different database tenants. Attackers can leverage this bypass to read, write, or delete documents belonging to other users or the platform itself.
A major consequence is unauthorized administrative database access. An attacker who can write to arbitrary namespaces can target internal system collections like system.users or system.views. In standard MongoDB deployments, writing to these collections can result in full database takeover and persistent privilege escalation.
Additionally, this vulnerability does not require authentication beyond the basic access needed to reach the vulnerable endpoint. If an unauthenticated public endpoint dynamically routes data to collections based on request headers or query variables, the vulnerability is fully exploitable by external actors.
The most effective remediation is upgrading the MongoDB PHP Client Library and the PHP C Extension to the patched versions. Applications running on the 1.x branch must upgrade the userland library to version 1.21.4 or higher, and the native extension to version 1.21.6 or higher. Teams running the 2.x branch must upgrade both components to version 2.4.1.
If immediate package upgrades are not possible, temporary input filtering must be applied in the application layer. All user inputs that influence database or collection identifiers must be rigorously sanitized. A strict allowlist approach should be used, rejecting any input containing dots, null bytes, or non-alphanumeric characters.
// Temporary verification helper
function secure_validate_db_identifier(string $input): bool
{
if (str_contains($input, "\0") || str_contains($input, ".")) {
return false;
}
return (bool) preg_match('/^[a-zA-Z0-9_-]+$/D', $input);
}In addition to code-level changes, organizations should audit database user privileges. Ensuring that application database credentials adhere to the principle of least privilege limits the potential damage of a namespace injection attack. For example, restricting the user's scope so they cannot access the admin database minimizes the impact of a successful injection attempt.
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N| Product | Affected Versions | Fixed Version |
|---|---|---|
mongodb/mongodb MongoDB | < 1.21.4 | 1.21.4 |
mongodb/mongodb MongoDB | >= 2.0.0, < 2.4.1 | 2.4.1 |
ext-mongodb MongoDB | < 1.21.6 | 1.21.6 |
ext-mongodb MongoDB | >= 2.0.0, < 2.4.1 | 2.4.1 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-943: Improper Neutralization of Special Elements in Data Query Logic |
| Attack Vector | Network (AV:N) |
| CVSS v4.0 Score | 8.6 (High) |
| EPSS Score | 0.00273 (19.38th Percentile) |
| Impact | Logical Security Boundary Bypass / Multi-Tenant Retargeting |
| Exploit Status | Proof-of-Concept (PoC) Released |
| KEV Status | Not Listed |
The software constructs a query or namespace using user input, but fails to neutralize or incorrectly neutralizes special elements that can modify the query logic.
CVE-2026-115886 (GHSA-2wqp-q3c6-ccj5) is a Server-Side Request Forgery (SSRF) and Unsafe Reflection vulnerability in MLflow versions 3.12.0rc0 prior to 3.17.0. Unauthenticated REST API endpoints accept serialized third-party scorer JSON payloads that are dynamically deserialized and reflectively instantiated without sanitizing constructor keyword arguments. When optional dependencies such as trulens and trulens-providers-litellm are installed, attackers can inject egress-steering arguments into the scorer payload, forcing the MLflow server to dispatch outbound HTTP requests to arbitrary internal destinations or cloud metadata services.
CVE-2026-113872 (GHSA-q7qp-rjg7-q26m) is a high-severity denial-of-service vulnerability affecting the multer multipart/form-data upload middleware for Node.js and Express in versions 2.0.0 through 2.4.0. When an endpoint is configured to accept multiple files using an asynchronous fileFilter callback, a crafted, truncated multipart HTTP request can trigger an unhandled error event on the underlying busboy stream parser after request teardown has already completed. Because all error listeners are stripped during teardown, Node.js treats the resulting error event as an uncaught exception and immediately terminates the server process.
CVE-2026-115897 (also tracked as GHSA-m5mm-p8h7-m29v and aliased as CVE-2026-115754) is a Cross-Site Scripting (XSS) vulnerability in the Yahoo serialize-javascript npm package prior to version 7.1.3. The flaw exists in the regular expression used by escapeFunctionBody() to neutralize HTML script closing tags within serialized JavaScript functions. Because function bodies are sanitized in isolation before structural formatting is applied, a function whose string representation terminates directly with the sequence '</script' bypasses the positive lookahead check. When combined with serialization formatting options that introduce whitespace delimiters and a subsequent property that supplies a closing bracket, an attacker can prematurely terminate an enclosing HTML <script> block and inject arbitrary HTML or JavaScript into the rendered document.
CVE-2026-109841 is a Subresource Integrity (SRI) verification bypass vulnerability in undici, the official HTTP/1.1 and HTTP/2 client library for Node.js that powers the global fetch() implementation. The flaw stems from improper handling of case sensitivity (CWE-178) when validating cryptographic hash algorithm tokens within SRI metadata. Because undici compared incoming algorithm identifiers against a strictly lowercase set without prior ASCII-lowercase normalization, valid uppercase or mixed-case tokens such as SHA256- or Sha384- were treated as unrecognized algorithms and discarded. Under SRI forward-compatibility rules, discarding all provided tokens results in an empty integrity list, causing undici to fail open and accept tampered HTTP response bodies without cryptographic verification.
A resource allocation vulnerability (CWE-770) exists in the Server-Sent Events (SSE) parser within the Node.js undici HTTP client library. In affected versions, the EventSourceStream implementation fails to restrict the count of internal Buffer chunk references and accumulated string nodes prior to event dispatch boundaries. A malicious or compromised SSE endpoint can exploit this behavior by streaming fragmented, unterminated lines or continuous sequences of short data fields without empty separator lines, bypassing configured byte-size limits and causing a fatal Out-of-Memory (OOM) crash in the client Node.js process.
CVE-2026-109869 is a high-severity denial-of-service vulnerability in undici, the default HTTP/1.1 client and Fetch implementation for Node.js. When a server responds with more than five Content-Encoding directives and prematurely closes the connection before transmitting the body, undici allocates an internal Readable stream before enforcing the content-encoding limit. Upon rejecting the fetch promise, the stream is orphaned without an error listener or abort signal, causing the premature socket closure to emit an unhandled stream error that terminates the Node.js process.