Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
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.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2025-62215-POC | Kitploit
Tools/GitHubGitHub/gowonisgood/cve-2025-62215-poc
Vulnerability AnalysisExploitationCTFLearning & EducationBinary Exploitation
GitHubgowonisgood/cve-2025-62215-poc

CVE-2025-62215-POC

View Repository
1013 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2025-62215 — Windows Token UAF (SepTokenSidSharingEnabled Race Condition)

This repository is for educational and research purposes only.

Overview

A Use-After-Free vulnerability PoC that occurs in the SepTokenSidSharingEnabled optimization path of the Windows kernel.

  • When NtDuplicateToken increments the SID Values Block RefCount from 1→2, a racing kernel thread frees the block via ExFreePoolWithTag.
  • Subsequently, SepDereferenceSidValuesBlock accesses the freed block → UAF / Double Free.
root@kitploit:~
[User]  IOCTL_REPLACE_SID_BLOCK  →  Place an independent block (RefCount=1) at TOKEN+0x468
[User]  IOCTL_TRIGGER_FREE       →  Spawn kernel thread (poll until RefCount==2)
[User]  NtDuplicateToken         →  Internally increments RefCount 1→2
[Kernel Thread] RefCount==2 detected → ExFreePoolWithTag(pBlock)  ← UAF point

File Structure

PathDescription
exploit/exploitWithDriv/exploitWithDriv.cppUser-mode exploit (console app)
tokendriv/tokendrv/tokendrv/tokendrv.cppKernel driver (provides IOCTL interface)

Build Instructions (Visual Studio)

Prerequisites

  • Visual Studio 2022 (MSVC)
  • Windows Driver Kit (WDK) — required for tokendriv build
  • SDK 10.0.26100.x or later

1. tokendriv.sys — Kernel Driver

  1. Open tokendriv/tokendrv/tokendrv.slnx
  2. Configuration: Release / x64
  3. Build → generates tokendriv/tokendrv/x64/Release/tokendrv.sys
  4. Standalone deployment: copy only the .sys file to the VM

After installing WDK, verify: Project Properties → Driver Settings → Target OS Version

2. exploitWithDriv.exe — User-mode Exploit

  1. Open exploit/exploitWithDriv.slnx
  2. Configuration: Release / x64
  3. Project Properties → Linker → System → SubSystem: Console
  4. Build → generates exploit/x64/Release/exploitWithDriv.exe
  5. For standalone deployment (no Visual C++ Redistributable required):
    • C/C++ → Code Generation → Runtime Library: Multi-threaded (/MT)

Running on VM

Prerequisites

  • VM RAM: 2 GB or less (required to activate SepTokenSidSharingEnabled)
  • Test account: test / 1234 (local account, no admin rights required)
  • Kernel Debugging connection (optional, needed for analysis)
  • Administrator cmd

Load the Driver

root@kitploit:~
sc create tokendriv type= kernel binpath= "C:\path\to\tokendrv.sys"
sc start tokendriv

Verify the driver is running:

root@kitploit:~
sc query tokendriv

Status should be RUNNING.

Run the Exploit

root@kitploit:~
exploitWithDriv.exe

Execution flow:

  1. Check FullNumberOfPhysicalPages (must be ≤ 0x83400)
  2. LogonUser("test", ".", "1234") → acquire hSource
  3. Press Enter to start the race loop (100,000 iterations)
  4. Each iteration: REPLACE → TRIGGER → NtDuplicateToken → Sleep(1)

Race Condition Analysis (WinDbg KD)

1. Get the Target Process Address

root@kitploit:~
0: kd> !process 0 0 exploitWithDriv.exe

Example output:

root@kitploit:~
PROCESS ffffa88f5e61e080
    SessionId: 1  Cid: 1234    Peb: ...  ParentCid: ...
    Image: exploitWithDriv.exe

ffffa88f5e61e080 is the EPROCESS address.

2. Set Breakpoints

The addresses below may vary per environment — confirm with actual kernel symbols.

A. SID Block RefCount increment (race window start)

root@kitploit:~
0: kd> bp fffff800`725c6114 ".if (@$proc == 0xffffa88f5e61e080) { .echo A_REFCNT_INCR; dq poi(@rsi+0x468)+8 L1; gc } .else { gc }"
  • Prints the RefCount (+0x8) of the SID Values Block at TOKEN+0x468
  • The moment the value changes 1 → 2 is the race window

B. UAF Read point

root@kitploit:~
0: kd> bp fffff800`726f51fb ".if (@$proc == 0xffffa88f5e61e080) { .echo REAL_UAF_READ; r rax,rdx; gc } .else { gc }"
  • Point where the freed block is read
  • Check rax, rdx values

C. UAF Write point

root@kitploit:~
0: kd> bp fffff800`726f5208 ".if (@$proc == 0xffffa88f5e61e080) { .echo REAL_UAF_WRITE; r rcx,rdx,rax; gc } .else { gc }"
  • Point where the freed block is written
  • Check rcx, rdx, rax for corruption

3. Race Timing Flow

root@kitploit:~
NtDuplicateToken entry
    └─ SeTokenCanImpersonate
        └─ SID Block RefCount: 1 → 2        ← bp A (A_REFCNT_INCR)
                                              ← kernel thread: ExFreePoolWithTag(pBlock)
    └─ SepDereferenceSidValuesBlock
        └─ dereference pBlock (read)         ← bp B (REAL_UAF_READ)
        └─ dereference pBlock (write)        ← bp C (REAL_UAF_WRITE)

4. Analysis Tips

  • If RefCount is 2 immediately after A_REFCNT_INCR is printed, the race window was entered successfully
  • If REAL_UAF_READ / REAL_UAF_WRITE appear, actual UAF is confirmed
  • Track blocks allocated with pool tag 'kcoB': !pool <addr> or !poolused

Key Offsets (Windows 11 24H2)


Unload the Driver

root@kitploit:~
sc stop tokendriv
sc delete tokendriv


CVE-2025-62215 — Windows Token UAF (SepTokenSidSharingEnabled 레이스 컨디션)

개요

Windows 커널의 SepTokenSidSharingEnabled 최적화 경로에서 발생하는 Use-After-Free 취약점 PoC.

  • NtDuplicateToken 내부에서 SID Values Block의 RefCount가 1→2로 증가하는 순간, 레이스를 걸어 커널 스레드가 해당 블록을 ExFreePoolWithTag로 해제한다.
  • 이후 SepDereferenceSidValuesBlock이 해제된 블록에 다시 접근 → UAF / Double Free.
root@kitploit:~
[User]  IOCTL_REPLACE_SID_BLOCK  →  TOKEN+0x468 에 RefCount=1 독립 블록 배치
[User]  IOCTL_TRIGGER_FREE       →  커널 스레드 시작 (RefCount==2 폴링 대기)
[User]  NtDuplicateToken         →  내부에서 RefCount 1→2
[Kernel Thread] RefCount==2 감지 → ExFreePoolWithTag(pBlock)  ← UAF 지점

구성 파일

경로설명
exploit/exploitWithDriv/exploitWithDriv.cpp유저모드 익스플로잇 (콘솔 앱)
tokendriv/tokendrv/tokendrv/tokendrv.cpp커널 드라이버 (IOCTL 인터페이스 제공)

빌드 방법 (Visual Studio)

공통 사전 조건

  • Visual Studio 2022 (MSVC)
  • Windows Driver Kit (WDK) — tokendriv 빌드 시 필요
  • SDK 10.0.26100.x 이상

1. tokendriv.sys — 커널 드라이버

  1. tokendriv/tokendrv/tokendrv.slnx 열기
  2. 구성: Release / x64
  3. 빌드 → tokendriv/tokendrv/x64/Release/tokendrv.sys 생성
  4. 독립 실행 배포: .sys 파일 하나만 VM으로 복사하면 됨

WDK 설치 후 프로젝트 속성 → Driver Settings → Target OS Version 확인

2. exploitWithDriv.exe — 유저모드 익스플로잇

  1. exploit/exploitWithDriv.slnx 열기
  2. 구성: Release / x64
  3. 프로젝트 속성 → Linker → System → SubSystem: Console
  4. 빌드 → exploit/x64/Release/exploitWithDriv.exe 생성
  5. 독립 실행 배포: Visual C++ Redistributable 없이 동작하도록
    • C/C++ → Code Generation → Runtime Library: Multi-threaded (/MT) 으로 설정

VM 실행 방법

사전 조건

  • VM RAM: 2 GB 이하 (SepTokenSidSharingEnabled 활성화 조건)
  • 테스트 계정: test / 1234 (로컬 계정, 관리자 권한 불필요)
  • Kernel Debugging 연결 (선택, 분석 시 필요)
  • 관리자 권한 cmd

드라이버 로드

root@kitploit:~
sc create tokendriv type= kernel binpath= "C:\path\to\tokendrv.sys"
sc start tokendriv

드라이버 로드 확인:

root@kitploit:~
sc query tokendriv

RUNNING 상태이면 정상.

익스플로잇 실행

root@kitploit:~
exploitWithDriv.exe

실행 흐름:

  1. FullNumberOfPhysicalPages 체크 (0x83400 이하여야 진행)
  2. LogonUser("test", ".", "1234") → hSource 획득
  3. Enter 입력 시 레이스 루프 100,000회 시작
  4. 각 이터레이션: REPLACE → TRIGGER → NtDuplicateToken → Sleep(1)

Race Condition 분석 (WinDbg KD)

1. 분석 대상 프로세스 주소 확인

root@kitploit:~
0: kd> !process 0 0 exploitWithDriv.exe

출력 예시:

root@kitploit:~
PROCESS ffffa88f5e61e080
    SessionId: 1  Cid: 1234    Peb: ...  ParentCid: ...
    Image: exploitWithDriv.exe

ffffa88f5e61e080 부분이 EPROCESS 주소.

2. 브레이크포인트 설정

아래 주소는 환경마다 다를 수 있으므로 실제 커널 심볼로 확인 후 사용.

A. SID Block RefCount 증가 지점 (레이스 윈도우 시작)

root@kitploit:~
0: kd> bp fffff800`725c6114 ".if (@$proc == 0xffffa88f5e61e080) { .echo A_REFCNT_INCR; dq poi(@rsi+0x468)+8 L1; gc } .else { gc }"
  • TOKEN+0x468 에 있는 SID Values Block의 RefCount(+0x8)를 출력
  • 값이 1 → 2로 바뀌는 순간이 레이스 윈도우

B. UAF Read 지점

root@kitploit:~
0: kd> bp fffff800`726f51fb ".if (@$proc == 0xffffa88f5e61e080) { .echo REAL_UAF_READ; r rax,rdx; gc } .else { gc }"
  • 해제된 블록을 읽는 지점
  • rax, rdx 값 확인

C. UAF Write 지점

root@kitploit:~
0: kd> bp fffff800`726f5208 ".if (@$proc == 0xffffa88f5e61e080) { .echo REAL_UAF_WRITE; r rcx,rdx,rax; gc } .else { gc }"
  • 해제된 블록에 쓰는 지점
  • rcx, rdx, rax 값으로 오염 여부 확인

3. 레이스 타이밍 흐름

root@kitploit:~
NtDuplicateToken 진입
    └─ SeTokenCanImpersonate
        └─ SID Block RefCount: 1 → 2        ← bp A (A_REFCNT_INCR)
                                              ← 커널 스레드: ExFreePoolWithTag(pBlock)
    └─ SepDereferenceSidValuesBlock
        └─ pBlock 역참조 (읽기)              ← bp B (REAL_UAF_READ)
        └─ pBlock 역참조 (쓰기)              ← bp C (REAL_UAF_WRITE)

4. 분석 팁

  • A_REFCNT_INCR 출력 직후 RefCount가 2이면 레이스 윈도우 진입 성공
  • REAL_UAF_READ / REAL_UAF_WRITE 이 출력되면 실제 UAF 발생 확인
  • Pool tag 'kcoB' 로 할당된 블록 추적: !pool <addr> 또는 !poolused

주요 오프셋 (Windows 11 24H2 기준)


드라이버 제거

root@kitploit:~
sc stop tokendriv
sc delete tokendriv
Download Tool
StructureOffsetField
_TOKEN+0x468SepSidValues (SID Values Block pointer)
SID Values Block+0x000Length (ULONG)
SID Values Block+0x008ReferenceCount (LONGLONG)
구조체오프셋필드
_TOKEN+0x468SepSidValues (SID Values Block 포인터)
SID Values Block+0x000Length (ULONG)
SID Values Block+0x008ReferenceCount (LONGLONG)