REDHAT-BUG-2585306: Medium severity Samba Samba vulnerability
vlvvaluecompare() in source4/dsdb/samdb/ldbmodules/vlvpagination.c looks up the sort attribute with ldbmsgfindelement() and passes el->values[0] to the attribute comparison function. The element pointer is used with no check that the lookup found an element.
A greater-than-or-equal Virtual List View search, control type 1, reaches this function from vlvresults() through vlvgteqtoindex(). The helper binary-searches the GUID list for that search. Each comparison looks the GUID up again and requests the sort attribute. serversort keeps an entry that has no value for the sort attribute and places that entry after entries that have a value, so the GUID stays in the list. The comparison lookup finds no element when the attribute is absent. It also finds no element when aclread has marked the attribute inaccessible and ldbmsgremoveinaccessible() has removed it, which is what happens when the caller cannot read the attribute. vlvvaluecompare() then reads el->values[0]. This path is the same from samba 4.5.0 through samba 4.25.1 and on the current master branch.
The read faults the LDAP worker process. In the default prefork model that worker serves multiple client connections, and 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. A caller who repeats the search can exit the LDAP workers and leave them stopped for that delay.
The caller is authenticated and can search at least one directory object. rootdsefilteroperations() permits an anonymous operation only for a base-scoped search of an empty DN, unless dSHeuristics turns that block off. The search uses a server-side sort control and a greater-than-or-equal Virtual List View control. At least one returned object lacks the sort attribute, or the caller cannot read it.
The flaw is reachable in the default configuration. The vlv module is in the default sambadsdb module list. The acl search check defaults to enabled. The samba process model defaults to prefork.
Introduced in samba 4.5.0 by commit 79c58c2543790134ef8deb5307ec4b4ae069ea61 (Douglas Bagnall, 22 March 2016), when Virtual List View support was added. The unchecked use of el->values[0] has been in the function since that commit.
vlvvaluecomparerev() calls vlvvaluecompare() and returns the negated comparison, so a reverse greater-than-or-equal search uses the same missing element.
Affected Software
Event History
Frequently Asked Questions
Which LDAP requests can reach the faulting code path?
A greater-than-or-equal Virtual List View search using control type 1 reaches the affected comparison path. The path performs a binary search over the GUID list and retrieves the requested sort attribute for each comparison.
Can an entry that lacks the requested sort attribute trigger the issue?
Yes. server_sort retains entries without a value for the sort attribute, placing them after entries that have a value, so their GUIDs can remain in the searched list. Looking up the absent attribute then returns no element before the code reads from it.
Do LDAP access controls affect exposure?
Yes. The issue can also occur when the entry has the sort attribute but the LDAP caller cannot read it. aclread removes inaccessible attributes, causing the later lookup to find no element.
What is the operational impact of a successful trigger?
The invalid read faults the LDAP worker process. Under the default prefork model, that worker may be serving multiple client connections.
What Samba versions are identified as affected?
The affected path is reported from Samba 4.5.0 through Samba 4.25.1, and on the current master branch.