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

Show remembered arguments for packages #1310

Closed
CWempe opened this issue May 24, 2017 · 19 comments · Fixed by #2619
Closed

Show remembered arguments for packages #1310

CWempe opened this issue May 24, 2017 · 19 comments · Fixed by #2619

Comments

@CWempe
Copy link

CWempe commented May 24, 2017

Like @ivanatpr posted here (#797), there should be a way to see wich arguments are remembered by choco.

@ferventcoder
Copy link
Member

Thanks for filing - we just need some way of having folks opt into this, some arguments could contain sensitive data and we need to ensure that is not exposed.

@CWempe
Copy link
Author

CWempe commented May 24, 2017

I understand.
Nobody wants their "-P mySecretPassword" to be exposed via a simple command. 😄

I am not sure how you can solve this.

Maybe a second "remember-function".

Like:

choco install app1 -x86 -rememberPlain
choco install app1 -P mySecretPassword -rememberEncrypt

And an option to define with function should be default.

@bcurran3
Copy link

bcurran3 commented Jan 8, 2018

An option to encrypt or not encrypt seems a reasonable solution to me.

choco feature enable -n useRememberedArgumentsForUpgrades (Default=not encrypted)
choco feature enable -n useRememberedArgumentsForUpgradesEncrypted

(That's already long to type!)

@jacktose
Copy link

jacktose commented Feb 8, 2018

This would be necessary to do something like this, to exactly replicate a chocolatey setup from one profile/computer to another.

@bcurran3
Copy link

bcurran3 commented Feb 8, 2018

@jacktose - you could copy and paste that or save a lot of time and effort by using my package for that purpose :)
https://chocolatey.org/packages/choco-package-list-backup

(Which is why I have interest in this issue.)

@stippingerm
Copy link

Has this issue been solved? I have useRememberedArgumentsForUpgrades turned on with no effect on export.

some arguments could contain sensitive data

@ferventcoder I don't see no direct security concerns for hindering the export of remembered arguments.
Either these arguments are stored in a cryptographically secure way (thus preventing any unauthorized user from properly upgrading packages) or this information is already exposed to all users.

@heldchen
Copy link

heldchen commented Nov 14, 2018

I also would appreciate the ability to show the arguments throug choco.

the security concerns raised in this issues are kind of moot when NugetEncryptionUtility uses the machine key for encrypting the arguments. anyone on the local computer who can read C:\ProgramData\chocolatey\.chocolatey\foo\.arguments (in a default installation this is everyone in the Users group) can also fully decrypt it.

using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;

namespace ChocoDecrypt
{
    public class Program
    {
        private static readonly byte[] _entropyBytes = Encoding.UTF8.GetBytes("Chocolatey");
        
        public static void Main(string[] args)
        {
            var encryptedByteArray = Convert.FromBase64String(File.ReadAllText(args[0]));
            var decryptedByteArray = ProtectedData.Unprotect(encryptedByteArray, _entropyBytes, DataProtectionScope.LocalMachine);

            Console.WriteLine(Encoding.UTF8.GetString(decryptedByteArray));
        }
    }
}
D:\>C:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /nologo ChocoDecrypt.cs

D:\>ChocoDecrypt.exe C:\ProgramData\chocolatey\.chocolatey\git.2.19.0\.arguments
 --package-parameters="'/GitOnlyOnPath /NoAutoCrLf /NoShellIntegration /NoGitLfs'" --cache-location="'C:\Users\Heldchen\AppData\Local\Temp\chocolatey'" --use-system-powershell

@stippingerm
Copy link

stippingerm commented Nov 15, 2018

@heldchen Thank you for the valuable input. Me too, would appreciate the ability to show the arguments through choco. Here, I confirm your method works.

@ferventcoder the way to opt in with useRememberedArgumentsForUpgrades looks nice to me. Its default is False, so everything OK.

Conclusion (edited): administrators should be aware that in the current open source version the encryption does not protect their remembered installation secrets therefore they should set up access control to prevents users from reading them.

See bcurran3/ChocolateyPackages#7 too.

@ferventcoder
Copy link
Member

ferventcoder commented Nov 16, 2018

@stippingerm @heldchen That ability to unencrypt knowing a few bits is exactly why we're adding double encryption in C4B so that someone would not be able to decrypt the data at rest. It's less of a concern to do so when it's a person's personal computer. It's a security concern on a personal computer, but someone having access is going to typically have more avenues for doing bad things. It's typically much more of a concern to do so when we are talking about organizational use. So maybe only a moot point of obfuscation at best with open source Chocolatey, not with C4B.

@ferventcoder
Copy link
Member

Updated that last statement for clarification.

@heldchen
Copy link

so in other words, Chocolatey in the open source version could easily add a parameter to show the arguments, without any of the aforementioned concerns raised.

personally, I doubt that this feature is relevant in a organizational use case anyway, as one expects things as "parameters used" to be documented in such a setting anyway.

@ferventcoder
Copy link
Member

@heldchen fair statement

@ferventcoder
Copy link
Member

I don't think there was argument that this feature was not valuable. There are loads of valuable feature adds in our backlog here (lots of tickets), being a year or more old doesn't mean we don't plan to address. Typically if we have a milestone on something, it's considered in our backlog.

@musm
Copy link

musm commented Jan 16, 2019

Maybe there doesn't need further motivation on why this is useful, but here's mine:

Backing up installed packages, which are then exported and installed on a fresh computer with the same optional parameters.

@akaleeroy
Copy link

Another motivation: in trying to make upgrade actually upgrade – not re-install packages – one would have to pass arguments to packages to not create a desktop shortcut again.

And in order not to break the ability to upgrade with choco upgrade -y somepackage that NoDesktopIcon install argument could be saved using useRememberedArgumentsForUpgrades

@tylerszabo
Copy link

tylerszabo commented Nov 9, 2019

Here's a PowerShell one-liner based on @heldchen's solution

Add-Type -AssemblyName System.Security
Get-ChildItem -Filter ".arguments" -Path "C:\ProgramData\chocolatey\.chocolatey" -Recurse | ForEach-Object { Write-Output ("{0}: {1}" -f $_.Directory.BaseName, [System.Text.Encoding]::UTF8.GetString([System.Security.Cryptography.ProtectedData]::Unprotect([System.Convert]::FromBase64String(($_ | Get-Content -Encoding UTF8)), [System.Text.Encoding]::UTF8.GetBytes("Chocolatey"), [System.Security.Cryptography.DataProtectionScope]::LocalMachine))) }

@marcinsmialek
Copy link

This is especially important when one wants to find out, which packages were installed with --prerelease, and remove that parameter.

TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Mar 6, 2022
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Mar 9, 2022
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Mar 10, 2022
Adds the ability for implementations of uninstall_run to reset the
config in ChocolateyPackageService via the resetConfigAction.
This will be required to prevent an issue similar to chocolatey#1443 for
uninstall, once useRememberedArgumentsForUninstall is added in.
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Mar 10, 2022
This renames the set_package_config_for_upgrade to a more generic name,
and adds in another parameter to prepare for setting remembered args
for uninstall as well as upgrade
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Jan 28, 2023
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Jan 28, 2023
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Jan 28, 2023
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Jun 16, 2023
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Jun 16, 2023
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Jul 1, 2023
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
@gep13 gep13 modified the milestones: Future, 2.3.0 Dec 14, 2023
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Jan 9, 2024
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Apr 28, 2024
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
gep13 pushed a commit to TheCakeIsNaOH/choco that referenced this issue Apr 30, 2024
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
gep13 pushed a commit to TheCakeIsNaOH/choco that referenced this issue May 20, 2024
This adds the listing of remembered arguments to the list/info commands
It only grabs the arguments when --local-only is specified, then
decrypts and outputs them. Requires --verbose to be listed on the
command line.
gep13 added a commit to TheCakeIsNaOH/choco that referenced this issue May 20, 2024
This commit makes sure that no potentially sensitive arguments are
displayed to the end user. This makes use of the same code that is
currently being used in Chocolatey GUI, for providing the same function.
Now that this code exists in Chocolatey CLI, at some point in the
future, Chocolatey GUI can be updated to use it, rather than maintaining
the code in two places.

This new code makes use of the existing SensitiveArgumentsProvided method
to establish whether the argument is deemed as sensitive, and if it is,
"[REDACTED ARGUMENT]" is output, rather than the value itself.

This new function has been created as a static method, so that it can
be used easily in the Chocolatey GUI codebase.
gep13 added a commit that referenced this issue May 20, 2024
@gep13 gep13 added 4 - Done and removed 3 - Review labels May 20, 2024
@heldchen
Copy link

nice, thanks everyone involved in getting this feature added!

gep13 added a commit to gep13/choco that referenced this issue May 24, 2024
Remembered arguments can now be displayed when running the choco info
command, using the --local-only option.

This commit adds a test to verify that this is correctly shown.
corbob pushed a commit to gep13/choco that referenced this issue May 27, 2024
Remembered arguments can now be displayed when running the choco info
command, using the --local-only option.

This commit adds a test to verify that this is correctly shown.
gep13 added a commit to gep13/choco that referenced this issue May 28, 2024
Remembered arguments can now be displayed when running the choco info
command, using the --local-only option.

This commit adds a test to verify that this is correctly shown.
corbob added a commit to gep13/choco that referenced this issue May 28, 2024
corbob added a commit to gep13/choco that referenced this issue May 29, 2024
vexx32 pushed a commit to gep13/choco that referenced this issue May 30, 2024
Remembered arguments can now be displayed when running the choco info
command, using the --local-only option.

This commit adds a test to verify that this is correctly shown.
gep13 added a commit to gep13/choco that referenced this issue May 30, 2024
Remembered arguments can now be displayed when running the choco info
command, using the --local-only option.

This commit adds a test to verify that this is correctly shown.
gep13 added a commit that referenced this issue Jun 5, 2024
* release/2.3.0: (153 commits)
  (#23) Move call to SetRemotePackageNamesIfAllSpecified
  (#1901) Revert commit to display location
  (maint) Update Authenticode Signature
  (tests) Some minor tweaks for test consistency
  (#310) Set-EnvironmentVariable: delete values properly
  (tests) Remove v2 import tests
  (#310) Fix test issues
  (#310) Fixup v2 compatibility
  (tests) Working on tests during pairing session
  (#2050) Add Pester test for --ignore-pinned option
  (#3381) Add Pester tests for rule command
  (#1144) Add Pester test to cover hash validation
  (#72) Add Pester tests to cover new functionality
  (test) Update assertions for push commands
  (#1310) Add Pester test to validate output
  (#23) Add tests to handle install all
  (#2200) Add test for new enhanced exit code
  (#1764) Add test for new enhanced exit code
  (#1760) Add test for new enhanced exit code
  (#1759) Add test for new enhanced exit code
  ...
@choco-bot
Copy link

🎉 This issue has been resolved in version 2.3.0 🎉

The release is available on:

Your GitReleaseManager bot 📦 🚀

gep13 added a commit that referenced this issue Jun 5, 2024
* master: (37 commits)
  (#310) Fix path to chocolatey.lib files
  (maint) Corrected casing of file
  (#23) Move call to SetRemotePackageNamesIfAllSpecified
  (#1901) Revert commit to display location
  (maint) Update Authenticode Signature
  (tests) Some minor tweaks for test consistency
  (#310) Set-EnvironmentVariable: delete values properly
  (tests) Remove v2 import tests
  (#310) Fix test issues
  (#310) Fixup v2 compatibility
  (tests) Working on tests during pairing session
  (#2050) Add Pester test for --ignore-pinned option
  (#3381) Add Pester tests for rule command
  (#1144) Add Pester test to cover hash validation
  (#72) Add Pester tests to cover new functionality
  (test) Update assertions for push commands
  (#1310) Add Pester test to validate output
  (#23) Add tests to handle install all
  (#2200) Add test for new enhanced exit code
  (#1764) Add test for new enhanced exit code
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.