Authentication identity smuggling via NUL-byte injection in SASL PLAIN payload
Description
The MongoDB .NET/C# Driver did not neutralize NUL characters in the user name and password values it placed into the message it builds for SASL PLAIN authentication. A party who can choose the login values that an application passes to the driver can alter where the fields of that message begin and end. This may result in a receiving system reading a login name and secret that differ from the values the application supplied. Authenticating as a different account still requires that account's password. Only deployments that use SASL PLAIN authentication are affected.
Impact
Applications that use MONGODB-PLAIN authentication and that pass attacker-influenced values as the username or password. Exploitation is of low likelihood: the attacker needs valid credentials for the identity being targeted, but the consequence is authentication as a different identity.
Applications that do not use PLAIN authentication are not affected.
Patches
Fixed in MongoDB.Driver 3.14.1. The driver now rejects PLAIN usernames and passwords that contain a NUL character with an ArgumentException, both when the credential is created in code (for example MongoCredential.CreatePlainCredential) and when it is parsed from a connection string.
Behavior change: PLAIN credentials containing a NUL character that were previously accepted will now throw ArgumentException.
Workarounds
Validate that usernames and passwords supplied to PLAIN authentication do not contain NUL characters before passing them to the driver.