-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[BUG] npm resets the SUID bit for a binary in /usr/local/bin #3705
Comments
Can you try the latest version of npm? It's up to v7.21.1 atm. |
Happens on 7.21.1 as well. |
Same problem on 8.1.2 (LTS) shipped with nodejs 16.13.1 Here is an example with the gosu binary, but it's true for all binaries in this directory. Here is the node installation procedure used :
Here is the example :
|
Same issue as #4010 |
I don't know why this issue ins't a priority. I just update from 8.4.0 to 8.5.4 (using node v14.19.0) and lost sudo privileges on my server. sudo -i;
npm i -g npm; got me to
|
@jonathanpmartins FYI I've created a security issue via Github security report process (NPM Cli security issues seems to be managed by Github team => https://github.com/npm/cli/security/policy) and I have no response since 11 days |
After digging up for hours, and many many AMI restores later, I got to the real problem. Solution: sudo chown root:root /usr/bin;
sudo npm i -g [email protected];
sudo -i; #working So the real problem is:
After this workaround I was able to update NPM without losing sudo privileges. Unfortunately, I wasn't able to recover my server that I lost sudo privileges on. This only works if you know about the problem and change the bin folder ownership before updating npm. Today was the day of restoring backups! |
Seems legit, my |
@jonathanpmartins @bodqhrohro The real problem is NPM is touching permissions of binaries it doesn't installed. In the example above, gosu was owned by root:root and /usr/bin too |
Closing as a duplicate of #4010 |
Is there an existing issue for this?
Current Behavior
I have a binary in
/usr/local/bin/
, which is not related to JavaScript. When I upgrade some package which has a global binary vianpm
, liketypescript
ornpm
itself, the SUID bit on that binary is reset, and I have to set it manually again.Expected Behavior
npm
shouldn't touch foreign files in/usr/local/bin/
at all.Steps To Reproduce
sudo npm i -g npm
Environment
The text was updated successfully, but these errors were encountered: