You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
chromium won't start under a grsecurity kernel #17460
Running chromium with a grsecurity kernel yields the error:
[1500:1500:0802/235641:FATAL:setuid_sandbox_host.cc(162)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /nix/store/6xhfxlrnjwq8f54qpmzp9c0jjpxya8b0-chromium-51.0.2704.103/libexec/chromium/chrome-sandbox is owned by root and has mode 4755.
#0 0x002b7fe2835e base::debug::StackTrace::StackTrace()
#1 0x002b7fe3ccde logging::LogMessage::~LogMessage()
#2 0x002b82971a1e sandbox::SetuidSandboxHost::PrependWrapper()
#3 0x002b8273d895 content::ZygoteCommunication::Init()
#4 0x002b8273debe content::CreateZygote()
#5 0x002b827beb54 content::BrowserMainLoop::EarlyInitialization()
#6 0x002b825e406b content::BrowserMainRunnerImpl::Initialize()
#7 0x002b825e3303 content::BrowserMain()
#8 0x002b7fdfbbad content::ContentMainRunnerImpl::Run()
#9 0x002b7fdfb081 content::ContentMain()
#10 0x002b7fa3a8da ChromeMain
#11 0x039130667770 __libc_start_main
#12 0x002b7fa3a789 _start
Steps to reproduce
$ cat > test.nix <<EOF{ config, pkgs, ... }:{ # The two misbehaving kids security.grsecurity.enable = true; environment.systemPackages = with pkgs; [ chromium ]; # Some X environment services.xserver.enable = true; services.xserver.displayManager.lightdm.enable = true; services.xserver.windowManager.i3.enable = true; # A user users.extraUsers.testUser = { isNormalUser = true; uid = 1000; password = ""; };}EOF
$ nixos-rebuild build-vm -I nixos-config=./test.nix && ./result/bin/run-nixos-vm
Login as testUser, pop open a terminal (Mod4+Enter), invoke chromium-browser.
Thanks for adding this issue, it's been raised before but not recorded (as far as I can tell). You should also see a message like
grsec: denied RWX mmap of /nix/store/6xhfxlrnjwq8f54qpmzp9c0jjpxya8b0-chromium-51.0.2704.103/libexec/chromium/chromium[chromium:5077]
The "normal" fix for this is to disable mprotect() restrictions, however that's already done (per paxctl -v). For some reason, chromium does work if you set the flag via xattrs. I'm stumped ... EDIT: this was only because I tested on Arch Linux where ELF PaX markings aren't even supported ...)
@obadz I'm almost certain that mprotect() hardening is not to blame, I think the logs just mislead me. I've tried disabling all PaX per-file protections (by running in non-enforcing mode) but to no avail. On a grsec enabled arch linux system, the only thing I need to do is disable mprotect() hardening on chromium itself (as is done in Nixpkgs). The main difference is that their chromium sandbox helper is permitted to retain the setuid bit.
My understanding is that --disable-setuid-sandbox doesn't disable sandboxing entirely, but falls back on namespace-only sandboxing.
The intention is if you want to run Chrome and only use the namespace sandbox, you can set --disable-setuid-sandbox. But if you do so on a host without appropriate kernel support for the namespace sandbox, Chrome will loudly refuse to run.
Given that the Nixpkgs chromium can't use the setuid sandbox helper anyway, I'd think that you'd be no worse off for telling chromium to skip trying to enable it at startup. (chromium does warn you about using an unofficial command-line flag, though, but that looks like a generic warning).
Now, why trying to enable the setuid sandbox and failing appears to cause chromium to trigger a PaX violation is unclear to me.
@obadz possibly. For my own edification I'd like to know why the PaX violation occurs, but more importantly I'd like confirmation that --disable-setuid-sandbox really makes you no worse off than you already are when using Nixpkgs chromium.
You can use chrome://sandbox to see which sandboxing measures are in effect. It's probably useful to compare those for the disable-setuid-sandbox case and vanilla Nixpkgs chromium. If they're the same, I think a wrapper is a viable alternative (you'll get an annoying error, though ...)
@obadz I think that's as good as it gets. SUID vs namespace is mutually exclusive, as I understand it, so that should be okay. The Yama security module is disabled in the common kernel config, but it overlaps with a feature grsecurity also provides (ptrace hardening, specifically preventing the ability to start ptracing an already running process), so we should actually be covered there as well.
Sorry for being a bit late on this, but you won't need either the SUID or the namespace sandbox in grsecurity, because the whole reason why it needs root or user namespaces is to chroot/setuid/setgit to an unprivileged user. I think a RBAC policy for the sandbox created using learning mode should be enough to have an effective layer 1 sandbox (the layer 2 sandbox still uses seccomp-BPF, which I think shouldn't be an issue with grsecurity) without the need to make it setuid or use user namespaces.
@aszlig could you elaborate on this idea? Do you mean to grant CAP_SYS_ADMIN via policy or to outright replace the whole namespace based sandboxing with rbac policy? Policy is probably better but the suid stub requires less effort ... either way, I don't think it has to be either/or (depending on what you're thinking of).
yall are silly. This is not as complicated as your making it out to be. your path is preventing you from changing namespaces. Check to make sure you have xattr enabled on your /usr/lib partition as a advanced option. This is as simple as zfs set xattr=yes zpool/usr on real systems, you can use fstab otherwise if you are lost. Finally cd to the /usr/lib/chromium directory and invoke ./chromium from that directory. Some one say some thing about memory? silly rabbit, tricks are for kids. Building out of tree from source would also work. I find that to be the answer to any problem, learn how the thing is built then do it yourself. Or we can just blame debian until the end of time... I like both options.
Activity
joachifm commentedon Aug 2, 2016
Thanks for adding this issue, it's been raised before but not recorded (as far as I can tell). You should also see a message like
The "normal" fix for this is to disable
mprotect()restrictions, however that's already done (perpaxctl -v). For some reason, chromium does work if you set the flag via xattrs. I'm stumped ... EDIT: this was only because I tested on Arch Linux where ELF PaX markings aren't even supported ...)copumpkin commentedon Aug 3, 2016
Do xattrs get preserved in the nix store/NAR files?
joachifm commentedon Aug 3, 2016
@copumpkin relevant Nix issue NixOS/nix#185
copumpkin commentedon Aug 3, 2016
Ah 😦 we could try using paxctld?
joachifm commentedon Aug 3, 2016
Hm, I think this may have been a red herring. Per a comment on IRC, I tried
--disable-setuid-sandboxwhich allows chromium to run for me.obadz commentedon Aug 3, 2016
I seem to recall that the chrome sandbox meaningfully contributes to security as well, probably don't want to have to choose between grsec and that.
obadz commentedon Aug 3, 2016
Is there a nixos module that will let me disable
mprotectvia a config entry?joachifm commentedon Aug 3, 2016
@obadz I'm almost certain that
mprotect()hardening is not to blame, I think the logs just mislead me. I've tried disabling all PaX per-file protections (by running in non-enforcing mode) but to no avail. On a grsec enabled arch linux system, the only thing I need to do is disablemprotect()hardening on chromium itself (as is done in Nixpkgs). The main difference is that their chromium sandbox helper is permitted to retain the setuid bit.My understanding is that
--disable-setuid-sandboxdoesn't disable sandboxing entirely, but falls back on namespace-only sandboxing.https://bugs.chromium.org/p/chromium/issues/detail?id=598454#c11
Given that the Nixpkgs chromium can't use the setuid sandbox helper anyway, I'd think that you'd be no worse off for telling chromium to skip trying to enable it at startup. (chromium does warn you about using an unofficial command-line flag, though, but that looks like a generic warning).
Now, why trying to enable the setuid sandbox and failing appears to cause chromium to trigger a PaX violation is unclear to me.
obadz commentedon Aug 3, 2016
@joachifm, thanks for doing this research.
Would it make sense to set up a chromium wrapper that creates
makeWrapperand a.desktopfile that invokeschromium-browserwith the correct flag?joachifm commentedon Aug 3, 2016
@obadz possibly. For my own edification I'd like to know why the PaX violation occurs, but more importantly I'd like confirmation that
--disable-setuid-sandboxreally makes you no worse off than you already are when using Nixpkgs chromium.joachifm commentedon Aug 3, 2016
You can use
chrome://sandboxto see which sandboxing measures are in effect. It's probably useful to compare those for thedisable-setuid-sandboxcase and vanilla Nixpkgs chromium. If they're the same, I think a wrapper is a viable alternative (you'll get an annoying error, though ...)obadz commentedon Aug 3, 2016
@aszlig might know
41 remaining items
obadz commentedon Aug 6, 2016
So to recap, with 987f887 &
grsecurity.enable = true, I get:Is that sufficient? And can we do better?
joachifm commentedon Aug 6, 2016
@obadz I think that's as good as it gets. SUID vs namespace is mutually exclusive, as I understand it, so that should be okay. The Yama security module is disabled in the common kernel config, but it overlaps with a feature grsecurity also provides (ptrace hardening, specifically preventing the ability to start ptracing an already running process), so we should actually be covered there as well.
obadz commentedon Aug 6, 2016
@joachifm, great merging now
chromium: split the sandbox into a separate output
obadz commentedon Aug 6, 2016
Also merging in 231ed9e which splits out the sandbox as a separate output from the main Chromium output
joachifm commentedon Aug 6, 2016
@obadz cool, great work. Looking forward to trying this out.
obadz commentedon Aug 6, 2016
Hydra is building the split up chromium now: http://hydra.nixos.org/build/38353737/nixlog/1/tail-reload
Thanks a lot for your help @joachifm. And @cleverca22 @jasom @aszlig and @copumpkin too!
aszlig commentedon Aug 6, 2016
Sorry for being a bit late on this, but you won't need either the SUID or the namespace sandbox in grsecurity, because the whole reason why it needs root or user namespaces is to chroot/setuid/setgit to an unprivileged user. I think a RBAC policy for the sandbox created using learning mode should be enough to have an effective layer 1 sandbox (the layer 2 sandbox still uses seccomp-BPF, which I think shouldn't be an issue with grsecurity) without the need to make it setuid or use user namespaces.
obadz commentedon Aug 7, 2016
@aszlig, I'm afraid I don't know how to do any of this but happy to try a patch :)
joachifm commentedon Aug 8, 2016
@aszlig could you elaborate on this idea? Do you mean to grant CAP_SYS_ADMIN via policy or to outright replace the whole namespace based sandboxing with rbac policy? Policy is probably better but the suid stub requires less effort ... either way, I don't think it has to be either/or (depending on what you're thinking of).
bman7903 commentedon Mar 25, 2018
yall are silly. This is not as complicated as your making it out to be. your path is preventing you from changing namespaces. Check to make sure you have xattr enabled on your /usr/lib partition as a advanced option. This is as simple as zfs set xattr=yes zpool/usr on real systems, you can use fstab otherwise if you are lost. Finally cd to the /usr/lib/chromium directory and invoke ./chromium from that directory. Some one say some thing about memory? silly rabbit, tricks are for kids. Building out of tree from source would also work. I find that to be the answer to any problem, learn how the thing is built then do it yourself. Or we can just blame debian until the end of time... I like both options.
obadz commentedon Mar 25, 2018
If only there was such a thing as
/usr/lib¯\_(ツ)_/¯ …