|
| 1 | +# SeManageVolumePrivilege: Raw volume access for arbitrary file read |
| 2 | + |
| 3 | +{{#include ../../banners/hacktricks-training.md}} |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Windows user right: Perform volume maintenance tasks (constant: SeManageVolumePrivilege). |
| 8 | + |
| 9 | +Holders can perform low-level volume operations such as defragmentation, creating/removing volumes, and maintenance IO. Critically for attackers, this right allows opening raw volume device handles (e.g., \\.\C:) and issuing direct disk I/O that bypasses NTFS file ACLs. With raw access you can copy bytes of any file on the volume even if denied by DACL, by parsing the filesystem structures offline or leveraging tools that read at the block/cluster level. |
| 10 | + |
| 11 | +Default: Administrators on servers and domain controllers. |
| 12 | + |
| 13 | +## Abuse scenarios |
| 14 | + |
| 15 | +- Arbitrary file read bypassing ACLs by reading the disk device (e.g., exfiltrate sensitive system-protected material such as machine private keys under %ProgramData%\Microsoft\Crypto\RSA\MachineKeys and %ProgramData%\Microsoft\Crypto\Keys, registry hives, DPAPI masterkeys, SAM, ntds.dit via VSS, etc.). |
| 16 | +- Bypass locked/privileged paths (C:\Windows\System32\…) by copying bytes directly from the raw device. |
| 17 | +- In AD CS environments, exfiltrate the CA’s key material (machine key store) to mint “Golden Certificates” and impersonate any domain principal via PKINIT. See link below. |
| 18 | + |
| 19 | +Note: You still need a parser for NTFS structures unless you rely on helper tools. Many off-the-shelf tools abstract the raw access. |
| 20 | + |
| 21 | +## Practical techniques |
| 22 | + |
| 23 | +- Open a raw volume handle and read clusters: |
| 24 | + |
| 25 | +<details> |
| 26 | +<summary>Click to expand</summary> |
| 27 | + |
| 28 | +```powershell |
| 29 | +# PowerShell – read first MB from C: raw device (requires SeManageVolumePrivilege) |
| 30 | +$fs = [System.IO.File]::Open("\\.\\C:",[System.IO.FileMode]::Open,[System.IO.FileAccess]::Read,[System.IO.FileShare]::ReadWrite) |
| 31 | +$buf = New-Object byte[] (1MB) |
| 32 | +$null = $fs.Read($buf,0,$buf.Length) |
| 33 | +$fs.Close() |
| 34 | +[IO.File]::WriteAllBytes("C:\\temp\\c_first_mb.bin", $buf) |
| 35 | +``` |
| 36 | + |
| 37 | +```csharp |
| 38 | +// C# (compile with Add-Type) – read an arbitrary offset of \\.\nusing System; |
| 39 | +using System.IO; |
| 40 | +class R { |
| 41 | + static void Main(string[] a){ |
| 42 | + using(var fs = new FileStream("\\\\.\\C:", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)){ |
| 43 | + fs.Position = 0x100000; // seek |
| 44 | + var buf = new byte[4096]; |
| 45 | + fs.Read(buf,0,buf.Length); |
| 46 | + File.WriteAllBytes("C:\\temp\\blk.bin", buf); |
| 47 | + } |
| 48 | + } |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +</details> |
| 53 | + |
| 54 | +- Use an NTFS-aware tool to recover specific files from raw volume: |
| 55 | + - RawCopy/RawCopy64 (sector-level copy of in-use files) |
| 56 | + - FTK Imager or The Sleuth Kit (read-only imaging, then carve files) |
| 57 | + - vssadmin/diskshadow + shadow copy, then copy target file from the snapshot (if you can create VSS; often requires admin but commonly available to the same operators that hold SeManageVolumePrivilege) |
| 58 | + |
| 59 | +Typical sensitive paths to target: |
| 60 | +- %ProgramData%\Microsoft\Crypto\RSA\MachineKeys\ |
| 61 | +- %ProgramData%\Microsoft\Crypto\Keys\ |
| 62 | +- C:\Windows\System32\config\SAM, SYSTEM, SECURITY (local secrets) |
| 63 | +- C:\Windows\NTDS\ntds.dit (domain controllers – via shadow copy) |
| 64 | +- C:\Windows\System32\CertSrv\CertEnroll\ (CA certs/CRLs; private keys live in the machine key store above) |
| 65 | + |
| 66 | +## AD CS tie‑in: Forging a Golden Certificate |
| 67 | + |
| 68 | +If you can read the Enterprise CA’s private key from the machine key store, you can forge client‑auth certificates for arbitrary principals and authenticate via PKINIT/Schannel. This is often referred to as a Golden Certificate. See: |
| 69 | + |
| 70 | +{{#ref}} |
| 71 | +../active-directory-methodology/ad-certificates/domain-persistence.md |
| 72 | +{{#endref}} |
| 73 | + |
| 74 | +(Section: “Forging Certificates with Stolen CA Certificates (Golden Certificate) – DPERSIST1”). |
| 75 | + |
| 76 | +## Detection and hardening |
| 77 | + |
| 78 | +- Strongly limit assignment of SeManageVolumePrivilege (Perform volume maintenance tasks) to only trusted admins. |
| 79 | +- Monitor Sensitive Privilege Use and process handle opens to device objects like \\.\C:, \\.\PhysicalDrive0. |
| 80 | +- Prefer HSM/TPM-backed CA keys or DPAPI-NG so that raw file reads cannot recover key material in usable form. |
| 81 | +- Keep uploads, temp, and extraction paths non-executable and separated (web context defense that often pairs with this chain post‑exploitation). |
| 82 | + |
| 83 | +## References |
| 84 | + |
| 85 | +- Microsoft – Perform volume maintenance tasks (SeManageVolumePrivilege): https://learn.microsoft.com/previous-versions/windows/it-pro/windows-10/security/threat-protection/security-policy-settings/perform-volume-maintenance-tasks |
| 86 | +- 0xdf – HTB: Certificate (SeManageVolumePrivilege used to read CA key → Golden Certificate): https://0xdf.gitlab.io/2025/10/04/htb-certificate.html |
| 87 | + |
| 88 | +{{#include ../../banners/hacktricks-training.md}} |
0 commit comments