WSL icon indicating copy to clipboard operation
WSL copied to clipboard

dirtyfrag security error in kernel (Like "Copy Fail")

Open RageGen opened this issue 6 months ago • 13 comments

Windows Version

Microsoft Windows [Version 10.0.26200.8246]

WSL Version

WSL version: 2.6.3.0

Are you using WSL 1 or WSL 2?

  • [x] WSL 2
  • [ ] WSL 1

Kernel Version

Kernel version: 6.6.87.2-1

Distro Version

Ubuntu 24.04, 26.04

Other Software

No response

Repro Steps

Security error, same as CVE-2026-31431

Allows you to get root access on a local machine. The error comes from an unpatched Kernel module's - xfrm-ESP and RxRPC.

The code is publicly available in projects:

  1. https://github.com/V4bel/dirtyfrag
  2. https://github.com/0xdeadbeefnetwork/Copy_Fail2-Electric_Boogaloo

Steps:

  1. Run ./run.sh from second repo.

Expected Behavior

Error and no root access (with a rebuilt kernel without an error module, the exploit produces the expected result - on a standard WSL kernel, no).

Image

Actual Behavior

I'm getting root access.

Image

Diagnostic Logs

No response

RageGen avatar May 08 '26 07:05 RageGen

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

Once completed please upload the output files to this GitHub issue.

See Collect WSL logs (recommended method).

If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

github-actions[bot] avatar May 08 '26 07:05 github-actions[bot]

/emailed-logs

RageGen avatar May 08 '26 12:05 RageGen

Diagnostic information
Found '/emailed-logs', adding tag 'emailed-logs'

github-actions[bot] avatar May 08 '26 12:05 github-actions[bot]

@chemwolf6922 Thank you for tag, bro!

RageGen avatar May 09 '26 04:05 RageGen

Adding this to the .wslconfig in Windows should help to mitigate the issues:

[wsl2]
kernelCommandLine=module_blacklist=esp4,esp6,rxrpc,algif_aead

Because blacklisting the modules via /etc/modprobe.d (as suggested for general Linux systems) did not mitigate the exploits for me inside WSL! Also if you ran the dirtyfrag exploit on your systems, you must make sure to fix the su binary as it is replaced. Preferrably never run these exploits in your actual production WSL instance, always use a fresh instance to test them and remove them afterwards! Under Ubuntu you can run sudo apt reinstall util-linux to reinstall the correct the su binary, for the people who ran this in their actual dev environments...

thendricks0 avatar May 11 '26 10:05 thendricks0

@thendricks0 Yes, thank you for the alternative solution, but as I mentioned above, I took a more radical approach by recompiling the entire kernel without the vulnerable module. However, your solution is more elegant as it does not require a complete recompilation of the kernel.

RageGen avatar May 11 '26 10:05 RageGen

Also if you ran the dirtyfrag exploit on your systems, you must make sure to fix the su binary as it is replaced.

The exploit "only" overwrite parts in the kernel page cache, but the actual su binary is never changed on disc.

You can clear the page cache by running echo 3 > /proc/sys/vm/drop_caches and you will see that su is back to normal operation next time you run it. So re-installing util-linux would be overkill...

But I agree, that running the exploit on a production machine is still a bad idea.

supervirus avatar May 11 '26 12:05 supervirus

@RageGen Hey, what kernel version did you rebuild against?

NovaViper avatar May 11 '26 12:05 NovaViper

@NovaViper I recompiled the latest kernel available from Microsoft following the instructions from our neighboring discussion thread — https://github.com/microsoft/WSL/issues/40365#issuecomment-4357455695

RageGen avatar May 11 '26 12:05 RageGen

Now i have:

ragegen@RageGen-PC:~$ uname -a
Linux RageGen-PC 6.6.123.2-microsoft-standard-WSL2+ #1 SMP PREEMPT_DYNAMIC Fri May  1 05:38:07 MSK 2026 x86_64 GNU/Linux

RageGen avatar May 11 '26 12:05 RageGen

👀 Isn't the patch only available on 6.6.138 and 6.18.128?

NovaViper avatar May 11 '26 13:05 NovaViper

@NovaViper You can rebuild any of the available official Microsoft kernels with the necessary flags, and the module will be disabled in whichever kernel version you need.

RageGen avatar May 11 '26 13:05 RageGen

Fixed in last version.

RageGen avatar Jun 10 '26 11:06 RageGen