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

Security: how to protect pm2 process and pm2 applications from being listed/stopped by other users? #260

Closed
madarche opened this issue Jan 19, 2014 · 10 comments · May be fixed by qsays/pm2#2 or pr0d33p/pm2#2

Comments

@madarche
Copy link

Hello,

I haven't found anything about this security topic mentioned before, so here is an issue to talk about it.

At this time it's possible to start pm2 with a dedicated user, and it's good.

But :

  • the pm2 process can be killed by any user simply logged on the production system: pm2 kill
  • all the applications managed by pm2 can be listed/stopped by any user simply logged on the production system: pm2 list, pm2 stop all

A possible security model could be based on filesystem rights. This is very Unix. When called, pm2 could check the calling user rights on the .pm2 directory:

  • If the calling user has read rights on the .pm2 directory (i.e. can open r the directory) → the user is allowed to run pm2 list
  • If the calling user has write rights on the .pm2 directory (i.e. can open w the directory) → the user is allowed to run pm2 stop

That way all the permissions will be dealt on the filesystem level. What do you think?

Cheers,

@rlidwka
Copy link
Collaborator

rlidwka commented Jan 19, 2014

pm2 cli should probably talk with a daemon over a unix socket, not tcp. This will solve permissions problems as well.

@madarche
Copy link
Author

@rlidwka you are right, so far I had just been using pm2 as a (happy) user, I hadn't looked at the code when I described this issue.

And, of course, since pm2 has a client-side and a server-side, this security issue is more complicated to solve than just the proposed solution above. Unix socket is surely a part of the solution, but will it be enough? I will look at how PostgreSQL and its psql cli do it.

Cheers,

@Rush
Copy link

Rush commented Mar 26, 2014

This is a very serious issue for anyone having more than one user on a server. What is the solution? Why would even pm2 allow any other user to access pm2 started as a different user?

@soyuka
Copy link
Collaborator

soyuka commented Mar 26, 2014

Isn't this linked to the npm global install somehow ?

@soyuka
Copy link
Collaborator

soyuka commented May 5, 2014

#329 does not fix this

@soyuka soyuka closed this as completed May 5, 2014
@soyuka soyuka reopened this May 5, 2014
@jfbelisle
Copy link

I still have an issue related to this. I'm listening on a socket. The daemon is started as root and i'm using --run-as-user to start nodejs apps.

But the socket doesn't get created. Of course, it's working if i'm starting the daemon as my own user name but we are in a multiuser environment.

@soyuka
Copy link
Collaborator

soyuka commented Aug 14, 2014

#487

@Unitech Unitech added the 1.0 label Aug 22, 2014
@Unitech
Copy link
Owner

Unitech commented Aug 22, 2014

#642

@Unitech Unitech closed this as completed Aug 22, 2014
@dcaillibaud
Copy link

I still have this issue with version 0.10.1 (from npm or https://github.com/Unitech/PM2.git at this moment) : any local user can stop all apps handled by pm2 but then couldn't start these apps.

@soyuka
Copy link
Collaborator

soyuka commented Aug 23, 2014

Yes we're aware of this but it has been moved to #642 or how things would be resolved (1.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants