A directory connection binds anonymously or with a clear text password
What it finds
A directory connection that binds anonymously or without authentication lets the program read, and with a permissive server change, entries as nobody in particular; whatever the program shows from the directory can then come from anyone who can reach it. Basic authentication sends the password in clear text. Directory connections authenticate with Negotiate, Kerberos or Secure binding, over TLS where possible.
Reported are AuthenticationTypes.None and AuthenticationTypes.Anonymous of System.DirectoryServices and AuthType.Anonymous and AuthType.Basic of System.DirectoryServices.Protocols, in files that import one of them, outside attributes.
From the rule's source, ldap_anonymous_bind.rs.
using System.DirectoryServices;using System.DirectoryServices.Protocols; class Directory{ DirectoryEntry Open(string path) { var entry = new DirectoryEntry(path); entry.AuthenticationType = AuthenticationTypes.None;tx0 reports: the directory connection does not authenticate return new DirectoryEntry(path, null, null, AuthenticationTypes.Anonymous);tx0 reports: the directory connection binds anonymously } void Bind(LdapConnection connection) { connection.AuthType = AuthType.Basic;tx0 reports: the directory connection sends the password in clear text connection.AuthType = AuthType.Negotiate; var entry = new DirectoryEntry("LDAP://dc", "u", "p", AuthenticationTypes.Secure); }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:ldap-anonymous-bind" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:ldap-anonymous-bind] reason="..."tx0 explain tx0/csharp:ldap-anonymous-bind shows the same in the terminal. Found a false positive? Report it.