public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Viktor Ashirov <vashirov@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/389-ds-base] f44: - Resolves CVE-2026-86344
Date: Tue, 01 Dec 2026 12:39:13 GMT [thread overview]
Message-ID: <179612875301.1.4703083470783403505.rpms-389-ds-base-8c5dd3958c7a@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/389-ds-base
Branch : f44
Commit : 8c5dd3958c7a30d9c4b2d97dc6ee1bf4a19086d8
Author : Viktor Ashirov <vashirov@redhat.com>
Date : 2026-11-30T14:03:42+01:00
Stats : +3222/-0 in 11 file(s)
URL : https://src.fedoraproject.org/rpms/389-ds-base/c/8c5dd3958c7a30d9c4b2d97dc6ee1bf4a19086d8?branch=f44
Log:
- Resolves CVE-2026-86344
- Resolves CVE-2026-86345
- Resolves CVE-2026-115422
- Resolves CVE-2026-118469
- Resolves CVE-2026-118472
- Resolves CVE-2026-118474
- Resolves CVE-2026-119584
---
diff --git a/0002-Security-fix-for-CVE-2026-115422.patch b/0002-Security-fix-for-CVE-2026-115422.patch
new file mode 100644
index 0000000..2630e32
--- /dev/null
+++ b/0002-Security-fix-for-CVE-2026-115422.patch
@@ -0,0 +1,560 @@
+From 722a01b085218b04bbfb731d461b382d9a5b587a Mon Sep 17 00:00:00 2001
+From: Viktor Ashirov <vashirov@redhat.com>
+Date: Thu, 29 Oct 2026 11:52:29 +0100
+Subject: [PATCH] Security fix for CVE-2026-115422
+
+Description:
+The VLV response control sends `contentCount`. The server calculated this
+count in `vlv_filter_candidates()` without access control. The function
+also did not check the entry READ right. A client can test a hidden value
+with an assertion, for example `(userPassword:2.5.13.18:=...)`, and
+rebuild the value byte by byte. For a hidden attribute no entry was
+returned. A client with only the SEARCH right can do the same with
+substring, ordering and explicit matching rule assertions.
+
+Fix:
+- Check the filter with access control in `vlv_filter_candidates()`.
+- Check the entry READ right, same as `send_ldap_search_entry_ext()`.
+- Use the filter as the client sent it, not the internal rewritten
+ filter.
+- Require the READ right as well as SEARCH for substring, ordering and
+ explicit matching rule assertions. Presence and equality checks still
+ work with only SEARCH.
+- Add tests for each case.
+
+References:
+- https://access.redhat.com/security/cve/CVE-2026-115422
+- https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2026-115422
+
+Reviewed-by: Pierre Rogier <progier@redhat.com>
+Reviewed-by: Thierry Bordaz <tbordaz@redhat.com>
+---
+ dirsrvtests/tests/suites/vlv/vlv_acl_test.py | 279 +++++++++++++++++++
+ ldap/servers/slapd/back-ldbm/ldbm_search.c | 7 +-
+ ldap/servers/slapd/back-ldbm/vlv.c | 15 +-
+ ldap/servers/slapd/filterentry.c | 94 ++++---
+ 4 files changed, 357 insertions(+), 38 deletions(-)
+ create mode 100644 dirsrvtests/tests/suites/vlv/vlv_acl_test.py
+
+diff --git a/dirsrvtests/tests/suites/vlv/vlv_acl_test.py b/dirsrvtests/tests/suites/vlv/vlv_acl_test.py
+new file mode 100644
+index 000000000..7276cea52
+--- /dev/null
++++ b/dirsrvtests/tests/suites/vlv/vlv_acl_test.py
+@@ -0,0 +1,279 @@
++# --- BEGIN COPYRIGHT BLOCK ---
++# Copyright (C) 2026 Red Hat, Inc.
++# All rights reserved.
++#
++# License: GPL (version 3 or any later version).
++# See LICENSE for details.
++# --- END COPYRIGHT BLOCK ---
++
++"""Access control checks for VLV search candidate counting.
++
++The VLV response control reports the number of entries matching the search
++filter (contentCount) even when no entry can be returned to the client, so
++the filtered candidate list must only contain entries the client could also
++receive from an ordinary search. Otherwise a filter assertion against a
++hidden attribute value - an octetStringOrderingMatch (2.5.13.18) assertion
++on userPassword, for example - turns contentCount into an oracle that
++reveals whether the stored value sorts below the assertion, and repeating
++the query reconstructs the whole value byte by byte.
++
++Filter assertions that disclose value fragments or ordering - substring,
++>=, <= and extensible match with an explicit matching rule - additionally
++require the READ right on the attribute, so a SEARCH-only presence-check
++grant cannot turn filtering itself into a value oracle either.
++"""
++
++import logging
++import os
++
++import ldap
++import pytest
++from ldap.controls.sss import SSSRequestControl
++from ldap.controls.vlv import VLVRequestControl, VLVResponseControl
++
++from lib389._constants import DEFAULT_SUFFIX
++from lib389._mapped_object import DSLdapObject
++from lib389.idm.account import Anonymous
++from lib389.idm.organizationalunit import OrganizationalUnits
++from lib389.idm.user import UserAccounts
++from test389.topologies import topology_st as topo
++
++pytestmark = pytest.mark.tier1
++
++DEBUGGING = os.getenv("DEBUGGING", default=False)
++if DEBUGGING:
++ logging.getLogger(__name__).setLevel(logging.DEBUG)
++else:
++ logging.getLogger(__name__).setLevel(logging.INFO)
++log = logging.getLogger(__name__)
++
++TEST_OU = "vlv_acl"
++TEST_PW = "vlv_acl_pw"
++VICTIM_UID = "vlv_victim"
++ATTACKER_UID = "vlv_attacker"
++# Stored password hashes are in the {SCHEME}... form and therefore sort
++# between these two assertion values.
++LOW_ASSERTION = "!"
++HIGH_ASSERTION = "~"
++
++# The tests run under the access model the oracle was reported against: the
++# tree is searchable through public attributes while secrets stay hidden,
++# and the VLV control is open to anonymous clients the way FreeIPA's
++# Solaris-compatibility policy rewrites the stock feature ACI.
++VLV_FEATURE_DN = 'oid=2.16.840.1.113730.3.4.9,cn=features,cn=config'
++VLV_ANYONE_ACI = ('(targetattr != "aci")(version 3.0; acl "VLV Request Control"; '
++ 'allow (read, search, compare, proxy) userdn = "ldap:///anyone";)')
++PUBLIC_READ_ACI = ('(targetattr="uid || cn || sn || objectClass")'
++ '(version 3.0; acl "vlv_acl_test public read"; '
++ 'allow (read, search, compare) userdn="ldap:///anyone";)')
++
++
++def vlv_content_count(conn, base, filterstr, scope=ldap.SCOPE_ONELEVEL):
++ """Run a VLV search by index and return the contentCount reported in
++ the VLV response control."""
++ vlv_control = VLVRequestControl(criticality=True,
++ before_count=0,
++ after_count=0,
++ offset=1,
++ content_count=0,
++ greater_than_or_equal=None,
++ context_id=None)
++ sss_control = SSSRequestControl(criticality=True, ordering_rules=['cn'])
++ msg_id = conn.search_ext(base, scope, filterstr,
++ serverctrls=[vlv_control, sss_control])
++ rtype, rdata, rmsgid, rctrls = conn.result3(msg_id)
++ for ctrl in rctrls:
++ if ctrl.controlType == VLVResponseControl.controlType:
++ return ctrl.content_count
++ raise AssertionError('No VLV response control returned')
++
++
++@pytest.fixture(scope="module")
++def vlv_acl_entries(topo, request):
++ """Create a test OU with a password-protected victim, an attacker
++ user and two filler users, then apply the access model the tests
++ assume: anyone may read public attributes and use the VLV control,
++ while userPassword stays hidden."""
++ inst = topo.standalone
++ ous = OrganizationalUnits(inst, DEFAULT_SUFFIX)
++ ou = ous.create(properties={'ou': TEST_OU})
++ users = UserAccounts(inst, ou.dn, rdn=None)
++ entries = {'ou': ou, 'users': users}
++ uid_number = 10100
++ for uid in (VICTIM_UID, ATTACKER_UID, "vlv_user_a", "vlv_user_b"):
++ uid_number += 1
++ entries[uid] = users.create(properties={
++ 'uid': uid,
++ 'cn': uid,
++ 'sn': 'user',
++ 'uidNumber': str(uid_number),
++ 'gidNumber': str(uid_number),
++ 'homeDirectory': f'/home/{uid}',
++ 'userPassword': TEST_PW,
++ })
++ # A stock instance only lets authenticated users search user entries
++ # and use the VLV control; grant anyone both so the anonymous variant
++ # of the oracle is covered too.
++ ou.add('aci', PUBLIC_READ_ACI)
++ vlv_feature = DSLdapObject(inst, dn=VLV_FEATURE_DN)
++ vlv_feature.add('aci', VLV_ANYONE_ACI)
++
++ def fin():
++ if not DEBUGGING:
++ vlv_feature.remove('aci', VLV_ANYONE_ACI)
++ for user in users.list():
++ user.delete()
++ ou.delete()
++
++ request.addfinalizer(fin)
++ return entries
++
++
++@pytest.fixture
++def ou_aci(vlv_acl_entries):
++ """Add ACIs to the test OU, removing them after the test."""
++ ou = vlv_acl_entries['ou']
++ added = []
++
++ def add(aci):
++ ou.add('aci', aci)
++ added.append(aci)
++
++ yield add
++
++ for aci in added:
++ ou.ensure_removed('aci', aci)
++
++
++def test_vlv_count_does_not_leak_hidden_attribute_values(topo, vlv_acl_entries):
++ """VLV contentCount must not disclose hidden attribute values
++
++ :id: f01b9c8c-62ad-45f8-bfa4-b02fce512f01
++ :setup: Standalone instance, a password-protected user under a test OU
++ :steps:
++ 1. As anonymous, run a VLV search whose filter combines the victim
++ uid with an octetStringOrderingMatch assertion on userPassword
++ sorting below every stored hash
++ 2. Repeat with an assertion sorting above every stored hash
++ 3. Run an ordinary (non-VLV) search with the same assertion
++ 4. As anonymous, run the same VLV search filtering on a public
++ attribute only
++ :expectedresults:
++ 1. contentCount is 0
++ 2. contentCount is 0 - the count must not depend on the assertion
++ 3. No entry is returned
++ 4. contentCount is 1 - the entry is visible through public
++ attributes, so counting is not disabled wholesale
++ """
++ conn = Anonymous(topo.standalone).bind()
++ base = vlv_acl_entries['ou'].dn
++ users = UserAccounts(conn, base, rdn=None)
++ for assertion in (LOW_ASSERTION, HIGH_ASSERTION):
++ flt = (f'(&(uid={VICTIM_UID})'
++ f'(userPassword:2.5.13.18:={assertion}))')
++ log.info(f'Checking VLV count for filter {flt}')
++ assert vlv_content_count(conn, base, flt) == 0
++ assert users.filter(flt) == []
++ assert vlv_content_count(conn, base, f'(uid={VICTIM_UID})') == 1
++
++
++def test_vlv_count_privileged_client(topo, vlv_acl_entries):
++ """VLV searches and extensible matching keep working with full access
++
++ :id: 7b2aba22-5c44-4352-bd0b-0993df2b3fc3
++ :setup: Standalone instance, a password-protected user under a test OU
++ :steps:
++ 1. As Directory Manager, run a VLV search filtering on uid
++ 2. As Directory Manager, run VLV searches whose filters combine the
++ victim uid with octetStringOrderingMatch assertions on
++ userPassword below and above the stored hash
++ :expectedresults:
++ 1. contentCount is 1
++ 2. The two assertions bracket the stored hash, so exactly one of
++ the searches reports contentCount 1 and the other 0
++ """
++ base = vlv_acl_entries['ou'].dn
++ assert vlv_content_count(topo.standalone, base, f'(uid={VICTIM_UID})') == 1
++ counts = []
++ for assertion in (LOW_ASSERTION, HIGH_ASSERTION):
++ flt = (f'(&(uid={VICTIM_UID})'
++ f'(userPassword:2.5.13.18:={assertion}))')
++ counts.append(vlv_content_count(topo.standalone, base, flt))
++ assert sorted(counts) == [0, 1]
++
++
++def test_vlv_count_respects_entry_access(topo, vlv_acl_entries, ou_aci):
++ """VLV contentCount must not count entries the client cannot access
++
++ :id: 76e0c723-0a5a-4cd7-951a-98bdccad2806
++ :setup: Standalone instance, four users under a test OU
++ :steps:
++ 1. Deny the attacker all access to one of the users
++ 2. As the attacker, run a VLV search over the OU with a filter on
++ a public attribute
++ 3. Repeat the same search as Directory Manager
++ 4. As the attacker, run an ordinary search with the same filter
++ :expectedresults:
++ 1. The ACI is added
++ 2. contentCount is 3 - only the accessible entries are counted
++ 3. contentCount is 4
++ 4. Three entries are returned
++ """
++ ou = vlv_acl_entries['ou']
++ hidden_dn = f'uid=vlv_user_a,{ou.dn}'
++ aci = (f'(target="ldap:///{hidden_dn}")(targetattr="*")'
++ '(version 3.0; acl "vlv hide entry"; deny (all) '
++ f'userdn="ldap:///uid={ATTACKER_UID},{ou.dn}";)')
++ ou_aci(aci)
++ conn = vlv_acl_entries[ATTACKER_UID].bind(TEST_PW)
++ users = UserAccounts(conn, ou.dn, rdn=None)
++ assert vlv_content_count(conn, ou.dn, '(uid=*)') == 3
++ assert vlv_content_count(topo.standalone, ou.dn, '(uid=*)') == 4
++ assert len(users.filter('(uid=*)')) == 3
++
++
++def test_vlv_count_with_search_only_grant(topo, vlv_acl_entries, ou_aci):
++ """A SEARCH-only grant must not enable value assertions
++
++ :id: d83079f0-25ab-4d9a-bd78-6c0f0a8f54d8
++ :setup: Standalone instance, a password-protected user under a test OU
++ :steps:
++ 1. Grant the attacker SEARCH (but not READ) access to userPassword,
++ as password presence checks do
++ 2. As the attacker, run a VLV search with a presence filter on
++ userPassword
++ 3. As the attacker, run VLV searches and ordinary searches combining
++ the victim uid with substring, greater-or-equal, less-or-equal
++ and octetStringOrderingMatch assertions on userPassword
++ 4. As the attacker, request the userPassword attribute
++ :expectedresults:
++ 1. The ACI is added
++ 2. contentCount is 1 - presence checks keep working under SEARCH
++ 3. contentCount is 0 and no entry is returned for every assertion -
++ assertions that disclose value fragments or ordering require the
++ READ right, so a SEARCH-only presence-check grant cannot turn
++ filtering into a value oracle, through VLV or ordinary search
++ 4. The entry is returned but userPassword is not disclosed
++ """
++ ou = vlv_acl_entries['ou']
++ aci = ('(targetattr="userPassword")'
++ '(version 3.0; acl "vlv presence check grant"; allow (search) '
++ f'userdn="ldap:///uid={ATTACKER_UID},{ou.dn}";)')
++ ou_aci(aci)
++ conn = vlv_acl_entries[ATTACKER_UID].bind(TEST_PW)
++ users = UserAccounts(conn, ou.dn, rdn=None)
++ assert vlv_content_count(
++ conn, ou.dn, f'(&(uid={VICTIM_UID})(userPassword=*))') == 1
++ value_assertions = (
++ f'(userPassword={LOW_ASSERTION}*)',
++ f'(userPassword>={LOW_ASSERTION})',
++ f'(userPassword<={HIGH_ASSERTION})',
++ f'(userPassword:2.5.13.18:={LOW_ASSERTION})',
++ f'(userPassword:2.5.13.18:={HIGH_ASSERTION})',
++ )
++ for assertion_filter in value_assertions:
++ flt = f'(&(uid={VICTIM_UID}){assertion_filter})'
++ assert vlv_content_count(conn, ou.dn, flt) == 0
++ assert users.filter(flt) == []
++ victim = users.get(VICTIM_UID)
++ assert not victim.get_attr_vals('userPassword')
+diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
+index ec9bdb5e7..224caf9a1 100644
+--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
++++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
+@@ -839,7 +839,12 @@ ldbm_back_search(Slapi_PBlock *pb)
+ if (virtual_list_view && candidates) {
+ IDList *idl = NULL;
+ Slapi_Filter *filter = NULL;
+- slapi_pblock_get(pb, SLAPI_SEARCH_FILTER, &filter);
++ /* Use the filter as the client sent it. The rewritten
++ * filter adds internal terms. */
++ slapi_pblock_get(pb, SLAPI_SEARCH_FILTER_INTENDED, &filter);
++ if (filter == NULL) {
++ slapi_pblock_get(pb, SLAPI_SEARCH_FILTER, &filter);
++ }
+ rc = LDAP_OPERATIONS_ERROR;
+ if (filter) {
+ rc = vlv_filter_candidates(be, pb, candidates, basesdn,
+diff --git a/ldap/servers/slapd/back-ldbm/vlv.c b/ldap/servers/slapd/back-ldbm/vlv.c
+index f2f882b5a..d383e76ef 100644
+--- a/ldap/servers/slapd/back-ldbm/vlv.c
++++ b/ldap/servers/slapd/back-ldbm/vlv.c
+@@ -29,6 +29,13 @@
+ #include "vlv_srch.h"
+ #include "vlv_key.h"
+
++/* Match ldbm_search.c: DISABLE_ACL_CHECK builds skip ACL checks. */
++#if defined(DISABLE_ACL_CHECK)
++#define VLV_VERIFY_ACCESS 0
++#else
++#define VLV_VERIFY_ACCESS 1
++#endif
++
+ static PRUint32 vlv_trim_candidates_byindex(PRUint32 length, const struct vlv_request *vlv_request_control);
+ static PRUint32 vlv_trim_candidates_byvalue(backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, back_txn *txn);
+ static int vlv_build_candidate_list(backend *be, struct vlvIndex *p, const struct vlv_request *vlv_request_control, IDList **candidates, struct vlv_response *vlv_response_control, int is_srchlist_locked, back_txn *txn);
+@@ -1471,7 +1478,13 @@ vlv_filter_candidates(backend *be, Slapi_PBlock *pb, const IDList *candidates, c
+ } else {
+ lookedat++;
+ if (slapi_sdn_scope_test(backentry_get_sdn(e), base, scope)) {
+- if (slapi_filter_test(pb, e->ep_entry, filter, 0 /* No ACL Check */) == 0) {
++ /* Count only entries this client could receive
++ * from an ordinary search. Otherwise `contentCount`
++ * shows whether hidden values match the filter. */
++ if (slapi_vattr_filter_test(pb, e->ep_entry, filter, VLV_VERIFY_ACCESS) == 0 &&
++ (VLV_VERIFY_ACCESS == 0 ||
++ plugin_call_acl_plugin(pb, e->ep_entry, NULL, NULL, SLAPI_ACL_READ,
++ ACLPLUGIN_ACCESS_READ_ON_ENTRY, NULL) == LDAP_SUCCESS)) {
+ /* The entry passed the filter test, add the id to the list */
+ slapi_log_err(SLAPI_LOG_TRACE, "vlv_filter_candidates",
+ "Candidate %lu Passed Filter\n", (u_long)id);
+diff --git a/ldap/servers/slapd/filterentry.c b/ldap/servers/slapd/filterentry.c
+index ce17f99fd..1e9c62e94 100644
+--- a/ldap/servers/slapd/filterentry.c
++++ b/ldap/servers/slapd/filterentry.c
+@@ -26,8 +26,21 @@ static int vattr_test_filter_list_and(Slapi_PBlock *pb, Slapi_Entry *e, struct s
+ static int vattr_test_filter_list_or(Slapi_PBlock *pb, Slapi_Entry *e, struct slapi_filter *flist, int ftype, int verify_access, int only_check_access, int *access_check_done);
+
+ static int test_filter_access(Slapi_PBlock *pb, Slapi_Entry *e, char *attr_type, struct berval *attr_val);
++static int test_filter_access_ext(Slapi_PBlock *pb, Slapi_Entry *e, char *attr_type, struct berval *attr_val, int extra_access);
+ static int slapi_vattr_filter_test_ext_internal(Slapi_PBlock *pb, Slapi_Entry *e, struct slapi_filter *f, int verify_access, int only_check_access, int *access_check_done);
+
++/*
++ * Check access to an AVA filter. Ordering assertions reveal the value
++ * order, so they also need READ.
++ */
++static int
++test_ava_filter_access(Slapi_PBlock *pb, Slapi_Entry *e, struct ava *ava, int ftype)
++{
++ int extra_access = (ftype == LDAP_FILTER_GE || ftype == LDAP_FILTER_LE) ? SLAPI_ACL_READ : 0;
++
++ return test_filter_access_ext(pb, e, ava->ava_type, &ava->ava_value, extra_access);
++}
++
+ static char *opt_str = 0;
+ static int opt = 0;
+
+@@ -309,19 +322,13 @@ test_ava_filter(
+ }
+
+ if (rc == 0 && verify_access && pb != NULL) {
+- char *attrs[2] = {NULL, NULL};
+- attrs[0] = ava->ava_type;
+- rc = plugin_call_acl_plugin(pb, e, attrs, &ava->ava_value,
+- SLAPI_ACL_SEARCH, ACLPLUGIN_ACCESS_DEFAULT, NULL);
++ rc = test_ava_filter_access(pb, e, ava, ftype);
+ *access_check_done = -1;
+ }
+
+ } else {
+ if (verify_access && pb != NULL) {
+- char *attrs[2] = {NULL, NULL};
+- attrs[0] = ava->ava_type;
+- rc = plugin_call_acl_plugin(pb, e, attrs, &ava->ava_value,
+- SLAPI_ACL_SEARCH, ACLPLUGIN_ACCESS_DEFAULT, NULL);
++ rc = test_ava_filter_access(pb, e, ava, ftype);
+ *access_check_done = -1;
+ if (only_check_access || rc != LDAP_SUCCESS) {
+ slapi_log_err(SLAPI_LOG_FILTER, "test_ava_filter", "<= %d\n", rc);
+@@ -526,24 +533,22 @@ test_extensible_filter(
+ }
+
+ if (rc == 0 && mrf->mrf_type != NULL && verify_access) {
+- char *attrs[2] = {NULL, NULL};
+ /* Could be A, B, C, or D */
+- /* Check we have access to this attribute on this entry */
+- attrs[0] = mrf->mrf_type;
+- rc = plugin_call_acl_plugin(callers_pb, e, attrs, &(mrf->mrf_value),
+- SLAPI_ACL_SEARCH, ACLPLUGIN_ACCESS_DEFAULT, NULL);
++ /* An explicit rule can reveal the value order or value
++ * parts, so it needs READ. */
++ rc = test_filter_access_ext(callers_pb, e, mrf->mrf_type, &(mrf->mrf_value),
++ (mrf->mrf_oid != NULL) ? SLAPI_ACL_READ : 0);
+ *access_check_done = -1;
+ }
+ } else {
+ rc = LDAP_SUCCESS;
+
+ if (mrf->mrf_type != NULL && verify_access) {
+- char *attrs[2] = {NULL, NULL};
+ /* Could be A, B, C, or D */
+- /* Check we have access to this attribute on this entry */
+- attrs[0] = mrf->mrf_type;
+- rc = plugin_call_acl_plugin(callers_pb, e, attrs, &(mrf->mrf_value),
+- SLAPI_ACL_SEARCH, ACLPLUGIN_ACCESS_DEFAULT, NULL);
++ /* An explicit rule can reveal the value order or value
++ * parts, so it needs READ. */
++ rc = test_filter_access_ext(callers_pb, e, mrf->mrf_type, &(mrf->mrf_value),
++ (mrf->mrf_oid != NULL) ? SLAPI_ACL_READ : 0);
+ *access_check_done = -1;
+
+ if (only_check_access) {
+@@ -710,18 +715,14 @@ test_substring_filter(
+ }
+
+ if (rc == 0 && verify_access && pb != NULL) {
+- char *attrs[2] = {NULL, NULL};
+- attrs[0] = f->f_sub_type;
+- rc = plugin_call_acl_plugin(pb, e, attrs, NULL,
+- SLAPI_ACL_SEARCH, ACLPLUGIN_ACCESS_DEFAULT, NULL);
++ /* A substring reveals parts of the value, so it needs READ. */
++ rc = test_filter_access_ext(pb, e, f->f_sub_type, NULL, SLAPI_ACL_READ);
+ *access_check_done = -1;
+ }
+ } else {
+ if (verify_access && pb != NULL) {
+- char *attrs[2] = {NULL, NULL};
+- attrs[0] = f->f_sub_type;
+- rc = plugin_call_acl_plugin(pb, e, attrs, NULL,
+- SLAPI_ACL_SEARCH, ACLPLUGIN_ACCESS_DEFAULT, NULL);
++ /* A substring reveals parts of the value, so it needs READ. */
++ rc = test_filter_access_ext(pb, e, f->f_sub_type, NULL, SLAPI_ACL_READ);
+ *access_check_done = -1;
+ if (only_check_access || rc != LDAP_SUCCESS) {
+ return (rc);
+@@ -875,8 +876,9 @@ slapi_vattr_filter_test_ext_internal(
+ break;
+
+ case LDAP_FILTER_SUBSTRINGS:
++ /* A substring reveals parts of the value, so it needs READ. */
+ if (verify_access) {
+- rc = test_filter_access(pb, e, f->f_sub_type, NULL);
++ rc = test_filter_access_ext(pb, e, f->f_sub_type, NULL, SLAPI_ACL_READ);
+ *access_check_done = 1;
+ }
+ if (only_check_access || rc != LDAP_SUCCESS) {
+@@ -886,9 +888,10 @@ slapi_vattr_filter_test_ext_internal(
+ break;
+
+ case LDAP_FILTER_GE:
++ /* Ordering reveals the value order, so it needs READ. */
+ if (verify_access) {
+- rc = test_filter_access(pb, e, f->f_ava.ava_type,
+- &f->f_ava.ava_value);
++ rc = test_filter_access_ext(pb, e, f->f_ava.ava_type,
++ &f->f_ava.ava_value, SLAPI_ACL_READ);
+ *access_check_done = 1;
+ }
+ if (only_check_access || rc != LDAP_SUCCESS) {
+@@ -898,9 +901,10 @@ slapi_vattr_filter_test_ext_internal(
+ break;
+
+ case LDAP_FILTER_LE:
++ /* Ordering reveals the value order, so it needs READ. */
+ if (verify_access) {
+- rc = test_filter_access(pb, e, f->f_ava.ava_type,
+- &f->f_ava.ava_value);
++ rc = test_filter_access_ext(pb, e, f->f_ava.ava_type,
++ &f->f_ava.ava_value, SLAPI_ACL_READ);
+ *access_check_done = 1;
+ }
+ if (only_check_access || rc != LDAP_SUCCESS) {
+@@ -1001,10 +1005,23 @@ test_filter_access(Slapi_PBlock *pb,
+ char *attr_type,
+ struct berval *attr_val)
+ {
+- /*
+- * attr_type--attr_type to test for.
+- * attr_val--attr value to test for
+- */
++ return test_filter_access_ext(pb, e, attr_type, attr_val, 0);
++}
++
++/*
++ * Check access to a filter assertion.
++ *
++ * Presence and equality need SEARCH. Substring, ordering and explicit
++ * matching rule assertions reveal the value parts or the value order, so
++ * they also need READ.
++ */
++static int
++test_filter_access_ext(Slapi_PBlock *pb,
++ Slapi_Entry *e,
++ char *attr_type,
++ struct berval *attr_val,
++ int extra_access)
++{
+ int rc;
+ char *attrs[2] = {NULL, NULL};
+ attrs[0] = attr_type;
+@@ -1012,7 +1029,12 @@ test_filter_access(Slapi_PBlock *pb,
+ rc = plugin_call_acl_plugin(pb, e, attrs, attr_val,
+ SLAPI_ACL_SEARCH, ACLPLUGIN_ACCESS_DEFAULT, NULL);
+
+- slapi_log_err(SLAPI_LOG_FILTER, "slapi_vattr_filter_test_ext_internal",
++ if (rc == LDAP_SUCCESS && extra_access) {
++ rc = plugin_call_acl_plugin(pb, e, attrs, attr_val,
++ extra_access, ACLPLUGIN_ACCESS_DEFAULT, NULL);
++ }
++
++ slapi_log_err(SLAPI_LOG_FILTER, "test_filter_access_ext",
+ "acl result for %s %s = %d\n", slapi_entry_get_dn_const(e), attr_type, rc);
+
+ return (rc);
+--
+2.56.1
+
diff --git a/0003-Security-fix-for-CVE-2026-115422.patch b/0003-Security-fix-for-CVE-2026-115422.patch
new file mode 100644
index 0000000..5948502
--- /dev/null
+++ b/0003-Security-fix-for-CVE-2026-115422.patch
@@ -0,0 +1,297 @@
+From a5b2efb597c99ab9f3e31e24918a9a1152473d6b Mon Sep 17 00:00:00 2001
+From: Viktor Ashirov <vashirov@redhat.com>
+Date: Thu, 29 Oct 2026 11:52:29 +0100
+Subject: [PATCH] Security fix for CVE-2026-115422
+
+Description:
+The server-side sort control and the VLV `byValue` control calculate the
+result order and `targetPosition` from sort key values. They do not check
+if the client can read these values. A client can sort entries by a hidden
+attribute, for example `uidNumber` when an ACL hides it. The result order
+then shows the order of the hidden values. With chosen assertions, the
+`byValue` position also shows the hidden values byte by byte.
+
+Fix:
+- Treat a sort key value as absent when the client cannot read it, in
+ `compare_entries_sv()` and in the live VLV `byValue` path
+ (`vlv_trim_candidates_byvalue()`).
+- Keep the precomputed VLV index path unchanged; it still uses the read
+ right on the `vlvSearch` entry.
+- Add a test that changes the hidden values between two anonymous sorted
+ searches.
+
+References:
+- https://access.redhat.com/security/cve/CVE-2026-115422
+- https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2026-115422
+
+Reviewed-by: Pierre Rogier <progier@redhat.com>
+Reviewed-by: Thierry Bordaz <tbordaz@redhat.com>
+---
+ dirsrvtests/tests/suites/vlv/vlv_acl_test.py | 72 +++++++++++++++++--
+ ldap/servers/slapd/back-ldbm/ldbm_search.c | 2 +-
+ .../servers/slapd/back-ldbm/proto-back-ldbm.h | 4 +-
+ ldap/servers/slapd/back-ldbm/sort.c | 26 ++++++-
+ ldap/servers/slapd/back-ldbm/vlv.c | 29 ++++++--
+ 5 files changed, 116 insertions(+), 17 deletions(-)
+
+diff --git a/dirsrvtests/tests/suites/vlv/vlv_acl_test.py b/dirsrvtests/tests/suites/vlv/vlv_acl_test.py
+index 7276cea52..36f271c41 100644
+--- a/dirsrvtests/tests/suites/vlv/vlv_acl_test.py
++++ b/dirsrvtests/tests/suites/vlv/vlv_acl_test.py
+@@ -88,6 +88,35 @@ def vlv_content_count(conn, base, filterstr, scope=ldap.SCOPE_ONELEVEL):
+ raise AssertionError('No VLV response control returned')
+
+
++def sorted_uids(conn, base, sort_key):
++ """Run an SSS-sorted search and return the uid values in result order."""
++ sss_control = SSSRequestControl(criticality=True, ordering_rules=[sort_key])
++ msg_id = conn.search_ext(base, ldap.SCOPE_ONELEVEL, '(uid=*)',
++ attrlist=['uid'], serverctrls=[sss_control])
++ rtype, rdata, rmsgid, rctrls = conn.result3(msg_id)
++ return [attrs['uid'][0].decode() for _dn, attrs in rdata]
++
++
++def vlv_target_position(conn, base, sort_key, assertion):
++ """Run a VLV byValue search on the sort key and return targetPosition."""
++ vlv_control = VLVRequestControl(criticality=True,
++ before_count=0,
++ after_count=0,
++ offset=None,
++ content_count=0,
++ greater_than_or_equal=assertion,
++ context_id=None)
++ sss_control = SSSRequestControl(criticality=True, ordering_rules=[sort_key])
++ msg_id = conn.search_ext(base, ldap.SCOPE_ONELEVEL, '(uid=*)',
++ attrlist=['uid'],
++ serverctrls=[vlv_control, sss_control])
++ rtype, rdata, rmsgid, rctrls = conn.result3(msg_id)
++ for ctrl in rctrls:
++ if ctrl.controlType == VLVResponseControl.controlType:
++ return ctrl.target_position
++ raise AssertionError('No VLV response control returned')
++
++
+ @pytest.fixture(scope="module")
+ def vlv_acl_entries(topo, request):
+ """Create a test OU with a password-protected victim, an attacker
+@@ -99,15 +128,17 @@ def vlv_acl_entries(topo, request):
+ ou = ous.create(properties={'ou': TEST_OU})
+ users = UserAccounts(inst, ou.dn, rdn=None)
+ entries = {'ou': ou, 'users': users}
+- uid_number = 10100
++ # Deliberately not the creation order: the sort-order test must be able
++ # to tell an order derived from uidNumber apart from the natural one.
++ uid_numbers = {VICTIM_UID: 10401, ATTACKER_UID: 10202,
++ "vlv_user_a": 10303, "vlv_user_b": 10104}
+ for uid in (VICTIM_UID, ATTACKER_UID, "vlv_user_a", "vlv_user_b"):
+- uid_number += 1
+ entries[uid] = users.create(properties={
+ 'uid': uid,
+ 'cn': uid,
+ 'sn': 'user',
+- 'uidNumber': str(uid_number),
+- 'gidNumber': str(uid_number),
++ 'uidNumber': str(uid_numbers[uid]),
++ 'gidNumber': str(uid_numbers[uid]),
+ 'homeDirectory': f'/home/{uid}',
+ 'userPassword': TEST_PW,
+ })
+@@ -277,3 +308,36 @@ def test_vlv_count_with_search_only_grant(topo, vlv_acl_entries, ou_aci):
+ assert users.filter(flt) == []
+ victim = users.get(VICTIM_UID)
+ assert not victim.get_attr_vals('userPassword')
++
++
++def test_vlv_sort_key_does_not_leak_hidden_values(topo, vlv_acl_entries):
++ """Sort order and VLV position must not disclose hidden attribute values
++
++ :id: cefa711e-1bfa-4f6a-8a5c-2bab4ab1a72d
++ :setup: Standalone instance, four users under a test OU
++ :steps:
++ 1. As anonymous, run a sorted (SSS control) search ordering by the
++ hidden uidNumber attribute
++ 2. As Directory Manager, change the hidden uidNumber values and
++ repeat the sorted search
++ 3. As anonymous, run VLV byValue searches on the hidden uidNumber
++ sort key with assertions below, at and above the stored values
++ :expectedresults:
++ 1. The entries are returned in an order independent of uidNumber
++ 2. The order equals step 1 - the hidden values have no influence
++ on the result order
++ 3. targetPosition is identical for all three assertions
++ """
++ conn = Anonymous(topo.standalone).bind()
++ base = vlv_acl_entries['ou'].dn
++ # uidNumber is not granted to the anonymous client, so it must not
++ # shape the sort order or the VLV position.
++ first = sorted_uids(conn, base, 'uidNumber')
++ for uid, value in ((VICTIM_UID, '10001'), (ATTACKER_UID, '10002'),
++ ('vlv_user_a', '10003'), ('vlv_user_b', '10004')):
++ vlv_acl_entries['users'].get(uid).set('uidNumber', value)
++ second = sorted_uids(conn, base, 'uidNumber')
++ assert first == second
++ positions = {vlv_target_position(conn, base, 'uidNumber', assertion)
++ for assertion in (b'!', b'10003', b'~')}
++ assert len(positions) == 1
+diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
+index 224caf9a1..b3c8d01e4 100644
+--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
++++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
+@@ -994,7 +994,7 @@ ldbm_back_search(Slapi_PBlock *pb)
+ back_txn txn = {NULL};
+ slapi_pblock_get(pb, SLAPI_TXN, &txn.back_txn_txn);
+ vlv_response_control.result =
+- vlv_trim_candidates_txn(be, candidates, sort_control,
++ vlv_trim_candidates_txn(pb, be, candidates, sort_control,
+ &vlv_request_control, &idl, &vlv_response_control, &txn);
+ if (vlv_response_control.result == 0) {
+ idl_free(&candidates);
+diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+index 04c5334e7..78eb120e3 100644
+--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
++++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+@@ -499,8 +499,8 @@ int vlv_search_build_candidate_list(Slapi_PBlock *pb, const Slapi_DN *base, int
+ int vlv_update_index(struct vlvIndex *p, back_txn *txn, struct ldbminfo *li, Slapi_PBlock *pb, struct backentry *oldEntry, struct backentry *newEntry);
+ int vlv_update_all_indexes(back_txn *txn, backend *be, Slapi_PBlock *pb, struct backentry *oldEntry, struct backentry *newEntry);
+ int vlv_filter_candidates(backend *be, Slapi_PBlock *pb, const IDList *candidates, const Slapi_DN *base, int scope, Slapi_Filter *filter, IDList **filteredCandidates, int lookthrough_limit, struct timespec *expire_time);
+-int vlv_trim_candidates_txn(backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, IDList **filteredCandidates, struct vlv_response *pResponse, back_txn *txn);
+-int vlv_trim_candidates(backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, IDList **filteredCandidates, struct vlv_response *pResponse);
++int vlv_trim_candidates_txn(Slapi_PBlock *pb, backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, IDList **filteredCandidates, struct vlv_response *pResponse, back_txn *txn);
++int vlv_trim_candidates(Slapi_PBlock *pb, backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, IDList **filteredCandidates, struct vlv_response *pResponse);
+ int vlv_parse_request_control(backend *be, struct berval *vlv_spec_ber, struct vlv_request *vlvp);
+ int vlv_make_response_control(Slapi_PBlock *pb, const struct vlv_response *vlvp);
+ void vlv_getindices(int32_t (*callback_fn)(caddr_t, caddr_t), void *param, backend *be);
+diff --git a/ldap/servers/slapd/back-ldbm/sort.c b/ldap/servers/slapd/back-ldbm/sort.c
+index 73a483085..81b9a6c76 100644
+--- a/ldap/servers/slapd/back-ldbm/sort.c
++++ b/ldap/servers/slapd/back-ldbm/sort.c
+@@ -463,6 +463,19 @@ sort_attr_compare(struct berval **value_a, struct berval **value_b, value_compar
+ * 0 when a == b
+ * >0 when a > b
+ */
++/* A hidden value must not shape the order. Treat it as absent. */
++static int
++sort_key_readable(Slapi_PBlock *pb, Slapi_Entry *e, const char *type)
++{
++ char *attrs[2] = {(char *)type, NULL};
++
++ if (pb == NULL) {
++ return 1;
++ }
++ return plugin_call_acl_plugin(pb, e, attrs, NULL, SLAPI_ACL_READ,
++ ACLPLUGIN_ACCESS_DEFAULT, NULL) == LDAP_SUCCESS;
++}
++
+ static int
+ compare_entries_sv(ID *id_a, ID *id_b, sort_spec *s, baggage_carrier *bc, int *error)
+ {
+@@ -507,9 +520,13 @@ compare_entries_sv(ID *id_a, ID *id_b, sort_spec *s, baggage_carrier *bc, int *e
+ struct berval **value_a = NULL;
+ struct berval **value_b = NULL;
+
+- /* Get the two attribute values from the entries */
+- slapi_entry_attr_find(a->ep_entry, type, &attr_a);
+- slapi_entry_attr_find(b->ep_entry, type, &attr_b);
++ /* Hidden values count as absent. */
++ if (sort_key_readable(bc->pb, a->ep_entry, type)) {
++ slapi_entry_attr_find(a->ep_entry, type, &attr_a);
++ }
++ if (sort_key_readable(bc->pb, b->ep_entry, type)) {
++ slapi_entry_attr_find(b->ep_entry, type, &attr_b);
++ }
+ /* What do we do if one or more of the entries lacks this attribute ? */
+ /* if one lacks the attribute */
+ if (NULL == attr_a) {
+@@ -553,6 +570,9 @@ compare_entries_sv(ID *id_a, ID *id_b, sort_spec *s, baggage_carrier *bc, int *e
+ matchrule_values_to_keys(this_one->mr_pb, va_b, &value_b);
+
+ if ((va_a && !value_a) || (va_b && !value_b)) {
++ /* value_a is our copy of the plugin's keys; the plugin owns
++ * value_b. Free the copy before leaving. */
++ ber_bvecfree(value_a);
+ result = 0;
+ goto bail;
+ }
+diff --git a/ldap/servers/slapd/back-ldbm/vlv.c b/ldap/servers/slapd/back-ldbm/vlv.c
+index d383e76ef..403e9fec4 100644
+--- a/ldap/servers/slapd/back-ldbm/vlv.c
++++ b/ldap/servers/slapd/back-ldbm/vlv.c
+@@ -37,7 +37,7 @@
+ #endif
+
+ static PRUint32 vlv_trim_candidates_byindex(PRUint32 length, const struct vlv_request *vlv_request_control);
+-static PRUint32 vlv_trim_candidates_byvalue(backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, back_txn *txn);
++static PRUint32 vlv_trim_candidates_byvalue(Slapi_PBlock *pb, backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, back_txn *txn);
+ static int vlv_build_candidate_list(backend *be, struct vlvIndex *p, const struct vlv_request *vlv_request_control, IDList **candidates, struct vlv_response *vlv_response_control, int is_srchlist_locked, back_txn *txn);
+
+ /* New mutex for vlv locking
+@@ -1535,7 +1535,7 @@ vlv_filter_candidates(backend *be, Slapi_PBlock *pb, const IDList *candidates, c
+ * other (80)
+ */
+ int
+-vlv_trim_candidates_txn(backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, IDList **trimmedCandidates, struct vlv_response *vlv_response_control, back_txn *txn)
++vlv_trim_candidates_txn(Slapi_PBlock *pb, backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, IDList **trimmedCandidates, struct vlv_response *vlv_response_control, back_txn *txn)
+ {
+ IDList *resultIdl = NULL;
+ int return_value = LDAP_SUCCESS;
+@@ -1552,7 +1552,7 @@ vlv_trim_candidates_txn(backend *be, const IDList *candidates, const sort_spec *
+ si = vlv_trim_candidates_byindex(candidates->b_nids, vlv_request_control);
+ break;
+ case 1: /* byValue */
+- si = vlv_trim_candidates_byvalue(be, candidates, sort_control, vlv_request_control, txn);
++ si = vlv_trim_candidates_byvalue(pb, be, candidates, sort_control, vlv_request_control, txn);
+ /* Don't bother sending results if the attribute value wasn't found */
+ if (si == candidates->b_nids) {
+ do_trim = 0;
+@@ -1596,9 +1596,9 @@ vlv_trim_candidates_txn(backend *be, const IDList *candidates, const sort_spec *
+ }
+
+ int
+-vlv_trim_candidates(backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, IDList **trimmedCandidates, struct vlv_response *vlv_response_control)
++vlv_trim_candidates(Slapi_PBlock *pb, backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, IDList **trimmedCandidates, struct vlv_response *vlv_response_control)
+ {
+- return vlv_trim_candidates_txn(be, candidates, sort_control, vlv_request_control, trimmedCandidates, vlv_response_control, NULL);
++ return vlv_trim_candidates_txn(pb, be, candidates, sort_control, vlv_request_control, trimmedCandidates, vlv_response_control, NULL);
+ }
+
+ /*
+@@ -1650,11 +1650,24 @@ vlv_trim_candidates_byindex(PRUint32 length, const struct vlv_request *vlv_reque
+ return si;
+ }
+
++/* A hidden value must not shape the position. Treat it as absent. */
++static int
++vlv_sort_value_readable(Slapi_PBlock *pb, Slapi_Entry *e, const char *type)
++{
++ char *attrs[2] = {(char *)type, NULL};
++
++ if (pb == NULL) {
++ return 1;
++ }
++ return plugin_call_acl_plugin(pb, e, attrs, NULL, SLAPI_ACL_READ,
++ ACLPLUGIN_ACCESS_DEFAULT, NULL) == LDAP_SUCCESS;
++}
++
+ /*
+ * Iterate over the Candidate ID List looking for an entry >= the provided attribute value.
+ */
+ static PRUint32
+-vlv_trim_candidates_byvalue(backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, back_txn *txn)
++vlv_trim_candidates_byvalue(Slapi_PBlock *pb, backend *be, const IDList *candidates, const sort_spec *sort_control, const struct vlv_request *vlv_request_control, back_txn *txn)
+ {
+ PRUint32 si = 0; /* The Selected Index */
+ PRUint32 low = 0;
+@@ -1732,7 +1745,9 @@ retry:
+ /* Check if vlv_request_control->value is greater than or equal to the primary key. */
+ int match;
+ Slapi_Attr *attr;
+- if ((NULL != compare_fn) && (slapi_entry_attr_find(e->ep_entry, sort_control->type, &attr) == 0)) {
++ if ((NULL != compare_fn) &&
++ vlv_sort_value_readable(pb, e->ep_entry, sort_control->type) &&
++ (slapi_entry_attr_find(e->ep_entry, sort_control->type, &attr) == 0)) {
+ /*
+ * If there's a matching rule associated with the primary
+ * attribute then use the indexer to mangle the attr values.
+--
+2.56.1
+
diff --git a/0004-Security-fix-for-CVE-2026-118472.patch b/0004-Security-fix-for-CVE-2026-118472.patch
new file mode 100644
index 0000000..ee83784
--- /dev/null
+++ b/0004-Security-fix-for-CVE-2026-118472.patch
@@ -0,0 +1,110 @@
+From be64574df73528cf8094635d16e86986d590f6db Mon Sep 17 00:00:00 2001
+From: Viktor Ashirov <vashirov@redhat.com>
+Date: Thu, 29 Oct 2026 11:52:29 +0100
+Subject: [PATCH] Security fix for CVE-2026-118472
+
+Description:
+A client that can use the VLV control can crash the server. With the
+stock 389 DS configuration this is any authenticated user. Where the VLV
+feature ACI allows anonymous use, an anonymous client can also do it. The
+request has a server-side sort control. Its sort key names an ordering
+rule, for example `sss=userPassword:2.5.13.18`. The request also has a VLV
+control in `byValue` mode, for example `vlv=0/0:x`. The server crashes
+with SIGSEGV in `attr_value_lowest` from `vlv_trim_candidates_txn`.
+Sorting with such a rule can also return entries in an arbitrary order,
+with no error.
+
+Fix:
+- Keep SLAPI_PLUGIN in the pblock after `default_mr_indexer_create()`
+ succeeds, so the index wrappers can call `plg_mr_values2keys`.
+- Treat a value as absent when a matching rule cannot produce ordering
+ keys for it, and do not pass NULL key arrays to `sort_attr_compare()`.
+- Report a `byValue` assertion that produces no ordering keys as not
+ found, and keep the absent entry handling separate.
+
+References:
+- https://access.redhat.com/security/cve/CVE-2026-118472
+- https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2026-118472
+
+Reviewed-by: Pierre Rogier <progier@redhat.com>
+Reviewed-by: Thierry Bordaz <tbordaz@redhat.com>
+---
+ dirsrvtests/tests/suites/vlv/vlv_acl_test.py | 19 +++++++++++++++++++
+ ldap/servers/slapd/back-ldbm/vlv.c | 12 +++++++++++-
+ ldap/servers/slapd/plugin_mr.c | 3 ++-
+ 3 files changed, 32 insertions(+), 2 deletions(-)
+
+diff --git a/dirsrvtests/tests/suites/vlv/vlv_acl_test.py b/dirsrvtests/tests/suites/vlv/vlv_acl_test.py
+index 36f271c41..b81790e5f 100644
+--- a/dirsrvtests/tests/suites/vlv/vlv_acl_test.py
++++ b/dirsrvtests/tests/suites/vlv/vlv_acl_test.py
+@@ -341,3 +341,22 @@ def test_vlv_sort_key_does_not_leak_hidden_values(topo, vlv_acl_entries):
+ positions = {vlv_target_position(conn, base, 'uidNumber', assertion)
+ for assertion in (b'!', b'10003', b'~')}
+ assert len(positions) == 1
++
++
++def test_vlv_byvalue_with_matching_rule_sort_key(topo, vlv_acl_entries):
++ """VLV byValue with a matching-rule sort key must not crash the server
++
++ :id: 008b101b-beef-4e4b-9e0c-4986acdf3908
++ :setup: Standalone instance, four users under a test OU
++ :steps:
++ 1. As anonymous, run a VLV byValue search whose sort key carries an
++ explicit ordering rule (uidNumber:2.5.13.18)
++ 2. Run an ordinary search on the same connection
++ :expectedresults:
++ 1. The search completes - the server must not terminate
++ 2. The server still answers
++ """
++ conn = Anonymous(topo.standalone).bind()
++ base = vlv_acl_entries['ou'].dn
++ vlv_target_position(conn, base, 'uidNumber:2.5.13.18', b'10003')
++ assert conn.search_s(base, ldap.SCOPE_ONELEVEL, '(uid=*)') != []
+diff --git a/ldap/servers/slapd/back-ldbm/vlv.c b/ldap/servers/slapd/back-ldbm/vlv.c
+index 403e9fec4..cad700abf 100644
+--- a/ldap/servers/slapd/back-ldbm/vlv.c
++++ b/ldap/servers/slapd/back-ldbm/vlv.c
+@@ -1709,6 +1709,13 @@ vlv_trim_candidates_byvalue(Slapi_PBlock *pb, backend *be, const IDList *candida
+ typedown_value = vlv_create_matching_rule_value(sort_control->mr_pb, (struct berval *)&vlv_request_control->value);
+ compare_fn = slapi_berval_cmp;
+ }
++ if (typedown_value == NULL) {
++ /* The assertion has no ordering keys, so its position cannot be
++ * determined. Report it as not found. */
++ slapi_log_err(SLAPI_LOG_TRACE, "vlv_trim_candidates_byvalue",
++ "No ordering keys for the assertion, treating it as not found\n");
++ return candidates->b_nids; /* not found */
++ }
+ retry:
+ /*
+ * Perform a binary search over the candidate list
+@@ -1763,7 +1770,10 @@ retry:
+ valuearray_get_bervalarray(csn_value, &entry_value);
+ needFree = PR_TRUE; /* entry_value is a copy */
+ }
+- if (!sort_control->order) {
++ if (entry_value == NULL) {
++ /* The entry's value is absent or not readable. */
++ match = sort_control->order ? 1 : 0;
++ } else if (!sort_control->order) {
+ match = sort_attr_compare(entry_value, (struct berval **)typedown_value, compare_fn);
+ } else {
+ match = sort_attr_compare((struct berval **)typedown_value, entry_value, compare_fn);
+diff --git a/ldap/servers/slapd/plugin_mr.c b/ldap/servers/slapd/plugin_mr.c
+index 757355dbc..cad0cbf63 100644
+--- a/ldap/servers/slapd/plugin_mr.c
++++ b/ldap/servers/slapd/plugin_mr.c
+@@ -287,7 +287,8 @@ int /* an LDAP error code, hopefully LDAP_SUCCESS */
+ if (!rc) {
+ plugin_mr_bind(oid, pi); /* for future reference */
+ }
+- slapi_pblock_set(opb, SLAPI_PLUGIN, NULL);
++ /* Keep SLAPI_PLUGIN. The index wrappers need it to
++ * call plg_mr_values2keys. */
+ }
+ }
+ }
+--
+2.56.1
+
diff --git a/0005-Security-fix-for-CVE-2026-118469.patch b/0005-Security-fix-for-CVE-2026-118469.patch
new file mode 100644
index 0000000..6a29872
--- /dev/null
+++ b/0005-Security-fix-for-CVE-2026-118469.patch
@@ -0,0 +1,256 @@
+From e06ac3f5c7c8017d94ee3dd7cb2c18eaddc57f4e Mon Sep 17 00:00:00 2001
+From: Viktor Ashirov <vashirov@redhat.com>
+Date: Thu, 29 Oct 2026 11:52:30 +0100
+Subject: [PATCH] Security fix for CVE-2026-118469
+
+Description:
+A client that can use the VLV control can terminate the server with a
+single search request. With the stock 389 DS configuration this is any
+authenticated user. Where the VLV feature ACI allows anonymous use, an
+anonymous client can also do it. The request has a server-side sort
+control and a VLV control in `byIndex` mode with a negative
+`beforeCount`, for example `vlv=-2/0/1/1`. The draft limits
+`beforeCount`, `afterCount`, `index` and `contentCount` to INTEGER
+(`0 .. maxInt`), but the server decoded them without a range check. A
+negative `beforeCount` passes the guards in `determine_result_range()`,
+which only protect against counts that are too large, and moves the
+result window start past its end. The window size is computed as an
+unsigned difference in `vlv_trim_candidates_txn()` and wraps to
+UINT_MAX, so `idl_alloc()` tries to allocate about 17 GB. Where the
+allocation fails, the `ch_malloc` failure handler terminates the whole
+server with `exit(1)`. Where it succeeds, the same request returns an
+empty page and reports success.
+
+Fix:
+- Reject a negative `beforeCount`, `afterCount`, `index` or
+ `contentCount` with LDAP_PROTOCOL_ERROR in
+ `vlv_parse_request_control()`. A critical VLV control then fails the
+ search with `unavailableCriticalExtension`; a non-critical control is
+ ignored.
+- Return an empty window from `vlv_trim_candidates_txn()` for an
+ inverted range, so no inverted range can reach `idl_alloc()` even if a
+ future change reintroduces one.
+
+References:
+- https://access.redhat.com/security/cve/CVE-2026-118469
+- https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2026-118469
+
+Reviewed-by: Pierre Rogier <progier@redhat.com>
+Reviewed-by: Thierry Bordaz <tbordaz@redhat.com>
+---
+ .../tests/suites/vlv/vlv_parser_test.py | 140 ++++++++++++++++++
+ ldap/servers/slapd/back-ldbm/vlv.c | 37 ++++-
+ 2 files changed, 171 insertions(+), 6 deletions(-)
+ create mode 100644 dirsrvtests/tests/suites/vlv/vlv_parser_test.py
+
+diff --git a/dirsrvtests/tests/suites/vlv/vlv_parser_test.py b/dirsrvtests/tests/suites/vlv/vlv_parser_test.py
+new file mode 100644
+index 000000000..a84b3d974
+--- /dev/null
++++ b/dirsrvtests/tests/suites/vlv/vlv_parser_test.py
+@@ -0,0 +1,140 @@
++# --- BEGIN COPYRIGHT BLOCK ---
++# Copyright (C) 2026 Red Hat, Inc.
++# All rights reserved.
++#
++# License: GPL (version 3 or any later version).
++# See LICENSE for details.
++# --- END COPYRIGHT BLOCK ---
++
++"""Server-side range validation of the VLV request control values.
++
++The VLV request control carries four values the draft limits to
++INTEGER (0 .. maxInt): beforeCount, afterCount, index and contentCount.
++The server decoded them without any range check. A negative beforeCount
++passed the positive-only guards in determine_result_range() and produced
++an inverted result window; the unsigned window size computed in
++vlv_trim_candidates_txn() wrapped to UINT_MAX and the resulting
++multi-gigabyte idl_alloc() aborted the whole server through the ch_malloc
++OOM handler (exit(1)). A single search carrying a sort control and a VLV
++control with beforeCount=-2 terminated ns-slapd on any host that could
++not satisfy the wrapped allocation.
++"""
++
++import logging
++import os
++
++import ldap
++import pytest
++from ldap.controls.sss import SSSRequestControl
++from ldap.controls.vlv import VLVRequestControl, VLVResponseControl
++
++from lib389._constants import DEFAULT_SUFFIX
++from lib389.idm.organizationalunit import OrganizationalUnits
++from lib389.idm.user import UserAccounts
++from test389.topologies import topology_st as topo
++
++pytestmark = pytest.mark.tier1
++
++DEBUGGING = os.getenv("DEBUGGING", default=False)
++if DEBUGGING:
++ logging.getLogger(__name__).setLevel(logging.DEBUG)
++else:
++ logging.getLogger(__name__).setLevel(logging.INFO)
++log = logging.getLogger(__name__)
++
++TEST_OU = "vlv_parser"
++USER_COUNT = 5
++
++
++@pytest.fixture(scope="module")
++def vlv_entries(topo, request):
++ """A test OU with USER_COUNT users, so VLV searches run against a
++ non-empty candidate list."""
++ inst = topo.standalone
++ ous = OrganizationalUnits(inst, DEFAULT_SUFFIX)
++ ou = ous.create(properties={'ou': TEST_OU})
++ users = UserAccounts(inst, ou.dn, rdn=None)
++ for i in range(USER_COUNT):
++ uid = f'vlv_parser_user_{i}'
++ users.create(properties={
++ 'uid': uid,
++ 'cn': uid,
++ 'sn': 'user',
++ 'uidNumber': str(10100 + i),
++ 'gidNumber': str(10100 + i),
++ 'homeDirectory': f'/home/{uid}',
++ })
++
++ def fin():
++ if not DEBUGGING:
++ for user in users.list():
++ user.delete()
++ ou.delete()
++
++ request.addfinalizer(fin)
++ return {'ou': ou, 'users': users}
++
++
++def vlv_by_index(conn, base, criticality=True, before_count=0, after_count=0,
++ offset=1, content_count=1):
++ """Run one VLV byIndex search sorted by cn and return the full result."""
++ vlv_control = VLVRequestControl(criticality=criticality,
++ before_count=before_count,
++ after_count=after_count,
++ offset=offset,
++ content_count=content_count,
++ greater_than_or_equal=None,
++ context_id=None)
++ sss_control = SSSRequestControl(criticality=True, ordering_rules=['cn'])
++ msg_id = conn.search_ext(base, ldap.SCOPE_ONELEVEL, '(uid=*)',
++ attrlist=['uid'],
++ serverctrls=[vlv_control, sss_control])
++ return conn.result3(msg_id)
++
++
++def test_vlv_rejects_out_of_range_request_values(topo, vlv_entries):
++ """A VLV request outside INTEGER (0 .. maxInt) must not terminate the server
++
++ :id: 1645cf1e-8329-4915-83ac-01a184addc41
++ :setup: Standalone instance with users under a test OU
++ :steps:
++ 1. Run critical VLV searches whose beforeCount, afterCount, index
++ and contentCount are negative, one value per request
++ 2. Run an ordinary search after each rejected request
++ 3. Run a search with a non-critical VLV control carrying a
++ negative beforeCount
++ 4. Run a VLV search with valid values
++ :expectedresults:
++ 1. Every search fails with unavailableCriticalExtension
++ 2. The server still answers - the request must not abort ns-slapd
++ 3. The search succeeds - a malformed non-critical control is ignored
++ 4. The search succeeds and returns the requested window with a
++ VLV response control
++ """
++ inst = topo.standalone
++ base = vlv_entries['ou'].dn
++ bad_requests = (
++ ('beforeCount', {'before_count': -2}),
++ ('afterCount', {'after_count': -2}),
++ ('index', {'offset': -1}),
++ ('contentCount', {'content_count': -1}),
++ )
++ for name, overrides in bad_requests:
++ log.info('Sending VLV request with a negative %s', name)
++ with pytest.raises(ldap.UNAVAILABLE_CRITICAL_EXTENSION):
++ vlv_by_index(inst, base, **overrides)
++ # The rejected request must not take the server down with it.
++ assert len(vlv_entries['users'].list()) == USER_COUNT
++ rtype, rdata, rmsgid, rctrls = vlv_by_index(inst, base, criticality=False,
++ before_count=-2)
++ assert len(rdata) == USER_COUNT
++ # Valid values must keep working; offset 1 is the first entry, so
++ # the window cannot start before it.
++ rtype, rdata, rmsgid, rctrls = vlv_by_index(inst, base, before_count=1,
++ after_count=1, offset=1,
++ content_count=USER_COUNT)
++ assert len(rdata) == 2
++ vlv_response = [ctrl for ctrl in rctrls
++ if ctrl.controlType == VLVResponseControl.controlType]
++ assert vlv_response
++ assert vlv_response[0].content_count == USER_COUNT
+diff --git a/ldap/servers/slapd/back-ldbm/vlv.c b/ldap/servers/slapd/back-ldbm/vlv.c
+index cad700abf..5b1fa4eee 100644
+--- a/ldap/servers/slapd/back-ldbm/vlv.c
++++ b/ldap/servers/slapd/back-ldbm/vlv.c
+@@ -1580,12 +1580,18 @@ vlv_trim_candidates_txn(Slapi_PBlock *pb, backend *be, const IDList *candidates,
+ determine_result_range(vlv_request_control, si, candidates->b_nids, &start, &stop);
+ /* Build a new list containing the (start..stop) range */
+ /* JCM: Should really be a function in idlist.c to copy a range */
+- resultIdl = idl_alloc(stop - start + 1);
+- {
+- PRUint32 cursor = 0;
+- for (cursor = start; cursor <= stop; cursor++) {
+- slapi_log_err(SLAPI_LOG_TRACE, "vlv_trim_candidates", "Include ID %lu\n", (u_long)candidates->b_ids[cursor]);
+- idl_append(resultIdl, candidates->b_ids[cursor]);
++ if (start > stop) {
++ /* Defensive: an inverted range would wrap the unsigned
++ * idl_alloc() size to a huge value and abort the server. */
++ resultIdl = idl_alloc(1);
++ } else {
++ resultIdl = idl_alloc(stop - start + 1);
++ {
++ PRUint32 cursor = 0;
++ for (cursor = start; cursor <= stop; cursor++) {
++ slapi_log_err(SLAPI_LOG_TRACE, "vlv_trim_candidates", "Include ID %lu\n", (u_long)candidates->b_ids[cursor]);
++ idl_append(resultIdl, candidates->b_ids[cursor]);
++ }
+ }
+ }
+ }
+@@ -1997,6 +2003,16 @@ vlv_parse_request_control(backend *be, struct berval *vlv_spec_ber, struct vlv_r
+ ber = ber_init(vlv_spec_ber);
+ if (ber_scanf(ber, "{ii", &vlvp->beforeCount, &vlvp->afterCount) == LBER_ERROR) {
+ return_value = LDAP_OPERATIONS_ERROR;
++ } else if (vlvp->beforeCount < 0 || vlvp->afterCount < 0) {
++ /* Both counts are INTEGER (0 .. maxInt). A negative count slips
++ * past the positive-only checks in determine_result_range() and
++ * moves the range start past its end; the unsigned size math in
++ * vlv_trim_candidates_txn() then wraps and aborts the server. */
++ if (ISLEGACY(be)) {
++ return_value = LDAP_OPERATIONS_ERROR;
++ } else {
++ return_value = LDAP_VIRTUAL_LIST_VIEW_ERROR;
++ }
+ } else {
+ slapi_log_err(SLAPI_LOG_TRACE, "vlv_parse_request_control", "Before=%d After=%d\n",
+ vlvp->beforeCount, vlvp->afterCount);
+@@ -2013,6 +2029,15 @@ vlv_parse_request_control(backend *be, struct berval *vlv_spec_ber, struct vlv_r
+ } else {
+ return_value = LDAP_VIRTUAL_LIST_VIEW_ERROR;
+ }
++ } else if (vlvp->index < 0 || vlvp->contentCount < 0) {
++ /* Both are INTEGER (0 .. maxInt); a negative index
++ * would reach the unsigned math in
++ * vlv_trim_candidates_byindex(). */
++ if (ISLEGACY(be)) {
++ return_value = LDAP_OPERATIONS_ERROR;
++ } else {
++ return_value = LDAP_VIRTUAL_LIST_VIEW_ERROR;
++ }
+ } else {
+ /* Client Counts from 1. */
+ if (vlvp->index != 0) {
+--
+2.56.1
+
diff --git a/0006-Security-fix-for-CVE-2026-118474.patch b/0006-Security-fix-for-CVE-2026-118474.patch
new file mode 100644
index 0000000..e0bd04e
--- /dev/null
+++ b/0006-Security-fix-for-CVE-2026-118474.patch
@@ -0,0 +1,206 @@
+From a2c5026e5d8ee5476f340f2fc459b09fae899d6c Mon Sep 17 00:00:00 2001
+From: Viktor Ashirov <vashirov@redhat.com>
+Date: Thu, 29 Oct 2026 11:52:30 +0100
+Subject: [PATCH] Security fix for CVE-2026-118474
+
+Description:
+The Simple Paged Results response control carries an estimate of the
+result set size. The server computed it from the size of the index
+candidate list, before the filter test and before access control, and
+reported it on every page. A client restricted by ACIs therefore learns
+how many entries match a filter it cannot see, and entries outside the
+search scope are counted as well. The estimate is a count oracle for
+hidden data: an attacker can map the size and composition of parts of
+the directory it is not allowed to read, and probe the whole backend
+from any base it can search.
+
+Fix:
+Report the estimate only for operations that are not subject to access
+control (the root DN and internal operations). Other clients receive 0,
+which RFC 2696 defines as an unknown estimate.
+
+References:
+- https://access.redhat.com/security/cve/CVE-2026-118474
+- https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2026-118474
+
+Reviewed-by: Pierre Rogier <progier@redhat.com>
+Reviewed-by: Thierry Bordaz <tbordaz@redhat.com>
+---
+ .../paged_results_estimate_test.py | 135 ++++++++++++++++++
+ ldap/servers/slapd/back-ldbm/ldbm_search.c | 18 ++-
+ 2 files changed, 150 insertions(+), 3 deletions(-)
+ create mode 100644 dirsrvtests/tests/suites/paged_results/paged_results_estimate_test.py
+
+diff --git a/dirsrvtests/tests/suites/paged_results/paged_results_estimate_test.py b/dirsrvtests/tests/suites/paged_results/paged_results_estimate_test.py
+new file mode 100644
+index 000000000..a060862be
+--- /dev/null
++++ b/dirsrvtests/tests/suites/paged_results/paged_results_estimate_test.py
+@@ -0,0 +1,135 @@
++# --- BEGIN COPYRIGHT BLOCK ---
++# Copyright (C) 2026 Red Hat, Inc.
++# All rights reserved.
++#
++# License: GPL (version 3 or any later version).
++# See LICENSE for details.
++# --- END COPYRIGHT BLOCK ---
++
++"""The paged results estimate must not disclose entries hidden by ACLs.
++
++The estimate in the response control is computed from the index candidate
++list before the filter test and before access control, so it reports the
++size of a result set the client may not be allowed to see.
++"""
++
++import logging
++import os
++
++import ldap
++import pytest
++from ldap.controls import SimplePagedResultsControl
++
++from lib389._constants import DEFAULT_SUFFIX
++from lib389.idm.organizationalunit import OrganizationalUnits
++from lib389.idm.user import UserAccounts
++from test389.topologies import topology_st as topo
++
++pytestmark = pytest.mark.tier1
++
++DEBUGGING = os.getenv("DEBUGGING", default=False)
++if DEBUGGING:
++ logging.getLogger(__name__).setLevel(logging.DEBUG)
++else:
++ logging.getLogger(__name__).setLevel(logging.INFO)
++log = logging.getLogger(__name__)
++
++USERS_OU = f"ou=users,{DEFAULT_SUFFIX}"
++ADMINS_OU = f"ou=admins,{DEFAULT_SUFFIX}"
++ATTACKER_DN = f"uid=attacker,{ADMINS_OU}"
++ATTACKER_PW = "attacker_pw"
++USER_COUNT = 6
++HIDDEN = [f"uid=user{i},{USERS_OU}" for i in (4, 5, 6)]
++FILTER = "(objectClass=inetOrgPerson)"
++
++
++@pytest.fixture(scope="module")
++def hidden_entries(topo, request):
++ """Six users, three of them hidden from the attacker."""
++ inst = topo.standalone
++ ous = OrganizationalUnits(inst, DEFAULT_SUFFIX)
++ users_ou = ous.create(properties={'ou': 'users'})
++ admins_ou = ous.create(properties={'ou': 'admins'})
++ users = UserAccounts(inst, users_ou.dn, rdn=None)
++ for i in range(1, USER_COUNT + 1):
++ uid = f'user{i}'
++ users.create(properties={
++ 'uid': uid,
++ 'cn': uid,
++ 'sn': 'user',
++ 'uidNumber': str(11000 + i),
++ 'gidNumber': '11000',
++ 'homeDirectory': f'/home/{uid}',
++ 'userPassword': 'user_pw',
++ })
++ attacker = UserAccounts(inst, admins_ou.dn, rdn=None).create(properties={
++ 'uid': 'attacker',
++ 'cn': 'attacker',
++ 'sn': 'attacker',
++ 'uidNumber': '12000',
++ 'gidNumber': '12000',
++ 'homeDirectory': '/home/attacker',
++ 'userPassword': ATTACKER_PW,
++ })
++ users_ou.add('aci', f'(targetattr="uid || cn || sn || objectClass")'
++ f'(version 3.0; acl "public read"; '
++ f'allow (read, search, compare) '
++ f'userdn="ldap:///{ATTACKER_DN}";)')
++ for dn in HIDDEN:
++ uid = dn.split(',')[0]
++ users_ou.add('aci', f'(target="ldap:///{dn}")(targetattr="*")'
++ f'(version 3.0; acl "hide {uid}"; deny (all) '
++ f'userdn="ldap:///{ATTACKER_DN}";)')
++
++ def fin():
++ if not DEBUGGING:
++ for user in users.list():
++ user.delete()
++ attacker.delete()
++
++ request.addfinalizer(fin)
++ return {'users_ou': users_ou, 'attacker': attacker}
++
++
++def paged_pages(conn, base, pagesize):
++ """Return a list of (entries in page, estimate) for every page."""
++ cookie = b''
++ pages = []
++ while True:
++ ctrl = SimplePagedResultsControl(criticality=True, size=pagesize,
++ cookie=cookie)
++ msgid = conn.search_ext(base, ldap.SCOPE_ONELEVEL, FILTER,
++ attrlist=['uid'], serverctrls=[ctrl])
++ rtype, rdata, rmsgid, rctrls = conn.result3(msgid)
++ estimate = None
++ for resp in rctrls:
++ if resp.controlType == SimplePagedResultsControl.controlType:
++ estimate = resp.size
++ cookie = resp.cookie
++ pages.append((len(rdata), estimate))
++ if not cookie:
++ return pages
++
++
++def test_paged_estimate_does_not_count_hidden_entries(topo, hidden_entries):
++ """The paged results estimate must not exceed the visible result set
++
++ :id: d63b1397-d03e-4f54-920d-7f97ce4b17aa
++ :setup: Standalone instance, three of six users hidden from the attacker
++ :steps:
++ 1. As the attacker, page through a search that matches all six users
++ 2. Compare the estimate on the first page with the entries delivered
++ :expectedresults:
++ 1. The search returns only the three readable users
++ 2. The estimate is not larger than the number of entries the client
++ can actually receive
++ """
++ attacker = hidden_entries['attacker'].bind(ATTACKER_PW)
++ base = hidden_entries['users_ou'].dn
++ pages = paged_pages(attacker, base, 2)
++ delivered = sum(entries for entries, _estimate in pages)
++ first_estimate = pages[0][1]
++ log.info('pages=%s delivered=%d first_estimate=%s',
++ pages, delivered, first_estimate)
++ assert delivered == 3
++ assert first_estimate <= delivered
+diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
+index b3c8d01e4..34abe28fb 100644
+--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
++++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
+@@ -1109,9 +1109,21 @@ ldbm_back_search(Slapi_PBlock *pb)
+ sr->sr_candidates = candidates;
+ sr->sr_virtuallistview = virtual_list_view;
+
+- /* Set the estimated search result count for simple paged results */
+- if (sr->sr_candidates && !ALLIDS(sr->sr_candidates)) {
+- estimate = IDL_NIDS(sr->sr_candidates);
++ /* Set the estimated search result count for simple paged results.
++ * The count is the size of the index candidate list, before the
++ * filter test and access control, so it can disclose entries the
++ * client is not allowed to read. Report it only for operations that
++ * are not subject to access control. */
++ {
++ int isroot = 0;
++ Operation *op = NULL;
++ slapi_pblock_get(pb, SLAPI_REQUESTOR_ISROOT, &isroot);
++ slapi_pblock_get(pb, SLAPI_OPERATION, &op);
++ if (isroot || (op != NULL && operation_is_flag_set(op, OP_FLAG_INTERNAL))) {
++ if (sr->sr_candidates && !ALLIDS(sr->sr_candidates)) {
++ estimate = IDL_NIDS(sr->sr_candidates);
++ }
++ }
+ }
+ slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate);
+
+--
+2.56.1
+
diff --git a/0007-Issue-NNNN-Only-load-plugins-from-cn-plugins-cn-conf.patch b/0007-Issue-NNNN-Only-load-plugins-from-cn-plugins-cn-conf.patch
new file mode 100644
index 0000000..674b459
--- /dev/null
+++ b/0007-Issue-NNNN-Only-load-plugins-from-cn-plugins-cn-conf.patch
@@ -0,0 +1,423 @@
+From 1a6450d4418e4bbb55b4467e5ef6171ce49aaab5 Mon Sep 17 00:00:00 2001
+From: Viktor Ashirov <vashirov@redhat.com>
+Date: Thu, 8 Oct 2026 20:53:44 +0200
+Subject: [PATCH] Issue NNNN - Only load plugins from cn=plugins,cn=config
+
+Bug Description:
+The plugin loader used `cn=config` as the base and filtered on
+`objectclass=nsslapdPlugin`, so every entry with that object class
+anywhere below `cn=config` was handed to `plugin_setup()`.
+As a result, a plugin entry placed outside `cn=plugins,cn=config` could
+be loaded.
+
+Fix Description:
+- Scope the `load_plugin_entry` to the plugin subtree `cn=plugins,cn=config`.
+- Add a helper function `plugin_entry_is_under_plugin_base()` and make
+ `plugin_setup()` reject any entry outside `cn=plugins,cn=config`.
+- Make `dse_add_plugin()` reject a new plugin entry outside the subtree with
+ `LDAP_UNWILLING_TO_PERFORM`, and make `dse_add()` report that rejection as
+ an operation failure.
+- Skip plugin enable, disable and restart handling for entries outside the
+ subtree, while still allowing inert entries to be deleted.
+
+Fixes: https://github.com/389ds/389-ds-base/issues/NNNN
+
+Reviewed-by: Mark Reynolds <mreynolds@redhat.com>
+Reviewed-by: Pierre Rogier <progier@redhat.com>
+---
+ .../plugins/plugin_dn_validation_test.py | 145 ++++++++++++++++++
+ ldap/servers/slapd/configdse.c | 14 ++
+ ldap/servers/slapd/dse.c | 41 ++++-
+ ldap/servers/slapd/fedse.c | 6 +-
+ ldap/servers/slapd/plugin.c | 56 +++++++
+ ldap/servers/slapd/proto-slap.h | 1 +
+ 6 files changed, 259 insertions(+), 4 deletions(-)
+ create mode 100644 dirsrvtests/tests/suites/plugins/plugin_dn_validation_test.py
+
+diff --git a/dirsrvtests/tests/suites/plugins/plugin_dn_validation_test.py b/dirsrvtests/tests/suites/plugins/plugin_dn_validation_test.py
+new file mode 100644
+index 000000000..e1d68880a
+--- /dev/null
++++ b/dirsrvtests/tests/suites/plugins/plugin_dn_validation_test.py
+@@ -0,0 +1,145 @@
++# --- BEGIN COPYRIGHT BLOCK ---
++# Copyright (C) 2026 Red Hat, Inc.
++# All rights reserved.
++# License: GPL (version 3 or any later version).
++# See LICENSE for details.
++# --- END COPYRIGHT BLOCK ---
++#
++import ldap
++import logging
++import os
++import pytest
++from lib389._constants import *
++from lib389._mapped_object import DSLdapObject
++from lib389.dseldif import DSEldif
++from lib389.plugins import AttributeUniquenessPlugin
++from test389.topologies import topology_st as topo
++
++pytestmark = pytest.mark.tier1
++
++DEBUGGING = os.getenv("DEBUGGING", default=False)
++if DEBUGGING:
++ logging.getLogger(__name__).setLevel(logging.DEBUG)
++else:
++ logging.getLogger(__name__).setLevel(logging.INFO)
++log = logging.getLogger(__name__)
++
++PLUGIN_BASE_DN = "cn=plugins,cn=config"
++ROGUE_PLUGIN_DN = "cn=rogue-plugin,cn=config"
++VALID_PLUGIN_DN = f"cn=dn-validation-plugin,{PLUGIN_BASE_DN}"
++
++
++@pytest.fixture(scope="function")
++def created_plugin(topo, request):
++ """Create a disabled plugin under the plugin base and delete it afterwards"""
++ plugin = AttributeUniquenessPlugin(topo.standalone, dn=VALID_PLUGIN_DN)
++ plugin.create(properties={'cn': 'dn-validation-plugin'})
++
++ def fin():
++ if DEBUGGING:
++ return
++ if plugin.exists():
++ plugin.delete()
++
++ request.addfinalizer(fin)
++ return plugin
++
++
++@pytest.fixture(scope="function")
++def rogue_plugin_entry(topo, request):
++ """Store a plugin entry outside the plugin base in dse.ldif and remove it afterwards"""
++ inst = topo.standalone
++ entry = DSLdapObject(inst, dn=ROGUE_PLUGIN_DN)
++ # DSLdapObject is protected by default because it can point at any entry.
++ entry._protected = False
++
++ def fin():
++ # Never leave the module topology with a stopped server.
++ if not inst.status():
++ inst.start()
++ if DEBUGGING:
++ return
++ if entry.exists():
++ entry.delete()
++
++ request.addfinalizer(fin)
++
++ inst.stop()
++ DSEldif(inst).add_entry([
++ f"dn: {ROGUE_PLUGIN_DN}\n",
++ "objectClass: top\n",
++ "objectClass: nsSlapdPlugin\n",
++ "cn: rogue-plugin\n",
++ "nsslapd-pluginType: betxnpreoperation\n",
++ "nsslapd-pluginPath: libattr-unique-plugin\n",
++ "nsslapd-pluginInitFunc: rogue_plugin_init_does_not_exist\n",
++ "nsslapd-pluginEnabled: on\n",
++ "nsslapd-pluginId: rogue-plugin\n",
++ "nsslapd-pluginVersion: none\n",
++ "nsslapd-pluginVendor: 389 Project\n",
++ "nsslapd-pluginDescription: plugin entry outside the plugin base\n",
++ "\n",
++ ])
++ inst.start()
++
++ return inst
++
++
++def test_add_plugin_outside_plugin_base(topo):
++ """A plugin entry outside cn=plugins,cn=config is rejected
++
++ :id: 35847edc-abaf-429b-840c-0fc45928646a
++ :setup: Standalone instance
++ :steps:
++ 1. Add an nsSlapdPlugin entry under cn=config but outside cn=plugins,cn=config
++ 2. Verify the entry was not created
++ 3. Verify the server is still running
++ :expectedresults:
++ 1. The add fails with unwilling to perform
++ 2. The entry does not exist
++ 3. The server is healthy
++ """
++ inst = topo.standalone
++ plugin = AttributeUniquenessPlugin(inst, dn=ROGUE_PLUGIN_DN)
++
++ with pytest.raises(ldap.UNWILLING_TO_PERFORM) as e:
++ plugin.create(properties={'cn': 'rogue-plugin'})
++ assert "must be under" in e.value.args[0]["info"]
++
++ assert not plugin.exists()
++ assert inst.status()
++
++
++def test_add_plugin_under_plugin_base(created_plugin):
++ """A plugin entry under cn=plugins,cn=config is still accepted
++
++ :id: 2cb75480-c383-4e81-a617-39b375071222
++ :setup: Standalone instance with a disabled plugin entry created under the plugin base
++ :steps:
++ 1. Verify the plugin entry exists
++ :expectedresults:
++ 1. The entry exists
++ """
++ assert created_plugin.exists()
++ assert created_plugin.get_attr_val_utf8("nsslapd-pluginEnabled") == "off"
++
++
++def test_startup_ignores_plugin_outside_plugin_base(rogue_plugin_entry):
++ """A plugin entry outside cn=plugins,cn=config in dse.ldif is not loaded
++
++ :id: 64015ffb-1546-465e-8edd-5d70bb03e271
++ :setup: Standalone instance whose dse.ldif contains a plugin entry outside the plugin subtree
++ :steps:
++ 1. Verify the server started with the rogue entry in dse.ldif
++ 2. Verify the entry is kept as inert configuration
++ 3. Verify the plugin loader never tried to initialize the entry
++ :expectedresults:
++ 1. The server is healthy
++ 2. The entry exists
++ 3. The init function is never mentioned in the error log
++ """
++ inst = rogue_plugin_entry
++
++ assert inst.status()
++ assert DSLdapObject(inst, dn=ROGUE_PLUGIN_DN).exists()
++ assert not inst.ds_error_log.match(".*rogue_plugin_init_does_not_exist.*")
+diff --git a/ldap/servers/slapd/configdse.c b/ldap/servers/slapd/configdse.c
+index 920bebfbf..6fd620733 100644
+--- a/ldap/servers/slapd/configdse.c
++++ b/ldap/servers/slapd/configdse.c
+@@ -333,6 +333,20 @@ load_plugin_entry(Slapi_PBlock *pb __attribute__((unused)),
+ {
+ int retval = LDAP_SUCCESS;
+
++ if (!plugin_entry_is_under_plugin_base(e)) {
++ /*
++ * LDAP_SCOPE_SUBTREE also matches the base entry. This test
++ * is triggered only if cn=plugins,cn=config has nsSlapdPlugin
++ * objectClass, or a caller uses load_plugin_entry() directly.
++ * Ignore the entry and don't abort the startup.
++ */
++ slapi_log_err(SLAPI_LOG_WARNING, "load_plugin_entry",
++ "Ignoring plugin entry \"%s\": it is not under %s\n",
++ slapi_entry_get_dn_const(e), PLUGIN_BASE_DN);
++ *returncode = LDAP_SUCCESS;
++ return SLAPI_DSE_CALLBACK_OK;
++ }
++
+ if (isASyntaxOrMrPluginOrPss(e)) {
+ /*
+ * syntax/matching/passwd storage scheme rule plugins are loaded
+diff --git a/ldap/servers/slapd/dse.c b/ldap/servers/slapd/dse.c
+index fe3fd77d7..4daad6f9d 100644
+--- a/ldap/servers/slapd/dse.c
++++ b/ldap/servers/slapd/dse.c
+@@ -2315,6 +2315,11 @@ dse_pre_modify_plugin(Slapi_Entry *entryBefore, Slapi_Entry *entryAfter, LDAPMod
+ int rc = 0;
+ int i;
+
++ if (!plugin_entry_is_under_plugin_base(entryBefore) ||
++ !plugin_entry_is_under_plugin_base(entryAfter)) {
++ return 0;
++ }
++
+ /*
+ * Only check the mods if the plugin is enabled - no need to restart a plugin if it's not running.
+ */
+@@ -2353,6 +2358,11 @@ dse_modify_plugin(Slapi_Entry *pre_entry, Slapi_Entry *post_entry, char *returnt
+ {
+ int rc = LDAP_SUCCESS;
+
++ if (!plugin_entry_is_under_plugin_base(pre_entry) ||
++ !plugin_entry_is_under_plugin_base(post_entry)) {
++ return 0;
++ }
++
+ if (slapi_entry_attr_hasvalue(pre_entry, "nsslapd-pluginEnabled", "on") &&
+ slapi_entry_attr_hasvalue(post_entry, "nsslapd-pluginEnabled", "off")) {
+ /*
+@@ -2390,10 +2400,29 @@ dse_add_plugin(Slapi_Entry *entry, char *returntext)
+ {
+ int rc = LDAP_SUCCESS;
+
+- if (!slapi_entry_attr_hasvalue(entry, SLAPI_ATTR_OBJECTCLASS, "nsSlapdPlugin") ||
+- !config_get_dynamic_plugins()) {
++ if (!slapi_entry_attr_hasvalue(entry, SLAPI_ATTR_OBJECTCLASS, "nsSlapdPlugin")) {
+ /*
+- * This is not a plugin, or we are not allowing dynamic updates.
++ * This is not a plugin.
++ */
++ return rc;
++ }
++
++ if (!plugin_entry_is_under_plugin_base(entry)) {
++ /*
++ * Only plugins stored under the plugin base DN are ever loaded, so
++ * refuse to create an entry that could never take effect.
++ */
++ slapi_log_err(SLAPI_LOG_ERR, "dse_add_plugin",
++ "Plugin entry \"%s\" is not under %s - rejecting the add\n",
++ slapi_entry_get_dn_const(entry), PLUGIN_BASE_DN);
++ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
++ "Plugin entry must be under %s.", PLUGIN_BASE_DN);
++ return -1;
++ }
++
++ if (!config_get_dynamic_plugins()) {
++ /*
++ * We are not allowing dynamic updates.
+ */
+ return rc;
+ }
+@@ -2410,6 +2439,10 @@ dse_delete_plugin(Slapi_Entry *entry, char *returntext)
+ {
+ int rc = LDAP_SUCCESS;
+
++ if (!plugin_entry_is_under_plugin_base(entry)) {
++ return rc;
++ }
++
+ if (!slapi_entry_attr_hasvalue(entry, SLAPI_ATTR_OBJECTCLASS, "nsSlapdPlugin") ||
+ slapi_entry_attr_hasvalue(entry, "nsslapd-PluginEnabled", "off") ||
+ !config_get_dynamic_plugins()) {
+@@ -2620,6 +2653,8 @@ dse_add(Slapi_PBlock *pb) /* JCM There should only be one exit point from this f
+ */
+ if (dse_add_plugin(e, returntext)) {
+ returncode = LDAP_UNWILLING_TO_PERFORM;
++ rc = returncode;
++ e = NULL; /* caller will free upon error */
+ goto done;
+ }
+
+diff --git a/ldap/servers/slapd/fedse.c b/ldap/servers/slapd/fedse.c
+index 71b47260b..89a6ca0f4 100644
+--- a/ldap/servers/slapd/fedse.c
++++ b/ldap/servers/slapd/fedse.c
+@@ -2660,10 +2660,14 @@ init_dse_file(const char *configdir, Slapi_DN *config)
+ }
+ if (rc) {
+ Slapi_PBlock *pb = slapi_pblock_new();
++ Slapi_DN plugins;
+ int dont_write = 1;
+- dse_register_callback(pfedse, DSE_OPERATION_READ, DSE_FLAG_PREOP, config,
++ /* Scope the loader to the plugin subtree: entries elsewhere are never loaded. */
++ slapi_sdn_init_dn_byref(&plugins, PLUGIN_BASE_DN);
++ dse_register_callback(pfedse, DSE_OPERATION_READ, DSE_FLAG_PREOP, &plugins,
+ LDAP_SCOPE_SUBTREE, "(objectclass=nsslapdPlugin)",
+ load_plugin_entry, NULL, NULL);
++ slapi_sdn_done(&plugins);
+ dse_register_callback(pfedse, DSE_OPERATION_READ, DSE_FLAG_PREOP, config,
+ LDAP_SCOPE_BASE, "(objectclass=*)",
+ load_config_dse, NULL, NULL);
+diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
+index c1b0571eb..957b5fa31 100644
+--- a/ldap/servers/slapd/plugin.c
++++ b/ldap/servers/slapd/plugin.c
+@@ -2388,6 +2388,11 @@ plugin_restart(Slapi_Entry *pentryBefore, Slapi_Entry *pentryAfter)
+ char returntext[SLAPI_DSE_RETURNTEXT_SIZE];
+ int rc = LDAP_SUCCESS;
+
++ if (!plugin_entry_is_under_plugin_base(pentryBefore) ||
++ !plugin_entry_is_under_plugin_base(pentryAfter)) {
++ return LDAP_SUCCESS;
++ }
++
+ /*
+ * We can not restart a critical plugin, but the operation should still
+ * be allowed
+@@ -2730,6 +2735,35 @@ plugin_load_critical(struct slapdplugin *plugin)
+ }
+ return 1;
+ }
++
++/*
++ * Return true if the entry DN is strictly under the plugin base DN.
++ * Only such entries are loadable; the base DN itself is not a plugin.
++ */
++int
++plugin_entry_is_under_plugin_base(const Slapi_Entry *entry)
++{
++ Slapi_DN plugin_base;
++ const Slapi_DN *entry_dn;
++ int is_under_base;
++
++ if (entry == NULL) {
++ return 0;
++ }
++
++ entry_dn = slapi_entry_get_sdn_const(entry);
++ if (entry_dn == NULL) {
++ return 0;
++ }
++
++ slapi_sdn_init_dn_byref(&plugin_base, PLUGIN_BASE_DN);
++ is_under_base = slapi_sdn_issuffix(entry_dn, &plugin_base) &&
++ slapi_sdn_compare(entry_dn, &plugin_base) != 0;
++ slapi_sdn_done(&plugin_base);
++
++ return is_under_base;
++}
++
+ /***********************************
+ This is the main entry point for plugin configuration. The plugin_entry argument
+ should already contain the necessary fields required to initialize the plugin and
+@@ -2806,6 +2840,20 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group, slapi_p
+ return -1;
+ }
+
++ /*
++ * This is the single authoritative check for every load path, including
++ * programmatic slapi_register_plugin() calls, so it must stay here even
++ * though the DSE callbacks and dse_add() already filter on the same DN.
++ */
++ if (!plugin_entry_is_under_plugin_base(plugin_entry)) {
++ slapi_log_err(SLAPI_LOG_ERR, "plugin_setup",
++ "Plugin entry \"%s\" is not under %s.\n",
++ slapi_entry_get_dn_const(plugin_entry), PLUGIN_BASE_DN);
++ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
++ "Plugin entry must be under %s.", PLUGIN_BASE_DN);
++ return -1;
++ }
++
+ if ((existname = plugin_exists(slapi_entry_get_sdn_const(plugin_entry))) != NULL) {
+ slapi_log_err(SLAPI_LOG_TRACE, "plugin_setup", "The plugin named %s already exists, "
+ "or is already setup.\n",
+@@ -3103,6 +3151,10 @@ plugin_add(Slapi_Entry *entry, char *returntext, int locked)
+ {
+ int rc = LDAP_SUCCESS;
+
++ if (!plugin_entry_is_under_plugin_base(entry)) {
++ return LDAP_SUCCESS;
++ }
++
+ if (!locked) {
+ slapi_rwlock_wrlock(global_rwlock);
+ slapi_td_set_plugin_locked();
+@@ -3477,6 +3529,10 @@ plugin_delete(Slapi_Entry *plugin_entry, char *returntext, int locked)
+ int type = 0;
+ int rc = LDAP_SUCCESS;
+
++ if (!plugin_entry_is_under_plugin_base(plugin_entry)) {
++ return LDAP_SUCCESS;
++ }
++
+ /* Critical server plugins can not be disabled */
+ if (plugin_is_critical(plugin_entry)) {
+ slapi_log_err(SLAPI_LOG_ERR, "plugin_delete", "Plugin \"%s\" is critical to server operations, and can not be disabled\n",
+diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
+index 5533181d9..c27eaba52 100644
+--- a/ldap/servers/slapd/proto-slap.h
++++ b/ldap/servers/slapd/proto-slap.h
+@@ -1010,6 +1010,7 @@ LDAPControl **operation_get_result_controls(const Operation *o);
+ void global_plugin_init(void);
+ int plugin_call_plugins(Slapi_PBlock *, int);
+ int plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group, slapi_plugin_init_fnptr initfunc, int add_to_dit, char *returntext);
++int plugin_entry_is_under_plugin_base(const Slapi_Entry *entry);
+ int plugin_determine_exop_plugins(const char *oid, struct slapdplugin **plugin);
+ int plugin_call_exop_plugins(Slapi_PBlock *pb, struct slapdplugin *p);
+ Slapi_Backend *plugin_extended_op_getbackend(Slapi_PBlock *pb, struct slapdplugin *p);
+--
+2.56.1
+
diff --git a/0008-Security-fix-for-CVE-2026-119584.patch b/0008-Security-fix-for-CVE-2026-119584.patch
new file mode 100644
index 0000000..8480dda
--- /dev/null
+++ b/0008-Security-fix-for-CVE-2026-119584.patch
@@ -0,0 +1,271 @@
+From 724b65a05b0d71bc53b4a6f266a7b006999a7f9a Mon Sep 17 00:00:00 2001
+From: Viktor Ashirov <vashirov@redhat.com>
+Date: Wed, 4 Nov 2026 23:38:33 +0100
+Subject: [PATCH] Security fix for CVE-2026-119584
+
+Description:
+A malformed SubstringFilter can leak memory. `get_substring_filter()`
+returns LDAP_PROTOCOL_ERROR for a duplicate initial or final component,
+or an unknown tag, without attaching or freeing the decoded value.
+
+Filter parsing runs before access control, and anonymous search is on by
+default. So, an unauthenticated client can leak memory with each such
+request on one connection, and repeated requests may exhaust memory and
+get the server killed by the OOM killer.
+
+Fix:
+Free the decoded value in the duplicate-initial, duplicate-final and
+unknown-tag error paths of `get_substring_filter()`.
+
+References:
+- https://access.redhat.com/security/cve/CVE-2026-119584
+- https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2026-119584
+---
+ .../filter/filter_substring_leak_test.py | 206 ++++++++++++++++++
+ ldap/servers/slapd/filter.c | 3 +
+ 2 files changed, 209 insertions(+)
+ create mode 100644 dirsrvtests/tests/suites/filter/filter_substring_leak_test.py
+
+diff --git a/dirsrvtests/tests/suites/filter/filter_substring_leak_test.py b/dirsrvtests/tests/suites/filter/filter_substring_leak_test.py
+new file mode 100644
+index 000000000..13a70fa57
+--- /dev/null
++++ b/dirsrvtests/tests/suites/filter/filter_substring_leak_test.py
+@@ -0,0 +1,206 @@
++# --- BEGIN COPYRIGHT BLOCK ---
++# Copyright (C) 2026 Red Hat, Inc.
++# All rights reserved.
++#
++# License: GPL (version 3 or any later version).
++# See LICENSE for details.
++# --- END COPYRIGHT BLOCK ---
++#
++import glob
++import logging
++import os
++import socket
++
++import ldap
++import pytest
++
++from test389.topologies import topology_st as topo
++
++pytestmark = pytest.mark.tier1
++DEBUGGING = os.getenv("DEBUGGING", default=False)
++logging.getLogger(__name__).setLevel(logging.DEBUG if DEBUGGING else logging.INFO)
++log = logging.getLogger(__name__)
++
++# Keep each LDAP message below the default nsslapd-maxbersize (2 MiB).
++SUBSTRING_VALUE_SIZE = 1024 * 1024
++REQUESTS_PER_MODE = 8
++MODES = ("duplicate-initial", "duplicate-final", "unknown-tag")
++
++
++def _ber_length(length):
++ """Encode a non-negative BER definite length."""
++ if length < 0x80:
++ return bytes([length])
++ encoded = length.to_bytes((length.bit_length() + 7) // 8, "big")
++ return bytes([0x80 | len(encoded)]) + encoded
++
++
++def _ber_tlv(tag, value):
++ """Encode one BER TLV."""
++ return bytes([tag]) + _ber_length(len(value)) + value
++
++
++def _ber_int(value):
++ """Encode a non-negative BER INTEGER."""
++ encoded = value.to_bytes(max(1, (value.bit_length() + 7) // 8), "big")
++ if encoded[0] & 0x80:
++ encoded = b"\x00" + encoded
++ return _ber_tlv(0x02, encoded)
++
++
++def _substring_filter(mode):
++ """Build a malformed SubstringFilter for one of the leak paths."""
++ attribute = _ber_tlv(0x04, b"cn")
++ big_value = b"A" * SUBSTRING_VALUE_SIZE
++
++ if mode == "duplicate-initial":
++ # A second [0] initial reaches the f_sub_initial duplicate check.
++ substrings = _ber_tlv(0x80, b"a") + _ber_tlv(0x80, big_value)
++ elif mode == "duplicate-final":
++ # A second [2] final reaches the f_sub_final duplicate check.
++ substrings = _ber_tlv(0x82, b"a") + _ber_tlv(0x82, big_value)
++ else:
++ # An unknown substring choice reaches the switch default branch.
++ substrings = _ber_tlv(0x83, big_value)
++
++ return _ber_tlv(0xA4, attribute + _ber_tlv(0x30, substrings))
++
++
++def _search_request(msgid, mode):
++ """Build a complete anonymous SearchRequest with a malformed filter."""
++ body = b"".join(
++ [
++ _ber_tlv(0x04, b""), # baseObject (root DSE)
++ _ber_tlv(0x0A, b"\x00"), # scope = baseObject
++ _ber_tlv(0x0A, b"\x00"), # derefAliases = never
++ _ber_int(0), # sizeLimit
++ _ber_int(0), # timeLimit
++ _ber_tlv(0x01, b"\x00"), # typesOnly = FALSE
++ _substring_filter(mode),
++ _ber_tlv(0x30, b""), # attributes
++ ]
++ )
++ return _ber_tlv(0x30, _ber_int(msgid) + _ber_tlv(0x63, body))
++
++
++def _recv_exact(sock, count):
++ data = bytearray()
++ while len(data) < count:
++ chunk = sock.recv(count - len(data))
++ assert chunk, "LDAP connection closed while reading a response"
++ data.extend(chunk)
++ return bytes(data)
++
++
++def _recv_ldap_message(sock):
++ header = _recv_exact(sock, 2)
++ assert header[0] == 0x30, "expected an LDAPMessage SEQUENCE"
++ length = header[1]
++ if length & 0x80:
++ length = int.from_bytes(_recv_exact(sock, length & 0x7F), "big")
++ body = _recv_exact(sock, length)
++
++ assert body[0] == 0x02, "expected the messageID INTEGER"
++ id_length = body[1]
++ msgid = int.from_bytes(body[2:2 + id_length], "big")
++ op_offset = 2 + id_length
++ tag = body[op_offset]
++ op_length = body[op_offset + 1]
++ op_offset += 2
++ if op_length & 0x80:
++ length_bytes = op_length & 0x7F
++ op_length = int.from_bytes(body[op_offset:op_offset + length_bytes], "big")
++ op_offset += length_bytes
++ return msgid, tag, body[op_offset:op_offset + op_length]
++
++
++def _recv_result(sock, expected_msgid):
++ """Read a search response and return its resultCode."""
++ while True:
++ msgid, tag, payload = _recv_ldap_message(sock)
++ assert msgid == expected_msgid, "unexpected LDAP message ID"
++ if tag == 0x64: # SearchResultEntry, only expected for a valid search
++ continue
++ assert tag == 0x65, "unexpected LDAP response tag: {}".format(tag)
++ assert payload[0] == 0x0A, "SearchResultDone has no resultCode"
++ return payload[2]
++
++
++def test_substring_filter_duplicate_components_no_leak(topo):
++ """Malformed substring filters are rejected without leaking memory
++
++ The duplicate initial/final and unknown-tag branches of
++ get_substring_filter() used to return without freeing the value that
++ ber_scanf() had just allocated.
++
++ :id: 1af6915d-0c25-45e4-a8e5-439bd9f45a43
++ :setup: Standalone instance
++ :steps:
++ 1. Send SearchRequests with a duplicate substring initial component.
++ 2. Send SearchRequests with a duplicate substring final component.
++ 3. Send SearchRequests with an unknown substring component tag.
++ 4. Send a valid substring search and verify it still succeeds.
++ 5. Stop the server and check the sanitizer report for leaks.
++ :expectedresults:
++ 1. Every request is rejected with LDAP_PROTOCOL_ERROR.
++ 2. Every request is rejected with LDAP_PROTOCOL_ERROR.
++ 3. Every request is rejected with LDAP_PROTOCOL_ERROR.
++ 4. The valid search returns LDAP_SUCCESS.
++ 5. No direct leak is reported.
++ """
++ inst = topo.standalone
++ msgid = 1
++
++ for mode in MODES:
++ log.info("Sending %d malformed %s requests", REQUESTS_PER_MODE, mode)
++ with socket.create_connection((inst.host, inst.port), timeout=30) as sock:
++ sock.settimeout(30)
++ for _ in range(REQUESTS_PER_MODE):
++ sock.sendall(_search_request(msgid, mode))
++ result = _recv_result(sock, msgid)
++ assert result == ldap.PROTOCOL_ERROR.errnum, (
++ "{} request returned resultCode {}, expected {}".format(
++ mode, result, ldap.PROTOCOL_ERROR.errnum))
++ msgid += 1
++
++ # The parser must still work after the rejected requests.
++ log.info("Sending a valid substring search")
++ valid_filter = _ber_tlv(
++ 0xA4,
++ _ber_tlv(0x04, b"objectClass") + _ber_tlv(0x30, _ber_tlv(0x80, b"*")),
++ )
++ body = b"".join(
++ [
++ _ber_tlv(0x04, b""),
++ _ber_tlv(0x0A, b"\x00"),
++ _ber_tlv(0x0A, b"\x00"),
++ _ber_int(0),
++ _ber_int(0),
++ _ber_tlv(0x01, b"\x00"),
++ valid_filter,
++ _ber_tlv(0x30, b""),
++ ]
++ )
++ with socket.create_connection((inst.host, inst.port), timeout=30) as sock:
++ sock.settimeout(30)
++ sock.sendall(_ber_tlv(0x30, _ber_int(msgid) + _ber_tlv(0x63, body)))
++ assert _recv_result(sock, msgid) == ldap.SUCCESS.errnum
++
++ pid = str(inst.get_pid())
++ report_pattern = os.path.join(
++ inst.ds_paths.run_dir, "ns-slapd-{}.*.{}".format(inst.serverid, pid))
++ for stale_report in glob.glob(report_pattern):
++ os.remove(stale_report)
++
++ inst.stop()
++ reports = glob.glob(report_pattern)
++ for report in reports:
++ with open(report, "r", errors="replace") as report_file:
++ content = report_file.read()
++ assert "Direct leak" not in content, (
++ "memory leak detected in {}:\n{}".format(report, content))
++
++
++if __name__ == "__main__":
++ CURRENT_FILE = os.path.realpath(__file__)
++ pytest.main("-s {}".format(CURRENT_FILE))
+diff --git a/ldap/servers/slapd/filter.c b/ldap/servers/slapd/filter.c
+index f67c6d1d8..ff88a7b03 100644
+--- a/ldap/servers/slapd/filter.c
++++ b/ldap/servers/slapd/filter.c
+@@ -496,6 +496,7 @@ get_substring_filter(
+ case LDAP_SUBSTRING_INITIAL:
+ slapi_log_err(SLAPI_LOG_FILTER, "get_substring_filter", "INITIAL\n");
+ if (f->f_sub_initial != NULL) {
++ slapi_ch_free_string(&val);
+ return (LDAP_PROTOCOL_ERROR);
+ }
+ f->f_sub_initial = val;
+@@ -528,6 +529,7 @@ get_substring_filter(
+ case LDAP_SUBSTRING_FINAL:
+ slapi_log_err(SLAPI_LOG_FILTER, "get_substring_filter", "FINAL\n");
+ if (f->f_sub_final != NULL) {
++ slapi_ch_free_string(&val);
+ return (LDAP_PROTOCOL_ERROR);
+ }
+ f->f_sub_final = val;
+@@ -545,6 +547,7 @@ get_substring_filter(
+
+ default:
+ slapi_log_err(SLAPI_LOG_FILTER, "get_substring_filter", "Unknown tag 0x%lX\n", tag);
++ slapi_ch_free_string(&val);
+ return (LDAP_PROTOCOL_ERROR);
+ }
+ }
+--
+2.56.1
+
diff --git a/0009-Issue-7921-Fix-StartTLS-plaintext-buffer-handling-79.patch b/0009-Issue-7921-Fix-StartTLS-plaintext-buffer-handling-79.patch
new file mode 100644
index 0000000..fa2c143
--- /dev/null
+++ b/0009-Issue-7921-Fix-StartTLS-plaintext-buffer-handling-79.patch
@@ -0,0 +1,430 @@
+From b9fe2d1e140c79dafda5c3231d1401d5d6a991f0 Mon Sep 17 00:00:00 2001
+From: "github-actions[bot]"
+ <41898282+github-actions[bot]@users.noreply.github.com>
+Date: Wed, 7 Oct 2026 10:54:02 +0100
+Subject: [PATCH] Issue 7921 - Fix StartTLS plaintext buffer handling (#7922)
+ (#7943)
+
+Security fix for CVE-2026-86345
+
+Description:
+With StartTLS, leftover plaintext in the connection read buffer was not
+discarded. A MITM attacker could append another PDU to the same TCP
+packet as the StartTLS request. A second worker could drain that buffer
+before start_tls() ran, so an op contained in the second PDU would be
+run and clients, that use bind result could be fooled into thinking the
+auth was successful, when it wasnt.
+
+Fix:
+- Do not queue another worker for more_data when the current op is StartTLS.
+- In start_tls(), reject and disconnect if the read buffer still has data.
+
+Fixes: https://github.com/389ds/389-ds-base/issues/7921
+
+Reviewed by: @mreynolds389, @tbordaz, @progier389 (Thank you)
+
+References:
+- https://bugzilla.redhat.com/show_bug.cgi?id=2529332
+- https://access.redhat.com/security/cve/cve-2026-86345
+
+(cherry picked from commit 216e502d0fc6c5faf2202e937c8cef4bba0bc037)
+---
+ .../tests/suites/tls/starttls_buffer_test.py | 209 ++++++++++++++++++
+ ldap/servers/slapd/connection.c | 67 ++++++
+ ldap/servers/slapd/fe.h | 2 +
+ ldap/servers/slapd/start_tls_extop.c | 44 ++--
+ 4 files changed, 302 insertions(+), 20 deletions(-)
+ create mode 100644 dirsrvtests/tests/suites/tls/starttls_buffer_test.py
+
+diff --git a/dirsrvtests/tests/suites/tls/starttls_buffer_test.py b/dirsrvtests/tests/suites/tls/starttls_buffer_test.py
+new file mode 100644
+index 000000000..2b38a2787
+--- /dev/null
++++ b/dirsrvtests/tests/suites/tls/starttls_buffer_test.py
+@@ -0,0 +1,209 @@
++# --- BEGIN COPYRIGHT BLOCK ---
++# Copyright (C) 2026 Red Hat, Inc.
++# All rights reserved.
++#
++# License: GPL (version 3 or any later version).
++# See LICENSE for details.
++# --- END COPYRIGHT BLOCK ---
++#
++"""Regression tests for StartTLS read-buffer handling (CVE-2026-86345)."""
++
++import logging
++import os
++import socket
++
++import pytest
++from test389.topologies import topology_st as topo
++
++pytestmark = pytest.mark.tier1
++
++DEBUGGING = os.getenv("DEBUGGING", default=False)
++if DEBUGGING:
++ logging.getLogger(__name__).setLevel(logging.DEBUG)
++else:
++ logging.getLogger(__name__).setLevel(logging.INFO)
++log = logging.getLogger(__name__)
++
++START_TLS_OID = b"1.3.6.1.4.1.1466.20037"
++LDAP_SUCCESS = 0
++LDAP_TAG_BIND_RESPONSE = 0x61
++
++
++def _ber_len(n):
++ if n < 0x80:
++ return bytes([n])
++ out = []
++ v = n
++ while v:
++ out.append(v & 0xFF)
++ v >>= 8
++ out.reverse()
++ return bytes([0x80 | len(out)]) + bytes(out)
++
++
++def _ber_tlv(tag, val):
++ if isinstance(val, int):
++ if val == 0:
++ raw = b"\x00"
++ else:
++ raw = b""
++ v = val
++ while v:
++ raw = bytes([v & 0xFF]) + raw
++ v >>= 8
++ if raw[0] & 0x80:
++ raw = b"\x00" + raw
++ val = raw
++ return bytes([tag]) + _ber_len(len(val)) + val
++
++
++def _ldap_message(msgid, protocol_op):
++ return _ber_tlv(0x30, _ber_tlv(0x02, msgid) + protocol_op)
++
++
++def _start_tls_request(msgid=1):
++ return _ldap_message(msgid, _ber_tlv(0x77, _ber_tlv(0x80, START_TLS_OID)))
++
++
++def _simple_bind_request(msgid, bind_dn="", password=""):
++ body = (
++ _ber_tlv(0x02, 3)
++ + _ber_tlv(0x04, bind_dn.encode("utf-8"))
++ + _ber_tlv(0x80, password.encode("utf-8"))
++ )
++ return _ldap_message(msgid, _ber_tlv(0x60, body))
++
++
++def _recv_exact(sock, n, timeout=5.0):
++ sock.settimeout(timeout)
++ buf = b""
++ while len(buf) < n:
++ chunk = sock.recv(n - len(buf))
++ if not chunk:
++ raise EOFError("EOF reading %d bytes (got %d)" % (n, len(buf)))
++ buf += chunk
++ return buf
++
++
++def _read_ber_element(sock, timeout=5.0):
++ hdr = _recv_exact(sock, 2, timeout)
++ tag = hdr[0]
++ first = hdr[1]
++ if first & 0x80:
++ nlen = first & 0x7F
++ if nlen == 0:
++ raise ValueError("indefinite BER length")
++ len_bytes = _recv_exact(sock, nlen, timeout)
++ length = int.from_bytes(len_bytes, "big")
++ rest_hdr = bytes([first]) + len_bytes
++ else:
++ length = first
++ rest_hdr = bytes([first])
++ value = _recv_exact(sock, length, timeout)
++ return bytes([tag]) + rest_hdr + value
++
++
++def _parse_ldap_message(raw):
++ if raw[0] != 0x30:
++ raise ValueError("not a SEQUENCE")
++ i = 1
++ first = raw[i]
++ i += 1
++ if first & 0x80:
++ i += first & 0x7F
++ if raw[i] != 0x02:
++ raise ValueError("expected msgid INTEGER")
++ i += 1
++ mlen = raw[i]
++ i += 1
++ msgid = int.from_bytes(raw[i:i + mlen], "big")
++ i += mlen
++ return msgid, raw[i], raw[i:]
++
++
++def _parse_result_code(protocol_op):
++ i = 1
++ first = protocol_op[i]
++ i += 1
++ if first & 0x80:
++ i += first & 0x7F
++ if protocol_op[i] != 0x0A:
++ idx = protocol_op.find(b"\x0a\x01")
++ if idx < 0:
++ raise ValueError("no resultCode")
++ return protocol_op[idx + 2]
++ i += 1
++ rlen = protocol_op[i]
++ i += 1
++ return int.from_bytes(protocol_op[i:i + rlen], "big")
++
++
++def test_starttls_rejects_smuggled_bind(topo):
++ """StartTLS must not execute a second LDAP PDU from the same TCP read
++
++ :id: 8273e43a-0453-4518-892e-ae1fbc071f42
++ :setup: Standalone instance with TLS enabled
++ :steps:
++ 1. Enable TLS on the instance
++ 2. Open a plaintext LDAP socket and send StartTLS plus an anonymous
++ BindRequest in a single TCP write
++ 3. Collect cleartext LDAP responses (if any) before the connection closes
++ 4. Check the errors log for the StartTLS leftover-buffer rejection
++ :expectedresults:
++ 1. TLS is enabled
++ 2. The write completes
++ 3. No successful BindResponse is returned for the smuggled bind msgid
++ 4. The server logged rejection of unexpected data with StartTLS
++ """
++ inst = topo.standalone
++ log.info("Enabling TLS")
++ inst.enable_tls()
++
++ host = inst.host
++ port = int(inst.port)
++ smuggle_msgid = 2
++ payload = _start_tls_request(1) + _simple_bind_request(smuggle_msgid)
++
++ log.info("Sending StartTLS + BindRequest (%d bytes) to %s:%d",
++ len(payload), host, port)
++ sock = socket.create_connection((host, port), timeout=10)
++ sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
++ sock.sendall(payload)
++
++ bind_success = False
++ responses = []
++ try:
++ for _ in range(8):
++ try:
++ raw = _read_ber_element(sock, timeout=3.0)
++ except (socket.timeout, TimeoutError, EOFError, OSError) as exc:
++ log.info("Stopped reading cleartext responses: %s", exc)
++ break
++ msgid, tag, pop = _parse_ldap_message(raw)
++ rc = _parse_result_code(pop)
++ responses.append((msgid, tag, rc))
++ log.info("Cleartext response msgid=%d tag=0x%02x result=%d",
++ msgid, tag, rc)
++ if msgid == smuggle_msgid and tag == LDAP_TAG_BIND_RESPONSE and rc == LDAP_SUCCESS:
++ bind_success = True
++ break
++ finally:
++ try:
++ sock.close()
++ except OSError:
++ pass
++
++ assert not bind_success, (
++ "Smuggled BindResponse success was delivered; "
++ "responses=%r" % (responses,)
++ )
++
++ # Fixed servers reject StartTLS when leftover plaintext remains.
++ assert inst.ds_error_log.match(
++ ".*Rejecting StartTLS.*unexpected data.*"
++ ), "Expected StartTLS leftover-buffer rejection in the errors log"
++
++
++if __name__ == "__main__":
++ CURRENT_FILE = os.path.realpath(__file__)
++ pytest.main(["-s", CURRENT_FILE])
+diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
+index 9d651e281..b2a0eead0 100644
+--- a/ldap/servers/slapd/connection.c
++++ b/ldap/servers/slapd/connection.c
+@@ -37,6 +37,7 @@ static void connection_add_operation(Connection *conn, Operation *op);
+ static void connection_free_private_buffer(Connection *conn);
+ static void op_copy_identity(Connection *conn, Operation *op);
+ static void connection_set_ssl_ssf(Connection *conn);
++static bool connection_is_start_tls(Operation *op);
+ static int is_ber_too_big(const Connection *conn, ber_len_t ber_len);
+ static void log_ber_too_big_error(const Connection *conn,
+ ber_len_t ber_len,
+@@ -1106,6 +1107,33 @@ connection_wait_for_new_work(Slapi_PBlock *pb, int32_t interval)
+
+ #include "openldapber.h"
+
++/*
++ * Check whether the extended operation is StartTLS.
++ */
++static bool
++connection_is_start_tls(Operation *op)
++{
++ BerElement *ber = NULL;
++ char *oid = NULL;
++ int is_starttls = 0;
++
++ if (op == NULL || op->o_ber == NULL || op->o_tag != LDAP_REQ_EXTENDED) {
++ return 0;
++ }
++
++ ber = ber_dup(op->o_ber);
++ if (ber == NULL) {
++ return 0;
++ }
++ if (ber_scanf(ber, "{a", &oid) != LBER_ERROR && oid != NULL) {
++ is_starttls = (strcmp(oid, START_TLS_OID) == 0);
++ }
++ slapi_ch_free_string(&oid);
++ /* Free the dup, not the riginal ber. */
++ ber_free(ber, 0);
++ return is_starttls;
++}
++
+ static ber_tag_t
+ _ber_get_len(BerElement *ber, ber_len_t *lenp)
+ {
+@@ -2013,6 +2041,16 @@ connection_threadmain(void *arg)
+ /* once the connection is readable, another thread may access conn,
+ * so need locking from here on */
+ signal_listner(conn->c_ct_list);
++ } else if (connection_is_start_tls(op)) {
++ /*
++ * The StartTLS PDU has already been read into op->o_ber, but there is more data
++ * in c_buffer. Previously we continued, but now we do not requeue this connection
++ * as another worker could read the extra data as a separate op while this thread
++ * continues into start_tls().
++ */
++ slapi_log_err(SLAPI_LOG_CONNS, "connection_threadmain",
++ "conn %" PRIu64 " has buffered data following StartTLS request\n",
++ conn->c_connid);
+ } else { /* more data in conn - just put back on work_q - bypass poll */
+ pthread_mutex_lock(&(conn->c_mutex));
+ /* don't do this if it would put us over the max threads per conn */
+@@ -2782,6 +2820,35 @@ connection_abandon_operations(Connection *c)
+ }
+ }
+
++/*
++ * Return the number of bytes remaining in the read buffer.
++ * Must be called within c->c_mutex.
++ */
++size_t
++connection_read_buffer_data_len(Connection *c)
++{
++ int conn_closed = 0;
++
++ if (c == NULL || c->c_private == NULL) {
++ return 0;
++ }
++ return conn_buffered_data_avail_nolock(c, &conn_closed);
++}
++
++/*
++ * Clear any data left in c_buffer.
++ * Must be called within c->c_mutex.
++ */
++void
++connection_reset_read_buffer(Connection *c)
++{
++ if (c == NULL || c->c_private == NULL) {
++ return;
++ }
++ c->c_private->c_buffer_bytes = 0;
++ c->c_private->c_buffer_offset = 0;
++}
++
+ /* must be called within c->c_mutex */
+ void
+ connection_set_io_layer_cb(Connection *c, Conn_IO_Layer_cb push_cb, Conn_IO_Layer_cb pop_cb, void *cb_data)
+diff --git a/ldap/servers/slapd/fe.h b/ldap/servers/slapd/fe.h
+index ad90dba2e..be4b4f465 100644
+--- a/ldap/servers/slapd/fe.h
++++ b/ldap/servers/slapd/fe.h
+@@ -68,6 +68,8 @@ void connection_cleanup(Connection *conn);
+ void connection_reset(Connection *conn, int ns, PRNetAddr *from, int fromLen, int is_SSL);
+ void connection_set_io_layer_cb(Connection *c, Conn_IO_Layer_cb push_cb, Conn_IO_Layer_cb pop_cb, void *cb_data);
+ int connection_call_io_layer_callbacks(Connection *c);
++size_t connection_read_buffer_data_len(Connection *c);
++void connection_reset_read_buffer(Connection *c);
+
+ /*
+ * conntable.c
+diff --git a/ldap/servers/slapd/start_tls_extop.c b/ldap/servers/slapd/start_tls_extop.c
+index f415c41e0..e08865e95 100644
+--- a/ldap/servers/slapd/start_tls_extop.c
++++ b/ldap/servers/slapd/start_tls_extop.c
+@@ -185,6 +185,24 @@ start_tls(Slapi_PBlock *pb)
+
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+
++ /*
++ * RFC 4511 requires clients to wait for the StartTLS response before sending
++ * additional PDUs. Any data remaining after the StartTLS request has been
++ * consumed is a protocol violation.
++ */
++ if (connection_read_buffer_data_len(conn) > 0) {
++ slapi_log_err(SLAPI_LOG_ERR, "start_tls",
++ "Rejecting StartTLS, unexpected data after StartTLS request on conn=%"
++ PRIu64 ".\n", conn->c_connid);
++ connection_reset_read_buffer(conn);
++ ldaprc = LDAP_PROTOCOL_ERROR;
++ ldapmsg = "Unexpected data received with StartTLS request.";
++ disconnect_server_nomutex(conn, conn->c_connid,
++ pb_op ? pb_op->o_opid : -1,
++ SLAPD_DISCONNECT_BAD_BER_TAG, EPROTO);
++ goto unlock_and_return;
++ }
++
+ /* Check whether the Start TLS request can be accepted. */
+ if (connection_operations_pending(conn, pb_op,
+ 1 /* check for ops where result not yet sent */)) {
+@@ -192,26 +210,12 @@ start_tls(Slapi_PBlock *pb)
+ if (op == pb_op) {
+ continue;
+ }
+- if ((op->o_msgid == -1) && (op->o_tag == LBER_DEFAULT)) {
+- /* while processing start-tls extop we also received a new incoming operation
+- * As this operation will not processed until start-tls completes.
+- * Be fair do not consider this operation as a pending one
+- */
+- slapi_log_err(SLAPI_LOG_CONNS, "start_tls",
+- "New incoming operation blocked by start-tls, Continue start-tls (conn=%"PRIu64").\n",
+- conn->c_connid);
+- continue;
+- } else {
+- /* It is problematic, this pending operation is processed and
+- * start-tls can push new network layer while the operation
+- * send result. Safest to abort start-tls
+- */
+- slapi_log_err(SLAPI_LOG_CONNS, "start_tls",
+- "Other operations are still pending on the connection.\n");
+- ldaprc = LDAP_OPERATIONS_ERROR;
+- ldapmsg = "Other operations are still pending on the connection.";
+- goto unlock_and_return;
+- }
++ /* Do not StartTLS while another operation is still pending. */
++ slapi_log_err(SLAPI_LOG_CONNS, "start_tls",
++ "Other operations are still pending on the connection.\n");
++ ldaprc = LDAP_OPERATIONS_ERROR;
++ ldapmsg = "Other operations are still pending on the connection.";
++ goto unlock_and_return;
+ }
+ }
+
+--
+2.56.1
+
diff --git a/0010-Issue-7919-CVE-2026-86344-Fix-worker-pool-exhaustion.patch b/0010-Issue-7919-CVE-2026-86344-Fix-worker-pool-exhaustion.patch
new file mode 100644
index 0000000..191a60a
--- /dev/null
+++ b/0010-Issue-7919-CVE-2026-86344-Fix-worker-pool-exhaustion.patch
@@ -0,0 +1,386 @@
+From c26e849507749f279d3db64b09414139a499f50f Mon Sep 17 00:00:00 2001
+From: Mark Reynolds <mreynolds@redhat.com>
+Date: Mon, 21 Sep 2026 13:20:29 -0400
+Subject: [PATCH] Issue 7919 - CVE-2026-86344 - Fix worker pool exhaustion via
+ partial LDAP messages (DoS)
+
+Bug Description:
+
+A flaw in the connection handling logic allowed an unauthenticated
+attacker to exhaust the worker thread pool by sending a complete
+LDAP operation followed by the initial bytes of a second, incomplete
+message. The server would requeue the connection, and a second worker
+would block while holding the connection mutex (c_mutex), preventing
+the first worker from delivering its result.
+
+Fix Description:
+
+This commit resolves the issue and addresses related concurrency traps:
+1. Yield c_mutex during I/O waits: connection_read_operation() now
+ releases c_mutex while blocked in PR_Poll(). This allows other workers
+ to acquire the lock to flush results or log operations for the same
+ connection.
+2. Revalidation: The connection state is re-validated immediately after
+ re-acquiring c_mutex to ensure the connection was not closed during
+ the I/O wait.
+3. Lock Ordering: The fix preserves c_mutex -> c_pdumutex ordering.
+ It yields c_mutex while holding c_pdumutex, then releases
+ c_pdumutex before re-acquiring c_mutex to avoid deadlocks with
+ threads calling flush_ber().
+
+Includes a regression suite covering both the DoS mitigation and
+fragmented requests.
+
+Fixes: https://github.com/389ds/389-ds-base/issues/7919
+
+Assisted-by: Cursor & spichugi
+
+Reviewed by: tbordaz & spichugi(Thanks!!)
+
+(cherry picked from commit 1b26a640c83becf1cbd127366dba44ff673051bd)
+---
+ dirsrvtests/tests/suites/security/dos_test.py | 251 ++++++++++++++++++
+ ldap/servers/slapd/connection.c | 38 ++-
+ 2 files changed, 285 insertions(+), 4 deletions(-)
+ create mode 100644 dirsrvtests/tests/suites/security/dos_test.py
+
+diff --git a/dirsrvtests/tests/suites/security/dos_test.py b/dirsrvtests/tests/suites/security/dos_test.py
+new file mode 100644
+index 000000000..ea240bf6e
+--- /dev/null
++++ b/dirsrvtests/tests/suites/security/dos_test.py
+@@ -0,0 +1,251 @@
++# --- BEGIN COPYRIGHT BLOCK ---
++# Copyright (C) 2026 Red Hat, Inc.
++# All rights reserved.
++#
++# License: GPL (version 3 or any later version).
++# See LICENSE for details.
++# --- END COPYRIGHT BLOCK ---
++#
++import logging
++import os
++import re
++import time
++import socket
++import pytest
++from lib389._constants import *
++from test389.topologies import topology_st
++
++pytestmark = pytest.mark.tier1
++DEBUGGING = os.getenv("DEBUGGING", default=False)
++logging.getLogger(__name__).setLevel(logging.DEBUG if DEBUGGING else logging.INFO)
++log = logging.getLogger(__name__)
++
++
++def _recv_exact(sock, count):
++ data = bytearray()
++ while len(data) < count:
++ chunk = sock.recv(count - len(data))
++ assert chunk, "LDAP connection closed while reading a response"
++ data.extend(chunk)
++ return bytes(data)
++
++
++def _recv_ldap_message(sock):
++ header = _recv_exact(sock, 2)
++ assert header[0] == 0x30
++ length = header[1]
++ if length & 0x80:
++ length = int.from_bytes(_recv_exact(sock, length & 0x7f), "big")
++ body = _recv_exact(sock, length)
++ assert body[0] == 0x02
++ id_length = body[1]
++ msgid = int.from_bytes(body[2:2 + id_length], "big")
++ op_offset = 2 + id_length
++ tag = body[op_offset]
++ op_length = body[op_offset + 1]
++ op_offset += 2
++ if op_length & 0x80:
++ length_bytes = op_length & 0x7f
++ op_length = int.from_bytes(body[op_offset:op_offset + length_bytes], "big")
++ op_offset += length_bytes
++ return msgid, tag, body[op_offset:op_offset + op_length]
++
++
++def _recv_search_done(sock, expected_msgid):
++ while True:
++ msgid, tag, payload = _recv_ldap_message(sock)
++ assert msgid == expected_msgid
++ assert tag in (0x64, 0x65), "unexpected LDAP response tag: {}".format(tag)
++ if tag == 0x65:
++ assert payload.startswith(b"\x0a\x01\x00"), "Search result was not LDAP success"
++ return
++
++
++def _wait_for_error_log(inst, offset, pattern, timeout):
++ deadline = time.monotonic() + timeout
++ while time.monotonic() < deadline:
++ with open(inst.errlog, "r", errors="replace") as errlog:
++ errlog.seek(offset)
++ match = re.search(pattern, errlog.read())
++ if match:
++ return match
++ time.sleep(0.02)
++ return None
++
++
++def test_dos_partial_message(topology_st):
++ """Verify that a partial LDAP message does not block previous operations on the same connection.
++
++ This exercises the race deterministically instead of racing a wall-clock
++ timeout: nsslapd-ioblocktimeout is pinned to a known, short value, and we
++ wait on the error log for proof that the server actually queued the
++ buffered second request ("more_data") before measuring how fast the
++ first Bind response arrives. This avoids CI-load-dependent flakiness
++ while still failing clearly (and quickly) if the connection mutex is
++ ever held across the second worker's blocking read again.
++
++ :id: 3c59bb2a-0f77-477e-aa1c-de3aa8a0fa80
++ :setup: Standalone instance with connection logging and a short, pinned
++ ioblocktimeout
++ :steps:
++ 1. Connect to the server.
++ 2. Send a complete Anonymous Bind request followed by a partial second message.
++ 3. Wait for the error log to confirm the second (partial) message was buffered/queued.
++ 4. Verify that the Bind response for the first message is received promptly.
++ 5. Verify that other connections can still be established and used.
++ :expectedresults:
++ 1. Connection established.
++ 2. Data sent.
++ 3. The server logs that it queued the connection due to buffered data.
++ 4. Bind response received well within ioblocktimeout.
++ 5. Server remains responsive.
++ """
++ inst = topology_st.standalone
++ original_loglevel = inst.config.get_attr_val_utf8("nsslapd-errorlog-level")
++ original_ioblocktimeout = inst.config.get_attr_val_utf8("nsslapd-ioblocktimeout")
++ # Short enough that a regression (worker blocked for the full timeout)
++ # fails fast, long enough that CI scheduling jitter can't trip it.
++ test_ioblocktimeout_ms = 5000
++ s = None
++ try:
++ inst.config.loglevel([ErrorLog.CONNECT, ErrorLog.DEFAULT])
++ inst.config.replace("nsslapd-ioblocktimeout", str(test_ioblocktimeout_ms))
++ inst.restart()
++
++ # Anonymous Bind (MsgID=1): 30 0c 02 01 01 60 07 02 01 03 04 00 80 00
++ bind_req = b'\x30\x0c\x02\x01\x01\x60\x07\x02\x01\x03\x04\x00\x80\x00'
++ # Partial Bind (MsgID=2): 30 0c 02 01 02 ... (stops here)
++ partial_req = b'\x30\x0c\x02\x01\x02'
++
++ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
++ s.connect((inst.host, inst.port))
++ # Generous safety-net timeout: a true hang (bug reintroduced) should
++ # approach the full ioblocktimeout, so this only needs enough margin
++ # over that worst case to avoid masking a real failure as an error.
++ s.settimeout((test_ioblocktimeout_ms / 1000.0) + 5)
++
++ log_offset = os.path.getsize(inst.errlog)
++ log.info("Sending full bind request + partial second message")
++ s.sendall(bind_req + partial_req)
++
++ # Confirm the race window is actually open: the server must have
++ # buffered the partial second message and queued the connection
++ # before we start timing the response.
++ queued = _wait_for_error_log(
++ inst, log_offset, r"conn \d+ queued because more_data", 5)
++ assert queued is not None, "the partial second message was not buffered/queued"
++
++ start = time.monotonic()
++ log.info("Waiting for bind response...")
++ try:
++ data = s.recv(1024)
++ except socket.timeout:
++ pytest.fail("Timed out waiting for bind response. The server might be deadlocked.")
++ elapsed = time.monotonic() - start
++ log.info(f"Bind response received after {elapsed:.2f}s")
++ log.debug(f"Received data: {data.hex()}")
++
++ # Bind response for MsgID=1: 30 0c 02 01 01 61 07 0a 01 00 04 00 04 00
++ assert b'\x02\x01\x01\x61' in data
++ # The real regression signature is the response taking close to the
++ # full ioblocktimeout (because a second worker held c_mutex while
++ # blocked reading the fragment). A healthy server replies almost
++ # immediately, so a generous fraction of the timeout still leaves
++ # plenty of margin above normal scheduling noise.
++ assert elapsed < (test_ioblocktimeout_ms / 1000.0) / 2, (
++ f"Bind response took {elapsed:.2f}s - the server may be blocked "
++ f"behind the partial second LDAP message"
++ )
++ log.info("Successfully received a prompt bind response for the first operation")
++ finally:
++ if s is not None:
++ s.close()
++ inst.config.replace("nsslapd-errorlog-level", original_loglevel)
++ inst.config.replace("nsslapd-ioblocktimeout", original_ioblocktimeout)
++ inst.restart()
++
++ # Verify server is still responsive
++ log.info("Verifying server responsiveness")
++ inst.open()
++ assert "dn: cn=directory manager" == inst.whoami_s()
++
++
++def test_pipelined_partial_request_has_one_reader(topology_st):
++ """A queued worker must not start reading a PDU already owned by another worker.
++
++ :id: 357d2ba4-ae82-4da4-9b8b-f97de9653c26
++ :setup: Standalone instance with two worker threads and connection logging
++ :steps:
++ 1. Park one worker on an incomplete request on a separate connection.
++ 2. Send a complete Search request and the first five bytes of a second Search on one connection.
++ 3. Receive the first Search result and release the parked worker while the second request is incomplete.
++ 4. Finish the second Search request and receive its result.
++ :expectedresults:
++ 1. The parked worker waits for the remaining bytes.
++ 2. The server queues the buffered second request.
++ 3. The queued worker does not try to read the incomplete PDU concurrently.
++ 4. The second Search succeeds without disconnecting the connection.
++ """
++ inst = topology_st.standalone
++ original_threads = inst.config.get_attr_val_utf8("nsslapd-threadnumber")
++ original_loglevel = inst.config.get_attr_val_utf8("nsslapd-errorlog-level")
++ original_ioblocktimeout = inst.config.get_attr_val_utf8("nsslapd-ioblocktimeout")
++ target = None
++ parked = None
++ try:
++ inst.config.replace("nsslapd-threadnumber", "2")
++ inst.config.replace("nsslapd-ioblocktimeout", "30000")
++ inst.config.loglevel([ErrorLog.CONNECT, ErrorLog.DEFAULT])
++ inst.restart()
++
++ target = socket.create_connection((inst.host, inst.port), timeout=5)
++ target.settimeout(5)
++ # Complete an initial Bind before sending the pipelined Search requests.
++ target.sendall(bytes.fromhex("30 0c 02 01 01 60 07 02 01 03 04 00 80 00"))
++ assert _recv_ldap_message(target)[:2] == (1, 0x61)
++
++ parked = socket.create_connection((inst.host, inst.port), timeout=5)
++ parked.settimeout(5)
++ # This valid LDAPMessage prefix keeps one worker waiting for its body.
++ parked_offset = os.path.getsize(inst.errlog)
++ parked.sendall(bytes.fromhex("30 0c 02 01 01"))
++ parked_read = _wait_for_error_log(
++ inst, parked_offset, r"connection \d+ read 5 bytes", 5)
++ assert parked_read is not None, "the parked worker did not read its partial request"
++ time.sleep(0.25)
++
++ search = (bytes.fromhex("30 25 02 01 02 63 20 04 00 0a 01 00 0a 01 00 "
++ "02 01 00 02 01 00 01 01 00 87 0b") +
++ b"objectClass" + bytes.fromhex("30 00"))
++ search2 = search[:4] + b"\x03" + search[5:]
++ log_offset = os.path.getsize(inst.errlog)
++ target.sendall(search + search2[:5])
++
++ queued = _wait_for_error_log(inst, log_offset,
++ r"conn (\d+) queued because more_data", 5)
++ assert queued is not None, "the second Search was not queued from buffered data"
++ conn_id = queued.group(1)
++ _recv_search_done(target, 2)
++ # Allow the first worker to enter the poll for the second Search body.
++ time.sleep(0.25)
++
++ parked.close()
++ parked = None
++ duplicate_read = _wait_for_error_log(
++ inst, log_offset,
++ r"conn {} read not ready due to 4\b".format(conn_id), 2)
++
++ target.sendall(search2[5:])
++ _recv_search_done(target, 3)
++ assert duplicate_read is None, (
++ "a second worker read the connection while the first was assembling "
++ "the fragmented Search request: {}".format(duplicate_read.group(0)))
++ finally:
++ if parked is not None:
++ parked.close()
++ if target is not None:
++ target.close()
++ inst.config.replace("nsslapd-threadnumber", original_threads)
++ inst.config.replace("nsslapd-errorlog-level", original_loglevel)
++ inst.config.replace("nsslapd-ioblocktimeout", original_ioblocktimeout)
++ inst.restart()
+diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
+index b2a0eead0..fdd3b32b8 100644
+--- a/ldap/servers/slapd/connection.c
++++ b/ldap/servers/slapd/connection.c
+@@ -189,7 +189,7 @@ connection_cleanup(Connection *conn)
+ /*
+ * We hang onto these, since we can reuse them.
+ * Sockbuf *c_sb;
+- * PRLock *c_mutex;
++ * pthread_mutex_t c_mutex;
+ * PRLock *c_pdumutex;
+ * Conn_private *c_private;
+ */
+@@ -1291,7 +1291,6 @@ connection_read_operation(Connection *conn, Operation *op, ber_tag_t *tag, int *
+ int32_t waits_done = 0;
+ ber_int_t msgid;
+ int new_operation = 1; /* Are we doing the first I/O read for a new operation ? */
+- char *buffer = conn->c_private->c_buffer;
+ PRErrorCode err = 0;
+ PRInt32 syserr = 0;
+ size_t buffer_data_avail;
+@@ -1325,7 +1324,7 @@ connection_read_operation(Connection *conn, Operation *op, ber_tag_t *tag, int *
+ /* First check to see if we have buffered data from "before" */
+ if ((buffer_data_avail = conn_buffered_data_avail_nolock(conn, &conn_closed))) {
+ /* If so, use that data first */
+- if (0 != get_next_from_buffer(buffer + conn->c_private->c_buffer_offset,
++ if (0 != get_next_from_buffer(conn->c_private->c_buffer + conn->c_private->c_buffer_offset,
+ buffer_data_avail,
+ &len, tag, op->o_ber, conn)) {
+ ret = CONN_DONE;
+@@ -1474,9 +1473,40 @@ connection_read_operation(Connection *conn, Operation *op, ber_tag_t *tag, int *
+ pr_pd.fd = (PRFileDesc *)conn->c_prfd;
+ pr_pd.in_flags = PR_POLL_READ;
+ pr_pd.out_flags = 0;
++ /*
++ * To avoid deadlocks and allow other worker threads to flush
++ * results for this connection, we must yield c_mutex while
++ * waiting for I/O.
++ *
++ * Lock Hierarchy: c_mutex -> c_pdumutex
++ *
++ * We acquire c_pdumutex while holding c_mutex to ensure no other
++ * thread begins a read/write operation during the transition.
++ * We then release c_mutex to allow other threads to access
++ * connection metadata (e.g., for logging or result flushing).
++ */
+ PR_Lock(conn->c_pdumutex);
++ pthread_mutex_unlock(&(conn->c_mutex));
++
+ ret = PR_Poll(&pr_pd, 1, timeout);
++
++ /*
++ * DEADLOCK AVOIDANCE: We MUST release c_pdumutex BEFORE
++ * re-acquiring c_mutex.
++ *
++ * If we held c_pdumutex while waiting for c_mutex, we could
++ * deadlock with a thread that holds c_mutex and is waiting
++ * for c_pdumutex (e.g., in flush_ber() called from a SASL bind).
++ */
+ PR_Unlock(conn->c_pdumutex);
++ pthread_mutex_lock(&(conn->c_mutex));
++
++ /* check if the connection was closed while we were waiting */
++ if ((conn->c_sd == SLAPD_INVALID_SOCKET) ||
++ (conn->c_flags & CONN_FLAG_CLOSING)) {
++ ret = CONN_DONE;
++ goto done;
++ }
+ waits_done++;
+ /* Did we time out ? */
+ if (0 == ret) {
+@@ -1539,7 +1569,7 @@ connection_read_operation(Connection *conn, Operation *op, ber_tag_t *tag, int *
+ conn->c_private->c_buffer_bytes = ret;
+ conn->c_private->c_buffer_offset = 0;
+
+- if (get_next_from_buffer(buffer,
++ if (get_next_from_buffer(conn->c_private->c_buffer,
+ conn->c_private->c_buffer_bytes - conn->c_private->c_buffer_offset,
+ &len, tag, op->o_ber, conn) != 0) {
+ ret = CONN_DONE;
+--
+2.56.1
+
diff --git a/0011-Issue-7919-Coordinate-PDU-writer-handoff-and-buffere.patch b/0011-Issue-7919-Coordinate-PDU-writer-handoff-and-buffere.patch
new file mode 100644
index 0000000..162827f
--- /dev/null
+++ b/0011-Issue-7919-Coordinate-PDU-writer-handoff-and-buffere.patch
@@ -0,0 +1,273 @@
+From 4088e755704c2309f4aecd5c767f10ea84f39eb5 Mon Sep 17 00:00:00 2001
+From: Simon Pichugin <spichugi@redhat.com>
+Date: Tue, 6 Oct 2026 12:19:14 -0700
+Subject: [PATCH] Issue 7919 - Coordinate PDU writer handoff and buffered reads
+
+Description: When the reader sees a result writer waiting on c_pdumutex,
+wait for a writer to acquire the lock before starting another
+partial-message poll. This prevents repeated reader reacquisition from
+delaying result flushing.
+
+Prevent the current worker from reclaiming a buffered read already handed
+to the listener or work queue. With that handoff, the current worker
+cannot compete to read the next PDU.
+
+Relates: https://github.com/389ds/389-ds-base/issues/7919
+
+Reviewed by: @tbordaz, @mreynolds389 (Thanks!!)
+
+(cherry picked from commit cb5e57766016020253c02de95e44189b89e09d79)
+---
+ dirsrvtests/tests/suites/security/dos_test.py | 20 +++---
+ ldap/servers/slapd/connection.c | 62 ++++++++++++++++---
+ ldap/servers/slapd/conntable.c | 6 ++
+ ldap/servers/slapd/result.c | 8 +++
+ ldap/servers/slapd/slap.h | 4 ++
+ 5 files changed, 84 insertions(+), 16 deletions(-)
+
+diff --git a/dirsrvtests/tests/suites/security/dos_test.py b/dirsrvtests/tests/suites/security/dos_test.py
+index ea240bf6e..07fda6256 100644
+--- a/dirsrvtests/tests/suites/security/dos_test.py
++++ b/dirsrvtests/tests/suites/security/dos_test.py
+@@ -92,13 +92,15 @@ def test_dos_partial_message(topology_st):
+ 2. Send a complete Anonymous Bind request followed by a partial second message.
+ 3. Wait for the error log to confirm the second (partial) message was buffered/queued.
+ 4. Verify that the Bind response for the first message is received promptly.
+- 5. Verify that other connections can still be established and used.
++ 5. Complete the second Bind request and receive its response.
++ 6. Verify that other connections can still be established and used.
+ :expectedresults:
+ 1. Connection established.
+ 2. Data sent.
+ 3. The server logs that it queued the connection due to buffered data.
+ 4. Bind response received well within ioblocktimeout.
+- 5. Server remains responsive.
++ 5. The second Bind succeeds.
++ 6. Server remains responsive.
+ """
+ inst = topology_st.standalone
+ original_loglevel = inst.config.get_attr_val_utf8("nsslapd-errorlog-level")
+@@ -138,18 +140,18 @@ def test_dos_partial_message(topology_st):
+ start = time.monotonic()
+ log.info("Waiting for bind response...")
+ try:
+- data = s.recv(1024)
++ msgid, tag, payload = _recv_ldap_message(s)
+ except socket.timeout:
+ pytest.fail("Timed out waiting for bind response. The server might be deadlocked.")
+ elapsed = time.monotonic() - start
+ log.info(f"Bind response received after {elapsed:.2f}s")
+- log.debug(f"Received data: {data.hex()}")
++ log.debug(f"Received Bind response payload: {payload.hex()}")
+
+ # Bind response for MsgID=1: 30 0c 02 01 01 61 07 0a 01 00 04 00 04 00
+- assert b'\x02\x01\x01\x61' in data
++ assert (msgid, tag) == (1, 0x61)
++ assert payload.startswith(b"\x0a\x01\x00")
+ # The real regression signature is the response taking close to the
+- # full ioblocktimeout (because a second worker held c_mutex while
+- # blocked reading the fragment). A healthy server replies almost
++ # full ioblocktimeout. A healthy server replies almost
+ # immediately, so a generous fraction of the timeout still leaves
+ # plenty of margin above normal scheduling noise.
+ assert elapsed < (test_ioblocktimeout_ms / 1000.0) / 2, (
+@@ -157,6 +159,10 @@ def test_dos_partial_message(topology_st):
+ f"behind the partial second LDAP message"
+ )
+ log.info("Successfully received a prompt bind response for the first operation")
++ s.sendall(bind_req[5:])
++ msgid, tag, payload = _recv_ldap_message(s)
++ assert (msgid, tag) == (2, 0x61)
++ assert payload.startswith(b"\x0a\x01\x00")
+ finally:
+ if s is not None:
+ s.close()
+diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
+index fdd3b32b8..2cc68a58d 100644
+--- a/ldap/servers/slapd/connection.c
++++ b/ldap/servers/slapd/connection.c
+@@ -159,6 +159,9 @@ connection_done(Connection *conn)
+ if (NULL != conn->c_sb) {
+ ber_sockbuf_free(conn->c_sb);
+ }
++ if (NULL != conn->c_pdu_writer_cv) {
++ PR_DestroyCondVar(conn->c_pdu_writer_cv);
++ }
+ if (NULL != conn->c_pdumutex) {
+ PR_DestroyLock(conn->c_pdumutex);
+ }
+@@ -191,6 +194,7 @@ connection_cleanup(Connection *conn)
+ * Sockbuf *c_sb;
+ * pthread_mutex_t c_mutex;
+ * PRLock *c_pdumutex;
++ * PRCondVar *c_pdu_writer_cv;
+ * Conn_private *c_private;
+ */
+ if (conn->c_prfd) {
+@@ -1488,6 +1492,37 @@ connection_read_operation(Connection *conn, Operation *op, ber_tag_t *tag, int *
+ PR_Lock(conn->c_pdumutex);
+ pthread_mutex_unlock(&(conn->c_mutex));
+
++ /* Admit a pending result writer before polling again. */
++ if (slapi_atomic_load_32(&conn->c_pdu_writers_waiting, __ATOMIC_ACQUIRE) > 0) {
++ conn->c_pdu_handoff_pending = PR_TRUE;
++ while (conn->c_pdu_handoff_pending) {
++ if (PR_WaitCondVar(conn->c_pdu_writer_cv, PR_INTERVAL_NO_TIMEOUT) != PR_SUCCESS) {
++ err = PR_GetError();
++ syserr = PR_GetOSError();
++ conn->c_pdu_handoff_pending = PR_FALSE;
++ PR_Unlock(conn->c_pdumutex);
++ pthread_mutex_lock(&(conn->c_mutex));
++ slapi_log_err(SLAPI_LOG_ERR, "connection_read_operation",
++ "PDU writer wait for connection %" PRIu64 " failed: %d (%s)\n",
++ conn->c_connid, err, slapd_pr_strerror(err));
++ disconnect_server_nomutex(conn, conn->c_connid, -1, err, syserr);
++ ret = CONN_DONE;
++ goto done;
++ }
++ }
++ /* Recheck the connection after the writer has run. */
++ PR_Unlock(conn->c_pdumutex);
++ pthread_mutex_lock(&(conn->c_mutex));
++ if ((conn->c_sd == SLAPD_INVALID_SOCKET) ||
++ (conn->c_flags & CONN_FLAG_CLOSING)) {
++ ret = CONN_DONE;
++ goto done;
++ }
++ pr_pd.fd = (PRFileDesc *)conn->c_prfd;
++ PR_Lock(conn->c_pdumutex);
++ pthread_mutex_unlock(&(conn->c_mutex));
++ }
++
+ ret = PR_Poll(&pr_pd, 1, timeout);
+
+ /*
+@@ -1810,6 +1845,7 @@ connection_threadmain(void *arg)
+ while (1) {
+ int is_timedout = 0;
+ time_t curtime = 0;
++ bool read_handed_off = false;
+
+ if (op_shutdown) {
+ slapi_log_err(SLAPI_LOG_TRACE, "connection_threadmain",
+@@ -2071,6 +2107,7 @@ connection_threadmain(void *arg)
+ /* once the connection is readable, another thread may access conn,
+ * so need locking from here on */
+ signal_listner(conn->c_ct_list);
++ read_handed_off = true;
+ } else if (connection_is_start_tls(op)) {
+ /*
+ * The StartTLS PDU has already been read into op->o_ber, but there is more data
+@@ -2103,9 +2140,11 @@ connection_threadmain(void *arg)
+ }, NULL);
+ }
+ #endif /* ENABLE_EPOLL */
+- connection_activity(conn, maxthreads);
+- slapi_log_err(SLAPI_LOG_CONNS, "connection_threadmain", "conn %" PRIu64 " queued because more_data\n",
+- conn->c_connid);
++ if (connection_activity(conn, maxthreads) == 0) {
++ read_handed_off = true;
++ slapi_log_err(SLAPI_LOG_CONNS, "connection_threadmain", "conn %" PRIu64 " queued because more_data\n",
++ conn->c_connid);
++ }
+ } else {
+ /* keep count of how many times maxthreads has blocked an operation */
+ conn->c_maxthreadsblocked++;
+@@ -2198,6 +2237,9 @@ connection_threadmain(void *arg)
+ PR_AtomicIncrement(&conn->c_opscompleted);
+ /* total number of ops for the server */
+ slapi_counter_increment(g_get_per_thread_snmp_vars()->server_tbl.dsOpCompleted);
++ if (read_handed_off) {
++ more_data = 0;
++ }
+ /* If this op isn't a persistent search, remove it */
+ if (op->o_flags & OP_FLAG_PS) {
+ /* Release the connection (i.e. decrease refcnt) at the condition
+@@ -2231,12 +2273,14 @@ connection_threadmain(void *arg)
+ "repl_conn_bef %d, repl_conn_now %d\n",
+ conn->c_connid, more_data, thread_turbo_flag,
+ replication_connection, conn->c_isreplication_session);
+- if (!replication_connection && conn->c_isreplication_session) {
+- /* it a connection that was just flagged as replication connection */
+- more_data = 0;
+- } else {
+- /* normal connection or already established replication connection */
+- more_data = conn_buffered_data_avail_nolock(conn, &conn_closed) ? 1 : 0;
++ if (!read_handed_off) {
++ if (!replication_connection && conn->c_isreplication_session) {
++ /* it a connection that was just flagged as replication connection */
++ more_data = 0;
++ } else {
++ /* normal connection or already established replication connection */
++ more_data = conn_buffered_data_avail_nolock(conn, &conn_closed) ? 1 : 0;
++ }
+ }
+ if (!more_data) {
+ if (!thread_turbo_flag) {
+diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
+index d5de91e40..37c3c6bb4 100644
+--- a/ldap/servers/slapd/conntable.c
++++ b/ldap/servers/slapd/conntable.c
+@@ -212,11 +212,17 @@ connection_table_new(int table_size)
+ exit(1);
+ }
+
++
+ ct->c[ct_list][i].c_pdumutex = PR_NewLock();
+ if (ct->c[ct_list][i].c_pdumutex == NULL) {
+ slapi_log_err(SLAPI_LOG_ERR, "connection_table_new", "PR_NewLock failed\n");
+ exit(1);
+ }
++ ct->c[ct_list][i].c_pdu_writer_cv = PR_NewCondVar(ct->c[ct_list][i].c_pdumutex);
++ if (ct->c[ct_list][i].c_pdu_writer_cv == NULL) {
++ slapi_log_err(SLAPI_LOG_ERR, "connection_table_new", "PR_NewCondVar failed for connection PDU writer\n");
++ exit(1);
++ }
+
+ /* Ready to rock, mark as such. */
+ ct->c[ct_list][i].c_state = CONN_STATE_INIT;
+diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
+index e3a13dbd8..370c533ef 100644
+--- a/ldap/servers/slapd/result.c
++++ b/ldap/servers/slapd/result.c
+@@ -1925,7 +1925,15 @@ flush_ber(
+ ber_get_option(ber, LBER_OPT_BYTES_TO_WRITE, &bytes);
+
+ fgot_start(op, FGOT_WRITE);
++ /* After publishing intent, this path must reach admission or resolve
++ * a reader's pending handoff before it can exit. */
++ slapi_atomic_incr_32(&conn->c_pdu_writers_waiting, __ATOMIC_ACQ_REL);
+ PR_Lock(conn->c_pdumutex);
++ slapi_atomic_decr_32(&conn->c_pdu_writers_waiting, __ATOMIC_ACQ_REL);
++ if (conn->c_pdu_handoff_pending) {
++ conn->c_pdu_handoff_pending = PR_FALSE;
++ PR_NotifyCondVar(conn->c_pdu_writer_cv);
++ }
+ rc = ber_flush(conn->c_sb, ber, 1);
+ PR_Unlock(conn->c_pdumutex);
+ fgot_end(op, FGOT_WRITE);
+diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
+index 59e3e334f..6af9de4eb 100644
+--- a/ldap/servers/slapd/slap.h
++++ b/ldap/servers/slapd/slap.h
+@@ -81,6 +81,7 @@ static char ptokPBE[34] = "Internal (Software) Token ";
+ #define LITTLE_ENDIAN __LITTLE_ENDIAN
+ #endif
+ #include <cert.h>
++#include <prcvar.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/statvfs.h>
+@@ -1749,6 +1750,9 @@ typedef struct conn
+ int c_refcnt; /* # ops refering to this conn */
+ pthread_mutex_t c_mutex; /* protect each conn structure; need to be re-entrant */
+ PRLock *c_pdumutex; /* only write one pdu at a time */
++ PRCondVar *c_pdu_writer_cv; /* hand the PDU lock to a waiting writer */
++ int32_t c_pdu_writers_waiting; /* atomic writer intent count */
++ PRBool c_pdu_handoff_pending; /* reader awaits a writer admission; protected by c_pdumutex */
+ time_t c_idlesince; /* last time of activity on conn */
+ int c_idletimeout; /* local copy of idletimeout */
+ int c_idletimeout_handle; /* the resource limits handle */
+--
+2.56.1
+
diff --git a/389-ds-base.spec b/389-ds-base.spec
index d53a7c3..35bffba 100644
--- a/389-ds-base.spec
+++ b/389-ds-base.spec
@@ -459,6 +459,16 @@ Source4: https://fedorapeople.org/groups/389ds/libdb-5.3.28-59.tar.bz2
#Source8: cockpit_dist-%%{version}-1.tar.bz2
Patch: 0001-Issue-7567-Content-Sync-plugin-unbounded-queue-growt.patch
+Patch: 0002-Security-fix-for-CVE-2026-115422.patch
+Patch: 0003-Security-fix-for-CVE-2026-115422.patch
+Patch: 0004-Security-fix-for-CVE-2026-118472.patch
+Patch: 0005-Security-fix-for-CVE-2026-118469.patch
+Patch: 0006-Security-fix-for-CVE-2026-118474.patch
+Patch: 0007-Issue-NNNN-Only-load-plugins-from-cn-plugins-cn-conf.patch
+Patch: 0008-Security-fix-for-CVE-2026-119584.patch
+Patch: 0009-Issue-7921-Fix-StartTLS-plaintext-buffer-handling-79.patch
+Patch: 0010-Issue-7919-CVE-2026-86344-Fix-worker-pool-exhaustion.patch
+Patch: 0011-Issue-7919-Coordinate-PDU-writer-handoff-and-buffere.patch
%description
389 Directory Server is an LDAPv3 compliant server. The base package includes
reply other threads:[~2026-12-01 12:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179612875301.1.4703083470783403505.rpms-389-ds-base-8c5dd3958c7a@fedoraproject.org \
--to=vashirov@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox