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

track user names from inside container, not host #954

Open
mstemm opened this issue Oct 9, 2017 · 1 comment
Open

track user names from inside container, not host #954

mstemm opened this issue Oct 9, 2017 · 1 comment

Comments

@mstemm
Copy link
Contributor

mstemm commented Oct 9, 2017

If you create a user inside a container, sysdig still uses the uids from the host in order to populate %user.name. A way to reproduce is:

$ sudo docker run -it ubuntu:latest bash
root@e0ae2d1b19c2: /root@e0ae2d1b19c2:/# useradd testme
useradd testme
root@e0ae2d1b19c2: /root@e0ae2d1b19c2:/# su - testme
su - testme
No directory, logging in with HOME=/
$ cat /etc/passwd | grep testme
testme:x:1000:1000::/home/testme:
$ cat

While doing this and running sysdig with sudo sysdig container.id!=host and evt.type=execve -p "*%evt.num %evt.outputtime %evt.cpu %proc.name (%thread.tid) %evt.dir %evt.type %evt.info user=%user.name uid=%user.uid", you end up with this output:

5760 08:42:01.554078825 0 bash (12218) > execve filename=/bin/cat  user=deploy uid=1000
5797 08:42:01.554326172 0 cat (12218) < execve res=0 exe=cat args= tid=12218(cat) pid=12218(cat) ptid=12160(bash) cwd= fdlimit=1024 pgft_maj=0 pgft_min=33 vm_size=372 vm_rss=4 vm_swap=0 comm=cat cgroups=cpuset=/docker/e0ae2d1b19c25120fca711f6f8399728ccca234d1897d6474ad4bf3b543378... env=SHELL=/bin/bash.TERM=xterm.USER=testme.MAIL=/var/mail/testme.PATH=/usr/local/... tty=34816  user=deploy uid=1000

Note that although the user inside the container is "testme", sysdig reports the user as deploy, because uid 1000 within the container is being interpreted from the view of the host.

To fix this, we should keep track of uids from the container using something like user.vuid/user.vname.

mstemm added a commit to falcosecurity/falco that referenced this issue Oct 9, 2017
Work around draios/sysdig#954, which relates
to not always knowing the proper user name in containers, by not running
the rule when in a container and the user name is "<NA>". This won't
address cases where the uid from inside the container maps to a user
name outside the container that is different than the user inside the
container, but it will help a bit.
leogr pushed a commit to falcosecurity/rules that referenced this issue Dec 21, 2022
Work around draios/sysdig#954, which relates
to not always knowing the proper user name in containers, by not running
the rule when in a container and the user name is "<NA>". This won't
address cases where the uid from inside the container maps to a user
name outside the container that is different than the user inside the
container, but it will help a bit.
leogr pushed a commit to falcosecurity/rules that referenced this issue Dec 21, 2022
Work around draios/sysdig#954, which relates
to not always knowing the proper user name in containers, by not running
the rule when in a container and the user name is "<NA>". This won't
address cases where the uid from inside the container maps to a user
name outside the container that is different than the user inside the
container, but it will help a bit.
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Feb 23, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 2, 2023
@therealbobo therealbobo reopened this Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants