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

Warn if fabio is run as root #369

Closed
magiconair opened this issue Oct 10, 2017 · 12 comments
Closed

Warn if fabio is run as root #369

magiconair opened this issue Oct 10, 2017 · 12 comments
Milestone

Comments

@magiconair
Copy link
Contributor

Follow up from #195 which suggest that fabio should refuse to start as root unless you pass an -insecure flag. I'm still not fully convinced that users will just use the flag as workaround. Everybody has a right to shoot him/herself in the foot but I'm open for discussion.

@magiconair magiconair added this to the Unplanned milestone Oct 10, 2017
@sean-
Copy link

sean- commented Oct 10, 2017

PostgreSQL does this and it’s been a useful safety precaution that has probably prevented many incidents. That said, it’s also extremely irritating as an operator when diving into a problem as root. Or even when I’m in a secured contained environment and there is only one process, but now I have to manage the creation and lookup of a user/UID. In an ideal world I’d rather see a big obnoxious warning when the flag is used and a once-an-hour log entry nagging the user that the process is running as root (vs only at startup time).

@mterron
Copy link

mterron commented Oct 10, 2017

I stand by what I said in the original thread. It is the software responsibility to do the right thing, in this case refuse to run as root. If you really really really want to (even though it is a bad idea in 99.9999% of the cases), there's a cli switch that will allow you to do that.

Let's make doing the right thing the easy thing to do. +1 on the hourly WARNING when running as root, great idea.

The last ~25 years has proven beyond doubt that "secure by default" is the only reasonable choice, as the large majority of users/operators WILL NOT take steps to secure their deployments and WILL ignore "a big obnoxious warning" as long as the "thing" runs.

If you know what you are doing and want to run with decreased security for your environment, adding a cli switch that is clearly explained to you when you try to do something that's potentially unsafe is not a big deal. Same if you are building containers, adding a user on the build phase is trivial work and industry best practice.

@magiconair
Copy link
Contributor Author

@mterron I agree that the software should do the right thing but there is a valid case for running fabio as root inside a container if it is the only app. Static go binaries like fabio run from a SCRATCH container where there is no user management. Making this mandatory would mean to require a full-blown OS to support that which just increases the size and the attack surface. Also, containers provide the root abstraction for that reason, IMHO. You can be root but you're not root outside your container.

Also, if users will ignore a warning in the logs then they will just use the switch if is there. :)

OK, then the path forward is to refuse to run as root unless you specify -insecure. Issue a visible warning at startup and one WARN log message every hour.

@magiconair magiconair modified the milestones: Unplanned, 1.6 Oct 11, 2017
@mterron
Copy link

mterron commented Oct 11, 2017 via email

@magiconair
Copy link
Contributor Author

That's how I understand that but you'd have to break out of the container first, right? Isn't the point of containers to prevent that?

@mterron
Copy link

mterron commented Oct 11, 2017

This is probably semantics, but IMO as a Security professional, containers in linux don't exist. The kernel have no idea what a container is, the only thing it knows about is cgroups and namespaces.

On other OSs, a container is a kernel primitive so the control and segmentation is stronger (see Solaris/Illumos Zones) and multitenancy is possible (and encouraged).

magiconair added a commit that referenced this issue Oct 23, 2017
Fabio 1.6 will add recurring warning if fabio is run as root (UID == 0)
on UNIX operating systems. It will also add an '-insecure' flag as an
override.

As of version 1.7 fabio will refuse to start as root without the
'-insecure' flag.

Fixes #369
@magiconair
Copy link
Contributor Author

I've pushed a PR which will add a recurring warning which is written to the logs during startup and once an hour if fabio is run as root. The message of the warning changes slightly when the new -insecure flag is used noting that with version 1.7 fabio will refuse to start when run as root.

@magiconair magiconair changed the title Do not allow to run fabio as root by default Warn if fabio is run as root Oct 23, 2017
@magiconair
Copy link
Contributor Author

2017/10/23 16:37:48 [INFO] Running fabio as UID=0 EUID=0 GID=0
2017/10/23 16:37:48 [WARN]

	************************************************************
	You are running fabio as root with the '-insecure' flag
	Please check the fabio wiki for alternatives
	************************************************************

and

2017/10/23 16:38:09 [INFO] Running fabio as UID=0 EUID=0 GID=0
2017/10/23 16:38:09 [INFO] Setting GOMAXPROCS=8
2017/10/23 16:38:09 [WARN]

	************************************************************
	You are running fabio as root without the '-insecure' flag
	This will stop working with fabio 1.7!
	************************************************************

@magiconair
Copy link
Contributor Author

This way users have time to adjust to the change in default behavior.

magiconair added a commit that referenced this issue Feb 2, 2018
Fabio 1.5.7 will add recurring warning if fabio is run as root (UID == 0)
on UNIX operating systems. It will also add an '-insecure' flag as an
override.

As of version 1.7 fabio will refuse to start as root without the
'-insecure' flag.

Fixes #369
@magiconair magiconair modified the milestones: 1.6, 1.5.7 Feb 2, 2018
magiconair added a commit that referenced this issue Feb 2, 2018
Issue #369: Do not allow to run fabio as root
@johnypony3
Copy link

It is now almost a year later. the dockerhub image is still running as root. why?

@stevenscg
Copy link
Contributor

@johnypony3 I was just back checking on this as well. We are moving all of our containers away from root user, so I will probably build my own on alpine and a non-root user.

@aaronhurt
Copy link
Member

@johnypony3 feel free to submit a PR to adjust the project Dockerfile. The required changes should be adding a USER directive and a setcap execution before dropping privileges.

marco-m added a commit to marco-m/fabio that referenced this issue Nov 7, 2021
This switches off the warning

	************************************************************
	You are running fabio as root without the '-insecure' flag
	This will stop working with fabio 1.7!
	************************************************************

and makes all of us feel better :-)

See fabiolb#369

NOTE In my limited tests it just works (using the tutorial https://learn.hashicorp.com/tutorials/nomad/load-balancing-fabio?in=nomad/load-balancing and stopping before section "Place Nomad client nodes behind AWS load balancer"), but since I am learning Nomad/Consul/Fabio, I might be missing something.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants