Skip to content
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

Chocolatey CLI is incorrectly reporting bad permissions on the HttpCache folder and is not setting them correctly #3645

Open
6 tasks done
pauby opened this issue Mar 3, 2025 · 1 comment

Comments

@pauby
Copy link
Member

pauby commented Mar 3, 2025

Checklist

  • I confirm there are no unresolved issues reported on the Chocolatey Status page.
  • I have verified this is the correct repository for opening this issue.
  • I have verified no other issues exist related to my problem.
  • I have verified this is not an issue for a specific package.
  • I have verified this issue is not security related.
  • I confirm I am using official, and not unofficial, or modified, Chocolatey products.

What You Are Seeing?

When the permissions on the httpcache folder are changed, Chocolatey CLI shows the following validation warning:

System Cache directory is not locked down to administrators. Remove the directory 'C:\ProgramData\ChocolateyHttpCache' to have Chocolatey CLI create it with the proper permissions. 

When trying to resolve this warning, the user ran an Advanced Deployment Step in Chocolatey Central Management to remove the httpcache folder and have Chocolatey CLI recreate it. Chocolatey CLI creates the cache folder, with all local machine users having write access to the folder. This permission change causes the recreated httpcache folder to report the same issue of the folder not being locked down to just Administrator user access.

What is Expected?

Chocolatey should be able to recreate this folder with the correct permissions. Chocolatey should be setting the cache folder's ACL before every run of Chocolatey.

How Did You Get This To Happen?

  1. Install Chocolatey for Business and license it. Note the current permissions on C:\ProgamData\ChocolateyHttpCache folder.
  2. Go to the C:\ProgamData\ChocolateyHttpCache folder and edit the permissions to add LocalMachine\Users object to include Write access.
  3. Run choco list and the validation warning mentioned above, should be shown.
  4. Undo the folder permissions change done in Step 2.
  5. Run the following exported Chocolatey Central Management deployment against your test machine.
  6. You should notice that the C:\ProgamData\ChocolateyHttpCache folder has been re-created. However, Users now have Write access, and the CREATOR OWNER has Full Control rights. If you run choco list again, you get the same validation warning message.

System Details

  • Operating System: 20348.3091 (Windows Server 2022)
  • Windows PowerShell Version: 5.1.20348.2849
  • Chocolatey CLI Version: 2.4.2
  • Chocolatey Licensed Extension version: 6.3.1
  • Chocolatey Agent version: 2.2.2
  • Chocolatey License type (Professional / Business / ?): Business
  • Terminal/Emulator: Windows PowerShell & Chocolatey Central Management

Installed Packages

N/A

Output Log

[chocolatey.log](https://gist.github.com/ryanrichter94/1cf7cba454db54ec7d48664842e65012)

Additional Context

Adding the following to the PowerShell of the Advanced Deployment Step in the reproduction steps of this issue will programmatically recreate the cache folder, mirroring the ACLs from $env:ChocolateyInstall onto it.

if (Test-Path -Path "C:\ProgramData\ChocolateyHttpCache"){
	Write-Error "Chocolatey Cache directory still exists!"
} else { 
    Write-Output "Recreating Chocolatey Cache Directory"
    New-Item -Path "C:\ProgramData\" -Name "ChocolateyHttpCache" -ItemType "directory"

    Write-Output "Setting correct permissions for Chocolatey Cache Directory"
    $ChocolateyACL = Get-Acl -Path $env:ChocolateyInstall
    Set-Acl -Path "C:\ProgramData\ChocolateyHttpCache" -AclObject $ChocolateyAcl
}
@AdmiringWorm
Copy link
Member

Additional information. The cause of this is because we are locking down the Http Folder as part of running one of the Validations (CacheFolderValidationLockdown).

These validations are not run when the API is being used, which causes NuGet.Client itself to create the directory, which is then created with the incorrect permissions.

@pauby pauby changed the title Chocolaety CLI is incorrectly reporting bad permissions on the HttpCache folder and is not setting them correctly Chocolatey CLI is incorrectly reporting bad permissions on the HttpCache folder and is not setting them correctly Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants