Skip to content

Conversation

@micheelengronne
Copy link
Member

Add the option to choose the owner of configurations files and their locations.

Add the option to choose the owner of configurations files and their locations.

Signed-off-by: Michée Lengronne <[email protected]>
@micheelengronne micheelengronne force-pushed the micheelengronne-patch-2 branch from 64f4b91 to 5dc04cb Compare May 5, 2020 16:04
Signed-off-by: Michée Lengronne <[email protected]>
@micheelengronne micheelengronne force-pushed the micheelengronne-patch-2 branch from c3ab7b3 to 9305835 Compare May 5, 2020 16:08
Signed-off-by: Michée Lengronne <[email protected]>
@micheelengronne micheelengronne force-pushed the micheelengronne-patch-2 branch from d240832 to 1081581 Compare May 5, 2020 16:09
@micheelengronne
Copy link
Member Author

Signed-off-by: Michée Lengronne <[email protected]>
It should be 'no'

Signed-off-by: Michée Lengronne <[email protected]>
@micheelengronne micheelengronne force-pushed the micheelengronne-patch-2 branch from 7f026a3 to 5fafd0a Compare May 5, 2020 16:19
@micheelengronne micheelengronne changed the title In a container, ssh should not run as root In a container, sshd should not run as root May 5, 2020
Signed-off-by: Michée Lengronne <[email protected]>
@micheelengronne micheelengronne force-pushed the micheelengronne-patch-2 branch from cc9e43d to d47a8eb Compare May 5, 2020 16:26
Will test this rubocop one. Maybe it is the other.

Signed-off-by: Michée Lengronne <[email protected]>
@micheelengronne micheelengronne force-pushed the micheelengronne-patch-2 branch from 57fb69b to 7fda767 Compare May 5, 2020 16:38
@micheelengronne micheelengronne self-assigned this May 5, 2020
@micheelengronne micheelengronne removed their assignment May 6, 2020
@micheelengronne
Copy link
Member Author

@artem-sidorenko is it ok for you ? Is there smthg I did wrong ?

@micheelengronne micheelengronne requested a review from chris-rock May 7, 2020 18:16
@micheelengronne
Copy link
Member Author

@chris-rock is it ok to merge ?

Copy link
Member

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

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

I think it is a great addition @micheelengronne Can you elaborate the use case a bit more? I'd like to understand why a different path is required.

it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into os.darwin? ? 'wheel' : 'root' }
it { should be_owned_by custom_user }
Copy link
Member

Choose a reason for hiding this comment

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

I think that needs to be ssh_custom_user

Copy link
Member Author

Choose a reason for hiding this comment

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

I normally fixed that in the last commit.

Signed-off-by: Michée Lengronne <[email protected]>
@micheelengronne micheelengronne force-pushed the micheelengronne-patch-2 branch from ffb0a13 to 37a07a4 Compare May 7, 2020 20:48
@micheelengronne
Copy link
Member Author

Yes. In the case of a sshd server in a container, the root user should not be used as a container process should not run as root.

In that case, it is not very good to use a reserved root path like /etc/ssh to store configurations.

There is no clear definition of where a configurations ssh folder should be present when a non root user runs sshd. The sshd command is called with the -f flag in that case.

HOME/.ssh is used for the ssh keys and not the configurations. The 2 should not be mixed as they have a different lifecycle (the ssh keys are alterable during the container life, the configurations not).

As there is no clear definition, I think each user should have the choice.

Copy link
Member

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

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

Thank you for the clarification. Great improvement @micheelengronne

@chris-rock chris-rock merged commit 5d8da16 into master May 8, 2020
@chris-rock chris-rock deleted the micheelengronne-patch-2 branch May 8, 2020 07:26
@micheelengronne
Copy link
Member Author

Thank you. Can you trigger a release please ?

@lpirl
Copy link

lpirl commented May 8, 2020

Just out of curiosity: does this mean that the container ensures the security of the host here? If yes, wouldn't this miss the point of privilege separation and, well, containment?
In other words: If the container is not secure once a process therein attains root privileges, then the container is just not that secure and should rather be run unprivileged, no?

@micheelengronne
Copy link
Member Author

The problem is that unprivileged in the container world (particularly docker, less for podman) is not so unprivileged.

/etc/passwd is shared with the host as many other system files. So if your process runs as root in container, it can be considered as running as root (with some restrictions but still) in the host. That is a security risk.

@micheelengronne
Copy link
Member Author

It is generally a bad pattern to write a CMD without specifying a USER first.

@lpirl
Copy link

lpirl commented May 8, 2020

Thanks for the explanation.

Sorry in case I am missing obvious things here, as I primarily use LXC/LXD. If the container is within a user namespace (uidmap/gidmap), the container should never be able to run a process with the host's uid 0 (however, a process can be run with the container's uid 0, but that is mapped). This should be independent from what files are shared with the host (except maybe the Docker configuration and its control socket, you get it), as far as I understand.

But we don't need to get too philosophical here. I just wanted, for the record, to raise the concern about the container's containment qualities if a root process therein threatens the host security (as in: running nothing as root inside the container is the wrong thing to fix).

@micheelengronne
Copy link
Member Author

micheelengronne commented May 8, 2020

for some references:

The problem is that the main used container provider is docker and they made some wrong choices for their project.
The docker daemon is generally run as root (and is a daemon). uid are not mapped but shared so uid 0 is really root in the host.

Podman fixed these problems but is not very widely used. It is compatible with docker. I would generally advice to use podman over docker when possible.

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.

4 participants