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

Add a pelias user #2

Merged
merged 1 commit into from
Sep 3, 2018
Merged

Add a pelias user #2

merged 1 commit into from
Sep 3, 2018

Conversation

orangejulius
Copy link
Member

@orangejulius orangejulius commented Mar 14, 2018

For security reasons, it's important that Docker containers run processes as non-root users where possible. After all, processes in a Docker container are just regular Linux processes, and we wouldn't run Pelias processes as the root user outside of Docker.

This PR adds a pelias user, which is available for running processes later.

Because images built with this baseimage may need to install additional dependencies, we can't run the USER pelias Docker command here, so each of our services/importers needs to do that.

That means this PR should effectively be a no-op until individual services and importers opt-in to using a non-root user.

@orangejulius orangejulius force-pushed the pelias-user branch 2 times, most recently from f6de7b2 to 9f5cde7 Compare August 29, 2018 04:27
@missinglink
Copy link
Member

Sounds like a good idea, couple questions:

  • Will this stop docker from making all the files in my bind-mount owned by root? :)
  • Why did you decide to move /code and /data and then symlink them?
  • Does the use of ~/ in the script target /home/root or /home/pelias?

@orangejulius
Copy link
Member Author

orangejulius commented Aug 30, 2018

Will this stop docker from making all the files in my bind-mount owned by root? :)

I think it will, thankfully. That was getting annoying

Why did you decide to move /code and /data and then symlink them?

I really think we should stick to a roughly standard Linux filesystem layout in our containers, which would mean putting data owned by a user in /home. However having those short mount paths is kinda convenient, and the symlinks seem like a good compromise.

Does the use of ~/ in the script target /home/root or /home/pelias?

That was a change I made when I was trying out running nave as the pelias user, before I realized we can't switch users in this baseimage. I've changed it to /tmp to make it clear and put it in a place appropriate for code that will soon be deleted

Copy link
Member

@missinglink missinglink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am giving my 👍 on the principal of this, it's a good idea.

My personal preference would be to leave /data and /code at the root of the filesystem.

I know that some people might find it unconventional to add new top-level directories.

I personally find it super convenient because I don't have to dig around the filesystem looking for code and data.

I personally don't find /home/pelias/code as any more intuitive or convenient, nor is it a POSIX convention.

The symlinking is a compromise which avoids having to make a decision on a standard to adhere to.

IMHO symlinking represents the worst of the three options available because now the same thing exists in 2 places and scripts can pick and choose which place they prefer to target, which is kinda messy.

@missinglink
Copy link
Member

missinglink commented Aug 30, 2018

Eg: docker run -v /host/data:/data container would bind-mount over the /data symlink but scripts could still write to ~/data and end up in an unexpected location.

For security reasons, it's important that Docker containers run
processes as non-root users where possible. After all, processes in a
Docker container are just regular Linux processes, and we wouldn't run
Pelias processes as the root user outside of Docker.

This PR adds a `pelias` user, which is available for running processes
later.

Because images built with this baseimage may need to install
additional dependencies, we can't run the `USER pelias` Docker command
here, so each of our services/importers needs to do that.

That means this PR should effectively be a no-op until individual
services and importers opt-in to using a non-root user.
@orangejulius
Copy link
Member Author

After thinking about it more, you're totally right, symlinks add complexity (especially around mounting volumes) without solving anything. I also agree that we don't want to give up the convenience of those easy mountable paths /code and /data.

I've removed all the symlink stuff and strived to make this diff as small as possible. We can re-evaluate any other changes in separate PRs. Let me know if it still looks good.

@orangejulius orangejulius changed the title Add and use a pelias user Add a pelias user Aug 31, 2018
@missinglink
Copy link
Member

👍

@orangejulius
Copy link
Member Author

I've tested this with the local Docker setup and it seems to work well.

@orangejulius orangejulius merged commit 8f8116a into master Sep 3, 2018
@orangejulius orangejulius deleted the pelias-user branch September 4, 2018 07:20
orangejulius added a commit to pelias/api that referenced this pull request Sep 4, 2018
This is enabled by the work in pelias/docker-baseimage#2 and lets us ensure the API is run as
a non-root user.

Additionally the maintainer label is now set in the baseimage as of
(pelias/docker-baseimage#8), so it can be removed here.
orangejulius added a commit to pelias/api that referenced this pull request Sep 7, 2018
This is enabled by the work in pelias/docker-baseimage#2 and lets us ensure the API is run as
a non-root user.

Additionally the maintainer label is now set in the baseimage as of
(pelias/docker-baseimage#8), so it can be removed here.
orangejulius added a commit to pelias/pip-service that referenced this pull request Sep 7, 2018
This uses the work in pelias/docker-baseimage#2 to run
processes as the `pelias` user. Running as a non-root user is ideal from
a security perspective.
orangejulius added a commit to pelias/placeholder that referenced this pull request Sep 7, 2018
This uses the work in pelias/docker-baseimage#2 to run
processes as the `pelias` user. Running as a non-root user is ideal from a
security perspective.
orangejulius added a commit to pelias/interpolation that referenced this pull request Sep 7, 2018
This uses the work in pelias/docker-baseimage#2 to run
processes as the `pelias` user. Running as a non-root user is ideal from a
security perspective.
orangejulius added a commit to pelias/openstreetmap that referenced this pull request Sep 11, 2018
This uses the work in pelias/docker-baseimage#2 to run
processes as the `pelias` user. Running as a non-root user is ideal from a
security perspective.
orangejulius added a commit to pelias/whosonfirst that referenced this pull request Sep 11, 2018
This uses the work in pelias/docker-baseimage#2 to run
processes as the `pelias` user. Running as a non-root user is ideal from a
security perspective.
orangejulius added a commit to pelias/geonames that referenced this pull request Sep 11, 2018
This uses the work in pelias/docker-baseimage#2 to run
processes as the `pelias` user. Running as a non-root user is ideal from a
security perspective.
orangejulius added a commit to pelias/transit that referenced this pull request Sep 11, 2018
This uses the work in pelias/docker-baseimage#2 to run
processes as the `pelias` user. Running as a non-root user is ideal from a
security perspective.
orangejulius added a commit to pelias/schema that referenced this pull request Sep 11, 2018
This uses the work in pelias/docker-baseimage#2 to run
processes as the `pelias` user. Running as a non-root user is ideal from a
security perspective.
orangejulius added a commit to pelias/placeholder that referenced this pull request Sep 11, 2018
This uses the work in pelias/docker-baseimage#2 to run
processes as the `pelias` user. Running as a non-root user is ideal from a
security perspective.
orangejulius added a commit to pelias-deprecated/document-service that referenced this pull request Sep 11, 2018
This uses the work in pelias/docker-baseimage#2 to run
processes as the `pelias` user. Running as a non-root user is ideal from a
security perspective.
orangejulius added a commit to pelias/fuzzy-tester that referenced this pull request Sep 12, 2018
This uses the work in pelias/docker-baseimage#2 to run
processes as the `pelias` user. Running as a non-root user is ideal from a
security perspective.
orangejulius added a commit to pelias/docker that referenced this pull request Sep 19, 2018
By default, all Pelias images now have a user called `pelias` with UID
1000. However, running as a different UID may be best for different
people.

By setting the default in `.env` and using it in `docker-compose.yml`,
we can allow people running Pelias to use whatever non-root user is best
for them.

Connects pelias/docker-baseimage#2
orangejulius added a commit to pelias/docker that referenced this pull request Sep 19, 2018
By default, all Pelias images now have a user called `pelias` with UID
1000. However, running as a different UID may be best for different
people.

By setting the default in `.env` and using it in `docker-compose.yml`,
we can allow people running Pelias to use whatever non-root user is best
for them.

Connects pelias/docker-baseimage#2
orangejulius added a commit to pelias/docker that referenced this pull request Sep 25, 2018
By default, all Pelias images now have a user called `pelias` with UID
1000. However, running as a different UID may be best for different
people.

By setting the default in `.env` and using it in `docker-compose.yml`,
we can allow people running Pelias to use whatever non-root user is best
for them.

Connects pelias/docker-baseimage#2
Connects pelias/pelias#745
orangejulius added a commit to pelias/docker that referenced this pull request Sep 27, 2018
By default, all Pelias images now have a user called `pelias` with UID
1000. However, running as a different UID may be best for different
people.

By setting the default in `.env` and using it in `docker-compose.yml`,
we can allow people running Pelias to use whatever non-root user is best
for them.

Connects pelias/docker-baseimage#2
Connects pelias/pelias#745
missinglink pushed a commit to pelias/schema that referenced this pull request Sep 28, 2018
This uses the work in pelias/docker-baseimage#2 to run
processes as the `pelias` user. Running as a non-root user is ideal from a
security perspective.
calpb pushed a commit to sorelle/docker that referenced this pull request Mar 29, 2021
By default, all Pelias images now have a user called `pelias` with UID
1000. However, running as a different UID may be best for different
people.

By setting the default in `.env` and using it in `docker-compose.yml`,
we can allow people running Pelias to use whatever non-root user is best
for them.

Connects pelias/docker-baseimage#2
Connects pelias/pelias#745
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

Successfully merging this pull request may close these issues.

2 participants