Bug 16296 - [SECURITY] AD DC: by-value VLV search with a missing sort attribute crashes the LDAP worker (NULL dereference in vlv_value_compare)
Summary: [SECURITY] AD DC: by-value VLV search with a missing sort attribute crashes t...
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: AD: LDB/DSDB/SAMDB (show other bugs)
Version: 4.25.1
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-11-04 22:09 UTC by Zackary Loevseth
Modified: 2026-11-05 08:40 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zackary Loevseth 2026-11-04 22:09:11 UTC
vlv_value_compare() in source4/dsdb/samdb/ldb_modules/vlv_pagination.c uses the sort attribute's element without checking that it exists (master, lines 254-256):

    el = ldb_msg_find_element(result->msgs[0], target->attr);
    return target->comparison_fn(target->ldb, ac,
                                 &target->value, &el->values[0]);

server_sort keeps entries that lack the sort attribute and places them at the end, so a by-value VLV search whose results include such an entry reaches this line with el == NULL. The same happens when aclread removes a sort attribute the caller cannot read.

Reproduced on Samba 4.25.1 (Debian 4.25.1+dfsg-1, arm64, default prefork): an ordinary authenticated domain user searched CN=Users,DC=lab,DC=test, one level, filter (|(cn=canarya)(cn=canaryb)), attribute dn, with critical Server Side Sort on description (absent on both entries) and critical VLV by value "foo". The client got SERVER_DOWN; the LDAP worker logged Signal 11 and was restarted. A second client whose established connection was on the same worker was reset (errno 104). The same request by offset, and by value on a populated attribute, returned normally.

Control values as sent:
  Server Side Sort (1.2.840.113556.1.4.473): 300f300d040b6465736372697074696f6e
  VLV (2.16.840.1.113730.3.4.9), by value "foo": 300b0201000201008103666f6f

The unchecked access dates from the original VLV commit 79c58c2543790134ef8deb5307ec4b4ae069ea61 (first released in 4.5.0) and is unchanged in master (last change to the file: 48a0e7730f, which fixed a different NULL dereference in vlv_results()).

I will follow up with a GitLab merge request containing a fix and a test in source4/dsdb/tests/python/vlv.py, and add it under See Also.
Comment 1 Andrew Bartlett 2026-11-05 08:40:03 UTC
I'll get a CVE issued for this when we next get a batch, this is a public security bug as it is a DoS that we will eventually recover from.