# Docker's Root

### Docker's containers are not truly isolated

In a recent machine, I come across a docker container that was running as root shell which is quite normal when you create a container without a user.

But if a user's home directory is mounted, not necessarily the home directory but any directory that a user has write permission is mounted inside the container then by using docker's root shell we can affect the mounted directory and ofcourse since the directory is mounted the affect will show to the user side also.

Here is how i escalate privileges using docker's root to the host's root. User's home directory was mounted in the Docker container which was running as root. So if i create a file from the container inside the user's directory (oyi was the file i created):

<figure><img src="/files/8KVwua8InoOyquqByIhY" alt=""><figcaption></figcaption></figure>

As a container's root obviously it shows the "oyi" file was owned by root and the file literally appeared in the user's shell but the user who owns that "oyi" file was root.

<figure><img src="/files/VSyjm5CYa77yFviug96W" alt=""><figcaption></figcaption></figure>

OK, we get it from the container's side that the file was created as a root but then why in user's shell it shows the file is owned by host's root? Now If it's true then if i copy bash binary in user's shell and go back to the container and change the permission to set the suid bit on bash binary, this will also work, right?

<figure><img src="/files/3unOXXa2kGKq2HedGJaC" alt=""><figcaption></figcaption></figure>

So, I changed the owner of the copied file from user to root and set the SUID bit, when I SSH to the user's shell again, I found that the bash binary has the SUID bit set and escalated the privileges.

### How?


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kaizoku.gitbook.io/notes/interesting-findings/dockers-root.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
