Skip to content

chromium won't start under a grsecurity kernel #17460

Closed

Description

@obadz

Issue description

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.

Technical details

  • System: NixOS
  • Nixpkgs version: 26a2392

cc @aszlig @thoughtpolice @joachifm

Activity

  1. self-assigned this
    on Aug 2, 2016
  2. joachifm commented on Aug 2, 2016

    @joachifm
    Contributor

    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 ...)

  3. copumpkin commented on Aug 3, 2016

    @copumpkin
    Member

    Do xattrs get preserved in the nix store/NAR files?

  4. joachifm commented on Aug 3, 2016

    @joachifm
    Contributor

    @copumpkin relevant Nix issue NixOS/nix#185

  5. copumpkin commented on Aug 3, 2016

    @copumpkin
    Member

    Ah 😦 we could try using paxctld?

  6. joachifm commented on Aug 3, 2016

    @joachifm
    Contributor

    Hm, I think this may have been a red herring. Per a comment on IRC, I tried --disable-setuid-sandbox which allows chromium to run for me.

  7. obadz commented on Aug 3, 2016

    @obadz
    ContributorAuthor

    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.

  8. obadz commented on Aug 3, 2016

    @obadz
    ContributorAuthor

    Is there a nixos module that will let me disable mprotect via a config entry?

  9. joachifm commented on Aug 3, 2016

    @joachifm
    Contributor

    @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.

    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.

  10. obadz commented on Aug 3, 2016

    @obadz
    ContributorAuthor

    @joachifm, thanks for doing this research.

    Would it make sense to set up a chromium wrapper that creates makeWrapper and a .desktop file that invokes chromium-browser with the correct flag?

  11. joachifm commented on Aug 3, 2016

    @joachifm
    Contributor

    @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.

  12. joachifm commented on Aug 3, 2016

    @joachifm
    Contributor

    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 ...)

  13. obadz commented on Aug 3, 2016

    @obadz
    ContributorAuthor

    @aszlig might know

  14. 41 remaining items

  15. obadz commented on Aug 6, 2016

    @obadz
    ContributorAuthor

    So to recap, with 987f887 & grsecurity.enable = true, I get:

    image

    Is that sufficient? And can we do better?

  16. joachifm commented on Aug 6, 2016

    @joachifm
    Contributor

    @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.

  17. obadz commented on Aug 6, 2016

    @obadz
    ContributorAuthor

    @joachifm, great merging now

  18. obadz commented on Aug 6, 2016

    @obadz
    ContributorAuthor

    Also merging in 231ed9e which splits out the sandbox as a separate output from the main Chromium output

  19. joachifm commented on Aug 6, 2016

    @joachifm
    Contributor

    @obadz cool, great work. Looking forward to trying this out.

  20. aszlig commented on Aug 6, 2016

    @aszlig
    Member

    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.

  21. obadz commented on Aug 7, 2016

    @obadz
    ContributorAuthor

    @aszlig, I'm afraid I don't know how to do any of this but happy to try a patch :)

  22. joachifm commented on Aug 8, 2016

    @joachifm
    Contributor

    @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).

  23. bman7903 commented on Mar 25, 2018

    @bman7903

    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.

  24. obadz commented on Mar 25, 2018

    @obadz
    ContributorAuthor

    If only there was such a thing as /usr/lib ¯\_(ツ)_/¯ …

    $ find /usr
    /usr
    /usr/bin
    /usr/bin/env
    $
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

0.kind: bug

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions