An LDAP search turns entries into objects, or a connection binds anonymously
What it finds
Two settings of JNDI's LDAP client make a directory dangerous to talk to: a search with its returning-object flag set, as new SearchControls(scope, limit, time, attrs, true, deref) or setReturningObjFlag(true), turns entries into Java objects and so runs deserialization on what the server sends; and the authentication "none" connects without credentials, so anyone can read or write what anonymous access allows.
From the rule's source, ldap_unsafe_options.rs.
import java.util.Hashtable;import javax.naming.Context;import javax.naming.directory.SearchControls; class Directory { void search(Hashtable<String, String> env, SearchControls given) { Object objects = new SearchControls(SearchControls.SUBTREE_SCOPE, 0, 0, null, true, true);tx0 reports: this search turns directory entries into Java objects Object plain = new SearchControls(SearchControls.SUBTREE_SCOPE, 0, 0, null, false, true); given.setReturningObjFlag(true);tx0 reports: turns directory entries into Java objects env.put(Context.SECURITY_AUTHENTICATION, "none");tx0 reports: this LDAP connection binds without credentials env.put(Context.SECURITY_AUTHENTICATION, "simple"); }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/java:ldap-unsafe-options" = "off"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/java:ldap-unsafe-options] reason="..."tx0 explain tx0/java:ldap-unsafe-options shows the same in the terminal. Found a false positive? Report it.