-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Propose NODE_TLS_REJECT_UNAUTHORIZED be renamed #5258
Comments
/cc @nodejs/crypto @mikemaccana thanks for opening this issue. Although I personally prefer the suggestion over at ladjs/superagent#205 for |
[take 2 since I didn't parse this the first time around] Thanks @rvagg. There's a couple of options:
Or some combination of both |
I agree that the word of rejectUnauthorized is not intuitive and I sometimes lost the name. The name of Looking at github, it shows that https://github.com/search?l=javascript&q=rejectUnAuthorized&type=Code&utf8=%E2%9C%93 is much larger than https://github.com/search?l=javascript&q=NODE_TLS_REJECT_UNAUTHORIZED&type=Code&utf8=%E2%9C%93 We can only make soft deprecation for both of them and it would be a hard work. I wonder if it is worth while to go. I have no objection to show a warning due to environment settings related to the security. |
Perhaps is also not the ideal name for that option, given that changing it allows insecure connections.
I will prepare some npm package stats (though it would be iteresting who actually uses that outside of tests), but I think that soft (documentation-only) deprecation would be good.
+1 for the warning from me. |
That's good to know it and give us a great help to make decision. |
The preliminary results do not look good, even NODE_TLS_REJECT_UNAUTHORIZED has huge enough usage, and a signifcant part of that is outside tests. A few examples:
etc. |
Thanks @ChALkeR. Also agreed, |
Made a PR just to see what deprecating
|
Sorry, forgot about the greps. Note that the grep was done only in js/ts/coffeescript sources, and the env var ( |
@ChALkeR Thanks. I guess the first column is the id of package. How many is total? Is it corresponded the number of total package number of 242,054 shown in https://www.npmjs.com/ ? |
@shigeki The first column is downloads/month, as usual =). That data is also a month old, but it should give the right impression. |
@ChALkeR Oops. Yes, some of number in the first column are duplicated. ohtsu@omb:Downloads$ awk -F : '{print $1;}' grep.2016-01-28.NODE_TLS_REJECT_UNAUTHORIZED.sorted.txt |sort |uniq -c |sort -nr |wc
515 1545 27020
ohtsu@omb:Downloads$ awk -F : '{print $1;}' grep.2016-01-28.rejectUnauthorized.sorted.txt |sort |uniq -c |sort -nr |wc
2098 6297 115957
ohtsu@omb:Downloads$ awk -F : '{print $1;}' grep.2016-01-28.* |sort |uniq -c |sort -nr |wc 2551 7656 139748 |
@shigeki No, the number of packages is 1634 (note that there are false positives and false negatives). The total number of packages at the moment of the dataset build was 227866. |
@ChALkeR Okay, thanks.
It is smaller than that of I thought before. @indutny @bnoordhuis Any thoughts? |
@shigeki Note that downloads count is not equal to usage, and that a lot of modules use those modules as dependencies and so on. Directly affecting packages that form about 1% of the total downloads is very significant. Btw, it's 1.2%, |
I think that:
|
Since
|
@mikemaccana |
Please can you just leave this variable as it is? What's the benefit of changing it? I honestly have enough headaches getting tools such as Git and NPM to work behind corporate firewalls without people going round renaming variables unexpectedly. I have to set NODE_TLS_REJECT_UNAUTHORIZED=0 before doing an NPM install of a project I'm working on. This is because openlayers is a dependency and the post install step uses request.js to pull down closure-util. NODE_TLS_REJECT_UNAUTHORIZED is currently the only way I know of making this work without a certificate error. |
@allens The benefit is knowing you're actually downloading closure-util rather than having some network device at your conference wrap it in a little bit of malware. |
@allens A better solution would be to figure out why the certificate for closure-util is invalid in the first place. Are you behind a corporate MITM device like Cisco Ironports that is serving you a bad cert? If so, you probably have already lost all security as many of these devices are misconfigured to accept bad certificates on your behalf, but your best option would be to add the corporate CA to your trusted certificate store, using the 'ca' option. Check out http://www.thedreaming.org/2016/09/27/nodejs-ssl/ for some other SSL troubleshooting tips. |
@mikemaccana I'm all for adding the warning if that's what you mean. I expect most people know exactly what the risks are anyway. @jwalton I know what the better solution is, it's just not practical for me at the moment. I should have been more specific when I said "corporate firewall". A corporate device injecting a fake CA cert is exactly the problem. Thanks for the link but I don't know how to solve my issue with that information Isn't that specific to running my own node app? I'm one step removed - it's an NPM post-install script which is the problem. If I could wave a magic wand and not have to do this I would. I know what I'm doing is a horrible hack but please don't remove the option. What's the point of making life difficult for other developers? As for renaming the variable that just seems like pointless meddling. Thanks |
@allens Ahh, sorry, I misunderstood. But, I think you might be in luck. This PR was merged to node in October which I think will solve your issues: https://github.com/nodejs/node/pull/8334/files. In short, |
@jwalton Can you clarify how to get npm to automatically pass the --use-openssl-ca parameter to Node when it runs (post-install) scripts, please. Shame there isn't a way to get the certificates from the Operating System. These would already have been pre-doctored by the little-brother-in-the-middle SSL scanning technology, thus eliminating the need for additional configuration. |
I think But, if that's not working for you,
Or something roughly equivalent on Windows. |
Sorry no, it didn't find the certificate it was looking for, so it can't have been looking in the Windows Certificate Store (which is obviously set up fine or I wouldn't be able to access the https website where we're having this discussion). I was using this https example
|
https://nodejs.org/api/cli.html#cli_node_extra_ca_certs_file is probably what you want
You can't, that's the problem with CLI options, but when #12648 or #12677 land you will be able to use NODE_OPTIONS to pass CLI options to child processes via env var. |
Thanks. And that's why we'll be continuing to use NODE_TLS_REJECT_UNAUTHORIZED for the moment. |
@Antony74 Sorry, I don't understand your "that's why" comment. I proposed a more secure alternative, did you see https://nodejs.org/api/cli.html#cli_node_extra_ca_certs_file? Was its applicability not clear? Perhaps I misunderstand your problem, but it allows you to recursively add your proxy's cert to node's builtin CA certs, using environment variables, so your proxy is trusted, including for outbound http requests made by npm package install scripts, and it can be used instead of globally disabling all security. @mikemaccana How will changing the env var name make people more secure? They'll just use the new env var. I think what we should do is document the env var. Right now, its existence is being passed around via stackoverflow and other informal channels. We didn't document it because its so insecure, but by not documenting it, we also no longer have a place in the documentation where we can explain why its such a bad idea, and to explain how there are better alternatives. /cc @nodejs/security @nodejs/documentation |
@sam-github Oh I see, NODE_EXTRA_CA_CERTS is an env var not a CLI options so we don't have to wait for one of those two issues you mentioned before trying it. |
Thanks for the update @sam-github. I'm more that happy for NODE_TLS_REJECT_UNAUTHORIZED to be removed once there is a suitable alternative in place. I assume there are no plans to remove it in the current LTS? As well as being behind a corporate SSL filter I am using Windows so at the moment NODE_TLS_REJECT_UNAUTHORIZED is currently the only option for me. This proposal is about renaming NODE_TLS_REJECT_UNAUTHORIZED though. If it is being removed eventually anyway then I think it would be better just to leave it be - just let the option die out with the current LTS. |
I have seen no proposal to do this.
`NODE_EXTRA_CA_CERTS works on Windows, if there are use-cases it doesn't work for I would like to understand them. For renaming NODE_TLS_REJECT_UNAUTHORIZED, I'm -1 |
@sam-github I use the recommended LTS version of node.js. AFAIK NODE_EXTRA_CA_CERTS is only in the latest features release. So for the time being that limits me to NODE_TLS_REJECT_UNAUTHORIZED? |
Should this remain open? |
Was a decision reached on this? I haven't seen anything conclusive so far. |
It doesn't seem like there is broad agreement here. If someone wants to open a PR that prints a warning, go ahead, but I'll close this out. Maybe this reflects my bleak view on human nature in general and programmers in particular but if |
While technically true, it doesn't address the purpose of this issue. The goal isn't to reduce the amount of misuse to zero, as that is clearly not achievable. Instead, the goal is to reduce the misuse as much as possible, and that means clearly signalling to legitimately unaware users that they are doing something dangerous, so that they can take a step back and rectify the issue if they simply weren't aware of the consequences. If at that point they still choose to go ahead, there's not much that can be done about it. In that context, the current interface is really not sufficient; there's no clear signal in either the name of the setting or its operation that the user is doing something dangerous, and it doesn't look any more dangerous to the average user than any other copypasted answer. Something needs to be changed about that, the question is just what. Personally, I feel like ChALKeRs suggestions are reasonable. |
@joepie91 Then you should follow up with a pull request. I closed the issue because there has been no movement in the six months since it was filed.
It wasn't meant to. I'm less hopeful than you a name change or warning will effect any real change, though. Only removal will do that but that's going to be a prolonged effort with our deprecation policy. |
|
Happy to send a PR, but wanted to talk first:
I recently noticed there's a bunch of people trying to connect to untrusted sites using requests, superagent, etc. A bunch of answers to those questions are just
Which is scary. There's two things that could be improved here:
I propose:
Be replaced with a more explicit, inverse option:
Or something similar. Any thoughts?
The text was updated successfully, but these errors were encountered: