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

Windows - Disable option to add PATH during an AllUsers install #584

Merged
merged 25 commits into from
Dec 13, 2022

Conversation

pseudoyim
Copy link
Contributor

@pseudoyim pseudoyim commented Nov 16, 2022

Description

A critical privilege vulnerability was found in non-default installations of Anaconda installers for Windows users (CVE 2022-26526). This also impacts all Windows installers built using the latest release of constructor (v3.3.1).

To mitigate this vulnerability, this PR disables the option to add the installation to the PATH environment variable during an "All Users" installation. Users can still add the installation to their PATH environment variable during a "Just Me" installation. Additionally, when installing with Administrator privileges, non-admin system Users will no longer have "Write" permissions.

Currently, the user sees these Advanced Installation Options after selecting Just Me or All Users:

Screen Shot 2022-11-16 at 2 58 39 PM
Screen Shot 2022-11-16 at 3 02 57 PM

With the changes in this PR, if the user selects All Users, the option to add to the PATH environment variable will show as disabled:

Screen Shot 2022-11-16 at 2 58 57 PM

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update outdated documentation?
  • Add / update necessary tests?

@pseudoyim pseudoyim self-assigned this Nov 16, 2022
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Nov 16, 2022
@pseudoyim pseudoyim marked this pull request as ready for review November 16, 2022 21:08
@pseudoyim pseudoyim requested a review from a team as a code owner November 16, 2022 21:08
@pseudoyim pseudoyim requested a review from dbast November 21, 2022 17:27
…addtopath

Completely remove option to AddToPath when user selects AllUsers inst…
@pseudoyim
Copy link
Contributor Author

@jaimergp - is this the only key for which the description needs to be updated (regarding how the AddToPath option is disabled for AllUsers installations)?

@pseudoyim pseudoyim requested a review from jaimergp December 7, 2022 01:21
@dbast
Copy link
Member

dbast commented Dec 7, 2022

wouldn't the CVE be already be fixed in the "all users" cases by making the folder only admin writable but still allowing to have it in PATH?

@jaimergp
Copy link
Contributor

jaimergp commented Dec 8, 2022

@jaimergp - is this the only key for which the description needs to be updated (regarding how the AddToPath option is disabled for AllUsers installations)?

I was misremembering there ways a key similar to register_python but apparently there's none? So nothing to document there, I guess.

dbast
dbast previously approved these changes Dec 12, 2022
Co-authored-by: Jaime Rodríguez-Guerra <jaimergp@users.noreply.github.com>
@pseudoyim
Copy link
Contributor Author

LGTM. Can you provide screenshots for the following items?

  • Help message with the new description
  • Error message that appears if /AddToPath=1 is passed in an "All Users" installation.

@jaimergp, per your request:

Help message with the new description
Screen Shot 2022-12-12 at 8 38 50 PM

Error message that appears if /AddToPath=1 is passed in an "All Users" installation.
Screen Shot 2022-12-12 at 8 58 44 PM

It pops up again when the GUI gets to the installation type screen:
Screen Shot 2022-12-12 at 8 59 08 PM

@pseudoyim
Copy link
Contributor Author

@jaimergp @hoechenberger - When I was testing the MessageBox (/AddToPath=1 is disabled and ignored in 'All Users' installations), it kept popping up exactly two times in a row (after hitting the first OK).

I traced the problem to !insertmacro ParseCommandLineArgs being called twice in main.nsi.tmpl (line 323 and line 470). I think it only needs to be called once and this function seemed unnecessary to me, so I removed it in this commit. After I removed it, this solved the problem of the MessageBox popping up twice.

Could you please review this and validate my thinking?

dbast
dbast previously approved these changes Dec 13, 2022
@jaimergp
Copy link
Contributor

Hm, I am not sure... the logic in that part is really opaque. It looks like they are first parsing the CLI arguments, then overriding some defaults, then parsing again.

Both calls were introduced in the same PR (particularly, this commit), but judging by the branch name that PR is part of a merge/reunification. After that, I can't find any history on why you need it twice.

Since we can't prove it was added by accident, and all we can say it looks like deliberate, I'd be inclined to say we shouldn't remove it.

Things we can do to prevent the double warning:

  • Move the AllUsers vs AddToPatch check to the OnInit_Release function so it's only done once.
  • Flip a global var to "remember" whether the user was warned already.

I think I prefer the 1st one.

This is not a pretty part of the codebase so at the very least we should create an issue to investigate the double argument parsing call.

@pseudoyim
Copy link
Contributor Author

Thanks for reviewing @jaimergp. Per your recommendation, I restored the OnInit_Release function and moved the AddToPath check under it. I built a test MinicondaX with these changes and the MessageBox shows up only once. Screenshots look the same as what I posted here.

@dbast
Copy link
Member

dbast commented Dec 13, 2022

LGTM to me. all review comments are covered now and it locally tests correctly. merging.

@dbast dbast merged commit a1efe3b into conda:main Dec 13, 2022
@pseudoyim pseudoyim deleted the fix_CVE-2022-26526 branch December 13, 2022 15:41
@github-actions github-actions bot added the locked [bot] locked due to inactivity label Dec 14, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed [bot] added once the contributor has signed the CLA locked [bot] locked due to inactivity
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants