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

Why is NODE_TLS_REJECT_UNAUTHORIZED set to 0? #776

Closed
MattMorgis opened this issue Feb 19, 2019 · 15 comments
Closed

Why is NODE_TLS_REJECT_UNAUTHORIZED set to 0? #776

MattMorgis opened this issue Feb 19, 2019 · 15 comments

Comments

@MattMorgis
Copy link
Contributor

MattMorgis commented Feb 19, 2019

🐛 Describe the bug
When running my app with Node.js 11 within VS Code, I get the following message when making an https request:

(node:28306) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.

When I run my app with Node.js 11 without VS Code, I do not get this message.

I narrowed it down to this extension setting the variable to 0:

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

Why is this being set and does it have to be?

🌴 Visual Studio Code Version : [ 1.31.1 ]
🌴 Code Settings Sync Version : [ 3.2.5 ]
🌴 Standard or Insiders : [ standard ]
🌴 Operating System : [ macOS ]

@shanalikhan
Copy link
Owner

This is done , several users reported earlier that they are facing problems in certificates while connecting to github.

Is there any problem you are facing with this configuration ?

@MattMorgis
Copy link
Contributor Author

Yes, this is highly insecure. You are disabling TLS validation for any process running within VS Code. Now my app does not validate SSL certificates when run with VS Code

@marcellourbani
Copy link

@shanalikhan I agree

Just had the same issue: users complained my extension didn't validate certificates and all looked fine for me as you disabled the checks.
Much better if you add an option to install the right root CA

@shanalikhan
Copy link
Owner

Much better if you add an option to install the right root CA

I am open for PR if it solves the problem in both ways, installing CA and not using validation.

@nikolalukovic
Copy link

This is done , several users reported earlier that they are facing problems in certificates while connecting to github.

The solution should never be a complete disable of such a low level security feature which is paramount for secure systems. Especially if it side effects into the whole process.
The problem is with those users' machines/networks and a library should never try and fix a problem that does not even come remotely close to its primary function.

@kron4eg
Copy link

kron4eg commented Feb 22, 2019

The solution should never be a complete disable of such a low level security feature which is paramount for secure systems.

Indeed. I had to uninstall the plugin for now to restore normal behaviour.

@marcellourbani
Copy link

Me too.

@MattMorgis
Copy link
Contributor Author

MattMorgis commented Feb 22, 2019

The problem is with those users' machines/networks and a library should never try and fix a problem that does not even come remotely close to its primary function.

If users report SSL trust issues, they should be sent here: https://code.visualstudio.com/docs/setup/network#_ssl-certificates

Edit: Worst case, the user with the issue can turn it off in VS Code if they wish with --ignore-certificate-errors, but it should not be the default for everyone.

I sent PR #779 which removes the disabling of TLS certificate validation. It would make this safe to use again.

@shanalikhan
Copy link
Owner

Released with v3.2.6

@bernardop
Copy link

@MattMorgis after the 3.2.6 update I haven't been able to use this extension. Whenever I try to update/upload I get an error (Sync: Internet not connected or unable to connect to GitHub. Exception logged in Console). When I look at the console there's a couple of "unable to verify the first certificate" errors. I have tried setting my http.proxyStrictSSL to false and launching vs code with the --ignore-certificate-errors flag without any luck.

What do you think of having a setting that would set NODE_TLS_REJECT_UNAUTHORIZED to 0 right before a network request and set it back to 1 right after? Or is that still insecure?

@ggirard07
Copy link

@MattMorgis How did you manage to narrow it down to this extension from this single error message?
I am currently having the same kind of issue (same error message while trying to run my app in debug), but obviously not from this extension as I don't have it...

@MattMorgis
Copy link
Contributor Author

MattMorgis commented Jan 9, 2020 via email

@ggirard07
Copy link

@MattMorgis thanks, I found my culprit "Azure Repos" extension from Microsoft :/

@icemagno
Copy link

Why ZERO? Why not FALSE/TRUE ?

@jinhua115
Copy link

jinhua115 commented Apr 17, 2024 via email

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

9 participants