-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[security] Directory.Delete(@"somepath", true) can be duped by a malicious process to descend other directories #27299
Comments
I think this is reliability not security issue - attacker has to already have IO access to abuse this. For future reference please follow https://github.com/dotnet/corefx/#reporting-security-issues-and-security-bugs for any potential security issues. |
@krwq: Windows Remote Desktop services thinks IO access is not equivalent: https://docs.microsoft.com/en-us/windows-server/remote/remote-desktop-services/welcome-to-rds [email protected] is indistinguishable from a black hole. |
I believe you need to add Thanks |
The handle relative APIs may make things more speedy, which is precisely why I use them for enumeration on Windows. They also help keep context if the parent directory structure gets modified, so that's a small bonus. I'm perfectly fine with switching to handle relative where possible if it makes things faster, but this doesn't make things atomic. You could just as easily modify a subsequent subdirectory before it's ever touched and we wouldn't be able to determine ultimate intent. I don't know the handle relative way to delete files on Windows off the top of my head (without using NtCreateFile, which presumably is not what DeleteFile does). |
Somebody adding another file while recursive destroy is running is not a successful exploit. Somebody tricking it into leaving the target tree altogether is. This can only be done with symbolic links. |
I meant adding another symbolic link. If you have a directory with You could also find ways to flip the original file path to a symbolic link as well. In any case, if you still feel that there is a real issue here please follow the given link: https://github.com/dotnet/corefx/#reporting-security-issues-and-security-bugs |
Triage: Seems to be answered above. If there is still security concern, please follow the process linked above. |
I have inspected the Windows and the Linux code and found both to be not armored against directory traversal switcheroo.
Exploit path:
In the Linux world, the system calls openat() and unlinkat() were added to deal with this specific situation. The shortest correct sequence of system calls would be as follows:
There are equivalent calls in the NT Native API to do this on Windows. I have been unable to find any way at all to do this win Win32 calls.
So you might think you can just document to not do this, but Powershell on Linux uses .NET Core and .NET Framework on Windows has exactly the same bug.
The text was updated successfully, but these errors were encountered: