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

chromium: child processes escape the network namespace sandbox #4087

Closed
6 tasks done
ghost opened this issue Mar 12, 2021 · 5 comments
Closed
6 tasks done

chromium: child processes escape the network namespace sandbox #4087

ghost opened this issue Mar 12, 2021 · 5 comments
Labels
needinfo More information is needed from the issue author networking Issues related to networking features (--net=, etc) stale Closed due to inactivity

Comments

@ghost
Copy link

ghost commented Mar 12, 2021

Write clear, concise and in textual form.

Bug and expected behavior

  • Describe the bug.

I am running Chromium in a custom netns:
firejail --netns=for_wg chromium --user-data-dir="/home/lockywolf/.config/chromium" --disable-async-dns
Then I am finding firejail's pid:
pgrep firejail => 31669 (I actually do this by looking at the process tree, as there are two firejails.)
Then I look at the process tree:

lockywolf@delllaptop:~/BACKUP$ pstree -pST 31669 
firejail(31669)───firejail(31670)───chromium(31695)─┬─chromium(428)
                                                    ├─chromium(31707)───chromium(31730)───chromium(31743)
                                                    ├─chromium(31708,net,pid,user)───chromium(31710)─┬─chromium(1092,pid)
                                                    │                                                ├─chromium(1190,pid)
                                                    │                                                ├─chromium(1478,pid)
                                                    │                                                ├─chromium(31754,pid)
                                                    │                                                ├─chromium(31770,pid)
                                                    │                                                ├─chromium(31780,pid)
                                                    │                                                ├─chromium(31792,pid)
                                                    │                                                ├─chromium(31799,pid)
                                                    │                                                ├─chromium(31808,pid)
                                                    │                                                ├─chromium(31818,pid)
                                                    │                                                ├─chromium(31824,pid)
                                                    │                                                ├─chromium(31841,pid)
                                                    │                                                ├─chromium(31859,pid)
                                                    │                                                ├─chromium(31909,pid)
                                                    │                                                ├─chromium(31924,pid)
                                                    │                                                ├─chromium(31935,pid)
                                                    │                                                ├─chromium(31936,pid)
                                                    │                                                ├─chromium(31976,pid)
                                                    │                                                └─chromium(32313,pid)
                                                    └─chromium(31735)

Huh? PID 31708 escaped the sandbox? Checking:

lockywolf@delllaptop:~/BACKUP$ sudo /sbin/ip netns identify 31708

lockywolf@delllaptop:~/BACKUP$

Nothing!

  • What did you expect to happen?

I expected all Chromium's children to be in the for_wg netns.

No profile and disabling firejail

  • What changed calling firejail --noprofile /path/to/program in a terminal?
    Nothing, same behaviour.
  • What changed calling the program by path (check which <program> or firejail --list while the sandbox is running)?
    I do not understand the question.

Reproduce

  • Steps to reproduce the behavior:
    See above.

Environment

  • Linux distribution and version (ie output of lsb_release -a, screenfetch or cat /etc/os-release)
    Slackware 15.0 alpha1, kernel 5.10.21, glibc 2.33, chromium 89.0.4389.72 (Developer Build) (64-bit)
  • Firejail version (output of firejail --version) exclusive or used git commit (git rev-parse HEAD)
    0.9.64.4

Additional context
Other context about the problem like related errors to understand the problem.
Exactly the same behaviour happens if I run chromium with ip netns exec chromium ...
Checklist

  • The profile (and redirect profile if exists) hasn't already been fixed upstream.: I see nothing related to netns there.
  • The program has a profile. (If not, request one in https://github.com/netblue30/firejail/issues/1139)
  • I have performed a short search for similar issues (to avoid opening a duplicate).: Yes
  • If it is a AppImage, --profile=PROFILENAME is used to set the right profile. : Not an appimage.
  • Used LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 PROGRAM to get english error-messages.
  • I'm aware of browser-allow-drm yes/browser-disable-u2f no in firejail.config to allow DRM/U2F in browsers.: yes, but I do not use U2F and do not keep chrome executables in ~/
debug output

attaching stdout and stderr

firejail.chrome.debug.stderr.txt
firejail.chrome.debug.stdout.txt

The result of children being in a different namespace results in that different tabs of the browser are getting different routes and dns servers.

@rusty-snake
Copy link
Collaborator

rusty-snake commented Mar 12, 2021

I guess that's because of chromiums sandbox. What happens if you start chromium with --no-sandbox?

EDIT: Does slackwares kernel support unprivileged userns clone? (sysctl kernel.unprivileged_userns_clone)

@ghost
Copy link
Author

ghost commented Mar 12, 2021

What happens if you start chromium with --no-sandbox?

Does what I expect it to do. Every child is in for_wg. I would have closed this issue, but em... relying on chromium's good will doesn't infuse me with certainty.

Does slackwares kernel support unprivileged userns clone? (sysctl kernel.unprivileged_userns_clone)

root@delllaptop:/home/lockywolf# sysctl kernel.unprivileged_userns_clone
sysctl: cannot stat /proc/sys/kernel/unprivileged_userns_clone: No such file or directory

@rusty-snake
Copy link
Collaborator

Does slackwares kernel support unprivileged userns clone? (sysctl kernel.unprivileged_userns_clone)

root@delllaptop:/home/lockywolf# sysctl kernel.unprivileged_userns_clone
sysctl: cannot stat /proc/sys/kernel/unprivileged_userns_clone: No such file or directory

This sysctl is a debian patch (used by debian and arch). Mainline does not have it. So unprivileged_userns_clone is supported on your system if userns is supported at all (sysctl user/max_user_namespaces != 0). Then it should work for you the enable chromium-common-hardened.inc (firejail >= 0.9.65 chromium-common-hardened.profile):

mkdir -p ~/.config/firejail
echo "include chromium-common-hardened.inc" >> ~/.config/firejail/chromium-common.local

relying on chromium's good will doesn't infuse me with certainty.

Chromium has it's own sandbox (surprise 😎 ) with a suid-helper in /usr/lib64/chromium/chrome-sandbox (or somewhere else, depending on distro/packages/chromium,vivaldi,brave,..). Chromium fails to start on systems w/o unprivileged_userns_clone if it's started with NO_NEW_PRIVS=1, in a own userns, with seccomp filters or a capability bounding set w/o CAP_SYS_CHROOT and CAP_SYS_ADMIN. Therefore all these this are allowed/disable by default.

So it can run code as root in the default users with NO_NEW_PRIVS=0 and CAP_SYS_ADMIN. In general that's are good starting point to:

  • setup new namespaces with less restrictions
  • escape where ever it wants (if the suid binary on your systems allows it)
  • undo blacklist and whitelist AFAICTY

You can also sudo chmod -s /usr/lib64/chromium-browser-privacy/chrome-sandbox if unprivileged_userns_clone is enabled. I do this via package-manager hocks (needs to be done after every update).

@rusty-snake rusty-snake added the information_old (Deprecated; use "doc-todo" or "needinfo" instead) Information was/is required label Mar 14, 2021
@rusty-snake
Copy link
Collaborator

Any progress here?

@rusty-snake
Copy link
Collaborator

I'm closing here due to inactivity, please fell free to request to reopen if you have more questions.

@kmk3 kmk3 added the stale Closed due to inactivity label Feb 5, 2022
@kmk3 kmk3 added needinfo More information is needed from the issue author and removed information_old (Deprecated; use "doc-todo" or "needinfo" instead) Information was/is required labels Sep 4, 2024
@kmk3 kmk3 changed the title Chromium's children escape the network namespace sandbox. chromium: children processes escape the network namespace sandbox Sep 4, 2024
@kmk3 kmk3 changed the title chromium: children processes escape the network namespace sandbox chromium: child processes escape the network namespace sandbox Sep 4, 2024
@kmk3 kmk3 added the networking Issues related to networking features (--net=, etc) label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needinfo More information is needed from the issue author networking Issues related to networking features (--net=, etc) stale Closed due to inactivity
Projects
None yet
Development

No branches or pull requests

2 participants