Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

Zmsr

This repository contains a Proof of Concept (PoC) for a kernel-mode arbitrary code execution vulnerability in cpuz154_x64.sys using unvalidated rdmsr and wrmsr IOCTLs.

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

CVE-2025-51060 Proof of Concept (PoC)

This repository contains a Proof of Concept (PoC) for a kernel-mode arbitrary code execution vulnerability in cpuz154_x64.sys using unvalidated rdmsr and wrmsr IOCTLs.

Language

한국어

CVE-2025-51060 PoC 설명

cpuz154_x64.sys 드라이버에서 검증되지 않은 rdmsr 및 wrmsr IOCTL을 활용한 커널 모드 임의 코드 실행 PoC입니다.

동작 원리

  1. KiSystemCall64 주소 획득:
    • 검증되지 않은 rdmsr DeviceIoControl(0x9C402440)을 사용하여 KiSystemCall64 주소를 읽어옵니다.
    • rdmsr 없이도 KiSystemCall64 주소를 쿼리로 유추 가능합니다.
  2. KiSystemCall64 주소 변조:
    • 검증되지 않은 wrmsr DeviceIoControl(0x9C402444)을 사용하여 KiSystemCall64의 주소를 미리 찾아둔 pop rcx; ret; 가젯 주소로 덮어씌웁니다 (MSR_LSTAR에 기록).
  3. ROP 체인 구성:
    • syscall 호출 전, 스택에 특정 가젯을 순서대로 push하여 리턴 주소를 조작하고 필요한 opcode를 실행합니다.
    • 스택 푸시 순서:
      • SmepOffQuery
      • MovCr4RcxRetGadget
      • SyscallHandler (사용자 정의 함수 주소)
      • PopRcxRetGadget
      • Finish (syscall 호출 지점으로 복귀하기 위한 주소)
      • SysretGadget
  4. ROP 체인 실행 흐름:
    • KiSystemCall64: wrmsr로 변조된 pop rcx; ret; 가젯으로 시작.
    • pop rcx; ret: SmepOffQuery를 rcx에 로드하고 MovCr4RcxRetGadget으로 리턴.
    • SmepOff: rcx (SmepOffQuery) 값을 cr4에 기록하여 SMEP 비활성화, SyscallHandler로 리턴.
    • SyscallHandler: 사용자 정의 함수 호출, MSR_LSTAR 및 CR4를 원본 값으로 복구, PrepareSysret로 리턴.
    • PrepareSysret: Finish 주소를 rcx에 로드, GoFinish로 리턴.
    • GoFinish: sysret을 호출하여 rcx에 저장된 Finish 주소로 복귀.
    • Finish: ROP 체인 종료, popfq, pop, ret 실행.

English

CVE-2025-51060 PoC Description

This PoC demonstrates kernel-mode arbitrary code execution in cpuz154_x64.sys by exploiting unvalidated rdmsr and wrmsr IOCTLs.

How It Works

  1. Obtaining KiSystemCall64 Address:
    • Uses unvalidated rdmsr DeviceIoControl(0x9C402440) to read the KiSystemCall64 address.
    • The address can also be inferred via query without rdmsr.
  2. Overwriting KiSystemCall64 Address:
    • Uses unvalidated wrmsr DeviceIoControl(0x9C402444) to overwrite KiSystemCall64 with the address of a pop rcx; ret; gadget, written to MSR_LSTAR.
  3. ROP Chain Setup:
    • Before invoking syscall, specific gadgets are pushed onto the stack to manipulate return addresses and execute required opcodes.
    • Stack push order:
      • SmepOffQuery
      • MovCr4RcxRetGadget
      • SyscallHandler (user-defined function address)
      • PopRcxRetGadget
      • Finish (address to return to after syscall)
      • SysretGadget
  4. ROP Chain Execution Flow:
    • KiSystemCall64: Modified by wrmsr to point to pop rcx; ret; gadget, initiating the ROP chain via syscall.
    • pop rcx; ret: Loads SmepOffQuery into rcx and returns to MovCr4RcxRetGadget.
    • SmepOff: Writes rcx (SmepOffQuery) to cr4 to disable SMEP, returns to SyscallHandler.
    • SyscallHandler: Executes user-defined function, restores MSR_LSTAR and CR4 to original values, returns to PrepareSysret.
    • PrepareSysret: Loads Finish address into rcx, returns to GoFinish.
    • GoFinish: Executes sysret, returning to the Finish address stored in rcx.
    • Finish: Terminates ROP chain with popfq, pop, and ret.