Skip to main content
Menu
Advisories

Authentication identity smuggling via NUL characters in username and password options in the PHP Driver

GHSA-XXPM-9Q2V-748WPublished Updated GitHub

Description

Impact

The MongoDB PHP Driver extension passes the username and password URI options to libmongoc as C strings. A value containing a NUL character is silently truncated at that character instead of being rejected. When SASL PLAIN authentication is used (for example, with LDAP), the username and password are sent in a single NUL-delimited message. An application that builds credentials from untrusted input can therefore have extra fields injected into the authentication message, which may let a user authenticate as a different identity.

Exploitation requires the application to pass attacker-influenced values as the username or password options, and the attacker needs valid credentials for the identity being targeted. Credentials supplied in the connection string are not affected, because libmongoc already rejects a percent-encoded NUL (%00).

Patches

Fixed in MongoDB PHP Driver 1.21.16, 2.1.16, and 2.5.10. The driver now throws MongoDB\Driver\Exception\InvalidArgumentException when the username or password option contains a NUL character. Users should upgrade to a patched release.

Workarounds

Validate that credentials do not contain NUL characters before passing them to the MongoDB\Driver\Manager constructor or the username and password URI options. Avoid PLAIN authentication with untrusted credential input.

References

Affected versions

References

GitHub · mongodb/mongo-php-driver