REDHAT-BUG-2587434: High severity Samba Samba vulnerability
ldapsrvdocall() in source4/ldapserver/ldapbackend.c uses the wrong message tag in the check that decides whether to log a connection that has not bound. When authzlogged is false, the arm labeled LDAPTAGExtendedResponse reads call->request->r.ExtendedRequest and calls strcmp() on oid.
ldapdecode() in libcli/ldap/ldapmessage.c stores an extended response in r.ExtendedResponse. ldapdecoderesponse() writes the result code into the ldapResult at the start of that arm. The oid field of ldapExtendedRequest occupies those same leading bytes. ldapsrvcallreaddone() decodes the packet and queues the call. ldapsrvprocesscalltrigger() calls ldapsrvdocall() with no bind check. The connection is allocated with talloczero(), so authzlogged is false for the first message. A later switch in ldapsrvdocall() calls ldapsrvExtendedRequest() for LDAPTAGExtendedRequest and calls ldapsrvunwilling() for a tag it does not list. The logging check runs before that switch. The wrong tag is present in samba 4.7.0rc1, in samba 4.25.1, and on the current master branch.
strcmp() dereferences the value in those leading bytes. Those bytes hold the result code and the alignment padding after it. They are not an OID string. The dereference faults the ldap worker. faultsetup() installs sigfault() for SIGSEGV, sigfault() calls faultreport(), and faultreport() calls smbpanic(), which aborts the worker. In the default prefork model the ldap service has its own master and workers, and each worker serves more than one client connection. Those connections end when the process exits. The prefork master starts a replacement worker. The first restart delay is 0. Each later exit of that worker adds the prefork backoff increment to the delay, up to the prefork maximum backoff. Those defaults are 10 seconds and 120 seconds. The default number of prefork children is 4. A caller who repeats the extended response can exit the ldap workers and leave them stopped for that delay. The rpc and kdc services are separate prefork services.
The caller is not authenticated. The logging check runs while authzlogged is false, which is the state of a new connection. The message is an LDAP extended response, and it is the first message on the connection.
The flaw is reachable in the default configuration of an AD DC. The serviceldap module is built when the AD DC build is enabled. ldapsrvtaskinit() starts the LDAP server only when the server role is an Active Directory domain controller, and that server listens on port 389. The default server services list includes ldap, and the samba process model defaults to prefork.
Introduced in samba 4.7.0rc1 by commit f4a4522d1f8c19fdf142e12760160b15de1557ec (Andrew Bartlett, 3 March 2017), when logging of LDAP access before a bind was added. The wrong tag has been in that logging check since that commit. It is present in samba 4.7.0rc1, in samba 4.7.0, in samba 4.25.1, and on the current master branch. samba 4.6.16 does not contain the commit.
Affected Software
Event History
Frequently Asked Questions
What does an attacker need to do to reach the vulnerable path?
They need to send an LDAP packet decoded as an ExtendedResponse on a connection that has not yet bound. The first message on a newly allocated connection reaches this path because authz_logged is initially false and processing occurs without a bind check.
Which Samba versions are explicitly identified as containing the incorrect tag check?
The issue is stated to be present in Samba 4.7.0rc1, Samba 4.25.1, and the current master branch. No complete affected-version range is provided.
Why can an ExtendedResponse trigger unsafe handling?
The logging check treats an ExtendedResponse as an ExtendedRequest and passes the interpreted request oid to strcmp(). For a decoded ExtendedResponse, those bytes instead contain the result code and alignment padding.