-
Notifications
You must be signed in to change notification settings - Fork 257
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
Permissions on files created inside ~/.nuget are too open #7673
Comments
@gorazdzagar I can't reproduce this. Can you provide any more information? I created a brand new Ubuntu 16.04 LTS VM, then installed the dotnet CLI with the following instructions: https://dotnet.microsoft.com/download/linux-package-manager/ubuntu16-04/sdk-2.2.102. I ran
As you can see, NuGet restore is respecting umask on my machine. I also did a search though NuGet's source code, but I couldn't find any code that changed file flags/permissions or ACLs. |
Hi @zivkan, thank you for your reply. I'll provide a use case for it. We have umask 027 set in /etc/profile which applies to all users when shell is executed. What we are observing is files generated inside ~/.nuget/packages/ have world-write permission set where as they shouldn't. Could you please further test in your Ubuntu VM for package files not just the main folder. Thank you |
This issue should be fixed at the same time as #6778 and is related to #4424. The reason I couldn't find any code related to permissions earlier is because the fix doesn't use .NET APIs, it uses P/Invoke to run I don't sufficiently understand #4424, so I fear making any changes in case I regress the earlier bug. The team should discuss this. |
I thank you for acknowledging this as a bug. If it helps further, here are the steps to reproduce:
1.) files should not have +x permission This is a severe security risk as anyone can change the content of an executable file. If root executes a file without prior knowledge of its content, this could be exploitable. |
Today we released a fix for all affects products (nuget.exe, dotnet cli/sdk, VS for Mac, Mono): https://portal.msrc.microsoft.com/en-us/security-guidance/advisory/CVE-2019-0757 The fixed binaries do not change permissions of existing files on disk, so you should either delete the files and restore again, or fix the permissions yourself. But the updated binaries will now respect umask when creating new files. @gorazdzagar thank you for helping us make a better product! |
@gorazdzagar - thanks very much for bringing this to our attention. |
Hello, would it be possible to reference the fixing commit? Are older versions of nuget affected too (< 4.x)? |
Here's the commit. NuGet only started modifying extracted file permissions because .NET Core 1.x would create (all) files with the u+x bit set, but .NET Core 2.x stopped, and some people were shipping tools (such as build tools, but now .NET global tools are also relevant) that needed the execute bit set, so NuGet started setting the execute bit from NuGet 4.3. For this reason, NuGet older than 4.3 is not affected, but also does not set the execute bit on extracted files. |
Thank you for the clarification. Debian is still shipping an old version of NuGet and I couldn't reproduce the problem. That makes sense now. |
Details about Problem
NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe):
NuGet version (x.x.x.xxx):
dotnet.exe --version (if appropriate): 2.1.301
VS version (if appropriate):
OS version (i.e. win10 v1607 (14393.321)): Ubuntu 16.04
Worked before? If so, with which NuGet version:
Detailed repro steps so we can see the same problem
Files generated in ~/.nuget folder have world-wide writable permissions. Seems like umask set on a user executing the command is not respected. Any file created inside ~/.nuget should have permissions more restrictive.
The text was updated successfully, but these errors were encountered: