Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Security issue: npm to install executables as user 'nobody' #5596

Closed
wrigleyster opened this issue Jul 1, 2014 · 4 comments
Closed

Security issue: npm to install executables as user 'nobody' #5596

wrigleyster opened this issue Jul 1, 2014 · 4 comments

Comments

@wrigleyster
Copy link

It is a security issue of large proportion that npm -g installs executables as user 'nobody'. The 'nobody' user should not have write access to any files on a system let alone a whole bunch of libraries and executables. And especially not when those files are intended to be relied upon in the main runnings of the server.

The proper way to do it, would be

  • for npm to register a user 'npm' upon installation, and use this user during build and install, or
  • for npm to build files as 'nobody' in a temporary location, and install built files with ownership 'root', then delete all files owned by 'nobody', or better still
  • combine the two, have npm build as 'npm' but install as 'root'

Having files owned by 'nobody' is like saying to an intruder: "We won't give you root access, but don't worry, you can write to all our crucial files anyway. Enjoy!"

@othiym23
Copy link
Contributor

Patches welcome!

@othiym23
Copy link
Contributor

othiym23 commented Aug 9, 2016

The only time that the CLI is using the nobody UID is when running package lifecycle scripts. In some cases, this will involve those scripts creating files, which will, if nothing else happens, be themselves owned by nobody. However, in almost all cases, the process won't have permissions to write as nobody (because privileges have been dropped to nobody and most global directories are owned by root with fewer permissions than are necessary for nobody to create files), so the situations in which this can cause problems are vanishingly few in number.

As such, I'm going to call that an issue with those packages and their lifecycle scripts, and close this as not an issue in the CLI. If somebody wants to make an attempt to close this hole opened by the lifecycle runner, we'd be happy to review patches, but really, this is something that should be addressed at the level of the individual packages with this issue. Thanks for your time!

@wrigleyster
Copy link
Author

@othiym23 you are very wrong, kind sir. Installing applications, utilities or servers globally will install them as user nobody:

$ sudo npm install -g typescript
[install log]
$ find /usr/lib -user nobody
[long list of files owned by nobody]

This is a serious issue, and should not be closed or ignored. The user nobody is not allowed to own any files, especially not files that might influence the running of, or even directly be services on the interwebs.

@Shasharala
Copy link

If we're talking about global installs with the user set as nobody, I'd like to reference #3849. This is still an issue in the latest version of npm.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants