-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
NODE_EXTRA_CA_CERTS is ignored after adding capability to node process to run on port below 1024 #22081
Comments
This is a bit unrelated, but FWIW doing
|
Thanks @mscdex. We solved a problem by using nginx and route ports. It was very hard though to find where the problem is. |
Thanks for the bug report. The behavior you describe is an intentional security measure. When node.js runs with elevated privileges (setuid root or capabilities), it ignores the |
Fixes: #22081 PR-URL: #23770 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
Fixes: #22081 PR-URL: #23770 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
Fixes: #22081 PR-URL: #23770 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
Fixes: #22081 PR-URL: #23770 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
@bnoordhuis I tried to search for some additional information about this but without any success. Are there any resources people can read or maybe a reference to a related source code? Thank you. |
@pavelhoral See https://linux.die.net/man/3/secure_getenv - that's basically what Node.js does, except cross-platform: Lines 37 to 70 in 7bb4f95
Lines 114 to 124 in 7bb4f95
|
We needed to add self signed root CA to nodejs, so we did it with using NODE_EXTRA_CA_CERTS environment variable. We are also running nodejs HTTP servers on port 80 and 443 and using following command to allow non-root user to do that:
setcap 'cap_net_bind_service=+ep' /usr/local/bin/node
With that command in place though NODE_EXTRA_CA_CERTS was being ignored. It started working once we removed capability from node executable. I guess that node is not reading file as well as we didn't see warning in case NODE_EXTRA_CA_CERTS pointed to non-existing file.
Reproducible configuration can be found in this repo - https://github.com/dooman87/nodejs-setcap-bug.
To run:
docker-compose up
Once you run it you will see an error:
ERROR self signed certificate
If you comment line 12 in Dockerfile and run it again then you will see successful response from nginx.
The text was updated successfully, but these errors were encountered: