Bug 16147 (CVE-2026-58221) - [SECURITY] CVE-2026-58221: authenticated LDAP access to internal LDB special DNs permits domain takeover
Summary: [SECURITY] CVE-2026-58221: authenticated LDAP access to internal LDB special ...
Status: RESOLVED FIXED
Alias: CVE-2026-58221
Product: Samba 4.1 and newer
Classification: Unclassified
Component: AD: LDB/DSDB/SAMDB (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Stefan Metzmacher
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks: 16039
  Show dependency treegraph
 
Reported: 2026-06-24 03:31 UTC by Douglas Bagnall
Modified: 2026-08-13 14:31 UTC (History)
4 users (show)

See Also:


Attachments
original report (12.49 KB, text/markdown)
2026-06-24 03:31 UTC, Douglas Bagnall
no flags Details
OpenAI proposed patch (3.70 KB, patch)
2026-06-24 03:45 UTC, Douglas Bagnall
no flags Details
another version of the report (8.43 KB, text/markdown)
2026-06-24 03:49 UTC, Douglas Bagnall
no flags Details
security-bug-16147-master-metze-01.patches.txt (2.63 KB, text/plain)
2026-06-24 16:26 UTC, Stefan Metzmacher
metze: ci-passed+
Details
CVE-2026-TODO-SPECIAL-DN-advisory-v1.txt (3.19 KB, text/plain)
2026-06-27 08:55 UTC, Stefan Metzmacher
no flags Details
security-bug-16147-master-metze-02.patches.txt (19.24 KB, text/plain)
2026-06-29 17:44 UTC, Stefan Metzmacher
vl: review+
metze: ci-passed+
Details
CVE-2026-TODO-SPECIAL-DN-advisory-v2.txt (3.22 KB, text/plain)
2026-06-29 17:45 UTC, Stefan Metzmacher
dbagnall: review+
Details
CVE-2026-58221 advisory v3 (same as v2, but with CVE number) (3.21 KB, text/plain)
2026-07-01 01:18 UTC, Douglas Bagnall
no flags Details
Patch for master with CVE numbers (19.45 KB, patch)
2026-07-01 02:42 UTC, Douglas Bagnall
metze: review+
Details
patch for 4.22 (9.15 KB, patch)
2026-07-01 03:00 UTC, Douglas Bagnall
no flags Details
patch for 4.22 + 4.23 v2 (9.74 KB, patch)
2026-07-01 03:11 UTC, Douglas Bagnall
metze: review+
Details
patch for v4.24 (19.45 KB, patch)
2026-07-01 03:12 UTC, Douglas Bagnall
metze: review+
Details
CVE-2026-58221 advisory v4 (same as v2, but with CVE number) (3.21 KB, text/plain)
2026-07-01 03:47 UTC, Douglas Bagnall
no flags Details
CVE-2026-58221 advisory v5 (same as v4, but with hints regarding dsdb_audit) (3.44 KB, text/plain)
2026-07-02 12:40 UTC, Stefan Metzmacher
dbagnall: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Douglas Bagnall 2026-06-24 03:31:59 UTC
Created attachment 19026 [details]
original report

OpenAI report:

Any authenticated Samba AD domain user can modify internal LDB special records
such as @MODULES and @PARTITION through LDAP. By replacing the DSDB module
chain with a valid stack that omits acl and aclread, a normal account can open
a new LDAP connection without directory ACL enforcement and add itself to
Domain Admins, Enterprise Admins, and Builtin Administrators. The exploit then
restores the normal module loader; the privileged group memberships persist.

This was validated against Samba 4.25.0pre1-GIT-2fc21d87fc8 and an out-of-the-
box Ubuntu 24.04 package install of Samba 4.19.5+dfsg-4ubuntu9.6. The proposed
fix rejects untrusted LDAP operations against internal special DNs at the
RootDSE/network trust boundary while preserving trusted internal DSDB access
and normal null-base RootDSE discovery. The report includes the specific
rootdse, ACL, module-loader, and partition-loader code paths that compose into
the takeover.
Comment 1 Douglas Bagnall 2026-06-24 03:45:17 UTC
Created attachment 19029 [details]
OpenAI proposed patch
Comment 2 Douglas Bagnall 2026-06-24 03:49:22 UTC
Created attachment 19030 [details]
another version of the report
Comment 3 Stefan Metzmacher 2026-06-24 16:26:04 UTC
Created attachment 19033 [details]
security-bug-16147-master-metze-01.patches.txt

This also fixes the problem for me
Comment 4 Volker Lendecke 2026-06-25 06:26:37 UTC
(In reply to Stefan Metzmacher from comment #3)
> Created attachment 19033 [details]
> security-bug-16147-master-metze-01.patches.txt
> 
> This also fixes the problem for me

Just a very minor nit-pick on the patch: ldb_dn_is_special() treats NULL as non-special, so the additional check is not necessary.
Comment 5 Stefan Metzmacher 2026-06-27 08:55:47 UTC
Created attachment 19038 [details]
CVE-2026-TODO-SPECIAL-DN-advisory-v1.txt
Comment 6 Stefan Metzmacher 2026-06-29 17:44:32 UTC
Created attachment 19053 [details]
security-bug-16147-master-metze-02.patches.txt
Comment 7 Stefan Metzmacher 2026-06-29 17:45:12 UTC
Created attachment 19054 [details]
CVE-2026-TODO-SPECIAL-DN-advisory-v2.txt
Comment 8 Douglas Bagnall 2026-07-01 01:18:06 UTC
Created attachment 19058 [details]
CVE-2026-58221 advisory v3 (same as v2, but with CVE number)
Comment 9 Douglas Bagnall 2026-07-01 02:42:22 UTC
Created attachment 19059 [details]
Patch for master with CVE numbers
Comment 10 Douglas Bagnall 2026-07-01 03:00:30 UTC
Created attachment 19060 [details]
patch for 4.22

For the 4.22, I have added the shared dsdb_audit_operation_human_readable() functions to audit_util.c, but not removed the static operation_human_readable()  from audit_log.c.

The master patch applies from 4.23.
Comment 11 Douglas Bagnall 2026-07-01 03:11:30 UTC
Created attachment 19061 [details]
patch for 4.22 + 4.23 v2
Comment 12 Douglas Bagnall 2026-07-01 03:12:05 UTC
Created attachment 19062 [details]
patch for v4.24
Comment 13 Douglas Bagnall 2026-07-01 03:44:19 UTC
(In reply to Douglas Bagnall from comment #10)
> The master patch applies from 4.23.

from 4.24.

4.23 and 4.22 are the same.
Comment 14 Douglas Bagnall 2026-07-01 03:47:16 UTC
Created attachment 19063 [details]
CVE-2026-58221 advisory v4 (same as v2, but with CVE number)
Comment 15 Stefan Metzmacher 2026-07-02 12:40:10 UTC
Created attachment 19071 [details]
CVE-2026-58221 advisory v5 (same as v4, but with hints regarding dsdb_audit)
Comment 16 Björn Jacke 2026-07-17 13:43:59 UTC
adding vendors here.

scheduled release 2026-07-28 10:00 UTC.
Comment 17 Samba QA Contact 2026-07-28 10:24:58 UTC
This bug was referenced in samba v4-23-stable (Release samba-4.23.10):

a0081c8117d2a8e394dfc4aacb918e4cfbde6d30
f0880127a6034eeaceda23c9452e22726bc61713
Comment 18 Samba QA Contact 2026-07-28 10:26:05 UTC
This bug was referenced in samba v4-24-stable (Release samba-4.24.5):

1b3a0a2e981d3a3c67b6bfb43561d7123584a193
75e3ded48f4bd0087abeb9d2403c6147097dfddc
Comment 19 Samba QA Contact 2026-07-28 10:26:29 UTC
This bug was referenced in samba v4-22-stable (Release samba-4.22.11):

ad876ce926a4aa57e22d5772cd8d9c31c63efec2
1b95d0c2b68b464afb66b883f6e07b3002a64346
Comment 20 Samba QA Contact 2026-07-28 10:50:09 UTC
This bug was referenced in samba v4-22-test:

ad876ce926a4aa57e22d5772cd8d9c31c63efec2
1b95d0c2b68b464afb66b883f6e07b3002a64346
Comment 21 Samba QA Contact 2026-07-28 12:15:53 UTC
This bug was referenced in samba v4-24-test:

ba8b65647603aff9c26d0d517af071119b7abab9
3661b112ab649c373d133727bb15066576a66ae6
Comment 22 Samba QA Contact 2026-07-28 12:27:44 UTC
This bug was referenced in samba v4-23-test:

62c456ff62b303edb6fb143d76dd6b4c1cca6b4a
96b7e948a80b5a7182c27705949e9e523cf85683
Comment 23 Samba QA Contact 2026-07-28 14:41:42 UTC
This bug was referenced in samba v4-24-test:

1b3a0a2e981d3a3c67b6bfb43561d7123584a193
75e3ded48f4bd0087abeb9d2403c6147097dfddc
Comment 24 Samba QA Contact 2026-07-28 14:44:26 UTC
This bug was referenced in samba v4-23-test:

a0081c8117d2a8e394dfc4aacb918e4cfbde6d30
f0880127a6034eeaceda23c9452e22726bc61713
Comment 25 Samba QA Contact 2026-07-28 17:03:37 UTC
This bug was referenced in samba master:

ac1c8d6ad5747e69987dbec2307943efbbfdec5c
0973b2faa211dd3ccb4c4d86f0b8c62d36f68e9d
Comment 26 Samba QA Contact 2026-08-03 19:37:10 UTC
This bug was referenced in samba v4-23-stable (Release samba-4.23.11):

62c456ff62b303edb6fb143d76dd6b4c1cca6b4a
96b7e948a80b5a7182c27705949e9e523cf85683
Comment 27 Samba QA Contact 2026-08-13 14:31:29 UTC
This bug was referenced in samba v4-24-stable (Release samba-4.24.6):

ba8b65647603aff9c26d0d517af071119b7abab9
3661b112ab649c373d133727bb15066576a66ae6