REDHAT-BUG-2583971: Medium severity Samba Samba vulnerability
The aclcheckdnshostname() function and the aclvalidatespnvalue() function in source4/dsdb/samdb/ldbmodules/acl.c read samAccountName->length without testing that the pointer is NULL. dsdbmsggetsinglevalue() in source4/dsdb/samdb/ldbmodules/util.c supplies that pointer.
On an LDAP modify, dsdbmsggetsinglevalue() starts from the sAMAccountName stored on the object. A delete of sAMAccountName in the same request, or a replace with no values, makes the function return success and a NULL pointer. aclmodify() walks the attributes in the order the client sent them. A validated write of dNSHostName or servicePrincipalName is checked while that NULL pointer is already the account-name value, and before the write-property check on the sAMAccountName element. The acl module is loaded ahead of samldb and objectclassattrs, which are the modules that reject removal of a mandatory sAMAccountName. On an add, the same helper returns NULL when the new object does not contain sAMAccountName. In aclvalidatespnvalue(), the dnsHostName and original dnsHostName pointers are tested before use. The sAMAccountName pointer is not.
The process handling the LDAP request terminates. The AD DC restarts that LDAP process. Repeating the request crashes it again, so the directory service stays unavailable for as long as the requests continue. The stored object is left unchanged because the fault happens before the modify is committed.
The caller is an authenticated domain principal that can perform a validated write of dNSHostName or servicePrincipalName on a computer object. The default computer class security descriptor grants that self-write to Principal Self and Creator Owner. A domain-joined computer has this right on its own account. The same request deletes sAMAccountName or replaces it with no values. Write property on the object is not required. A caller who already has write property returns before the read.
The modify path is reachable on a Samba AD DC in the default configuration.
The unchecked read was added with the validated-write work for CVE-2022-32743. Joseph Sutton added the dNSHostName read in commit b95431ab2303eb258e37e88d8841f2fb79fc4af5 on 2022-06-01, and the servicePrincipalName read in commit e1c52ac05a9ff505d2e5eac2f1ece4e95844ee71 on 2022-06-07. dsdbmsggetsinglevalue() was added in commit 49ac07e786df58b914ee85e2db773c0ba8d4e171 on 2022-06-07. Samba 4.17.0, released on 2022-09-13, is the first release that contains the code. The same read is absent from Samba 4.16.4, 4.15.9, and 4.14.14.
aclcheckspn() calls aclvalidatespnvalue() for servicePrincipalName. aclcheckdnshostname() has the same unchecked read for dNSHostName.
Affected Software
Event History
Frequently Asked Questions
What LDAP request pattern can trigger the failure?
An LDAP modify can delete sAMAccountName, or replace it with no values, and then include a validated write to dNSHostName or servicePrincipalName later in the client-supplied attribute order. The ACL code can dereference the now-NULL account-name value before the later validation rejects removal of the mandatory attribute.
Can an LDAP add operation also be affected?
Yes. On an add request, the helper returns a NULL account-name value when the new object does not contain sAMAccountName; the servicePrincipalName validation path does not test that pointer before using it.
Do downstream checks for mandatory sAMAccountName prevent the crash?
No. The ACL module runs before the samldb and objectclass_attrs modules that reject removal of a mandatory sAMAccountName, so the process can terminate before those checks are reached.
What is the observed impact when the issue is triggered?
The process handling the LDAP request terminates.