Skip to content

Add a --not-a-security-boundary option #653

Closed

Description

@smcv

Depending on the options that it's given, the new namespaces created by bubblewrap might be:

  • a sandboxed environment, with a security boundary between the real system and the sandbox (for example Flatpak uses it this way when running the actual app)
  • a non-sandboxed environment, with differences between the real system and the sandbox, but no meaningful security boundary (for example Flatpak uses it this way when running xdg-dbus-proxy, and the Steam Runtime uses it this way when running Steam games)

If there is meant to be a security boundary, lots of features of bubblewrap need to "fail closed". For example, if we are told to provide a filesystem, and we fail to remount it ro or nosuid, then our only choice is to refuse to run the wrapped program (fail closed), because if we carried on anyway (fail open) then we would not be providing the intended security properties.

However, if there is not meant to be a security boundary, for a lot of failures we can consider ignoring the failure (possibly with a warning) and carrying on anyway.

At the moment, bubblewrap has no way to tell which of these security models the user of bubblewrap is looking for, so we have to make the conservative/pessimistic assumption that they do want a security boundary, and fail closed.

However, if we added a --not-a-security-boundary option, we could use it to make bubblewrap more robust in the cases where something unexpected goes wrong, such as #650. Pseudocode:

if (a thing fails)
  {
    if (not_a_security_boundary)
      warn ("the thing failed (%s), continuing without doing the thing", strerror (errno));
    else
      die_with_error ("the thing failed");
  }

Activity

  1. smcv commented on Sep 9, 2024

    @smcv
    CollaboratorAuthor
  2. xplshn commented on Oct 30, 2024

    @xplshn

    This would be a desired feature for a large part of the AppImages community, AppBundle community, NixAppImage project, and others. It'd be great to have this :)

  3. xplshn commented on Nov 27, 2024

    @xplshn
  4. rusty-snake commented on Nov 27, 2024

    @rusty-snake
  5. smcv commented on Nov 27, 2024

    @smcv
    Author
  6. xplshn commented on Nov 27, 2024

    @xplshn
  7. ao2 commented on May 11, 2026

    @ao2
    Contributor

    A draft implementation of --not-a-security-boundary can be found in #751

  8. ao2 commented on Jun 15, 2026

    @ao2
    Contributor

    This change should also address #541

  9. twhitehead commented on Jul 31, 2026

    @twhitehead

    @smcv would it make sense for this option to also not set PR_SET_NO_NEW_PRIVS? In particular I am thinking of executing programs that have cap_sys_nice set on them (in order for them to be able to set real time priority for some of their threads) not working in bwrap.

    For example, adding cap_sys_nice to chrt to demonstrate this

    cp $(which chrt) .
    sudo setcap cap_sys_nice=eip chrt
    

    It runs okay outside of bwrap

    ./chrt 99 echo hi
    
    hi
    

    but fails inside of bwrap

    bwrap --ro-bind / / --dev /dev --proc /proc --tmpfs /tmp ./chrt 99 echo hi
    
    chrt: failed to set pid 0's policy: Operation not permitted
    
  10. smcv commented on Jul 31, 2026

    @smcv
    CollaboratorAuthor

    would it make sense for this option to also not set PR_SET_NO_NEW_PRIVS?

    No. In the presence of user namespaces, setcap can't work the way you expect it to anyway.

    In particular I am thinking of executing programs that have cap_sys_nice set on them (in order for them to be able to set real time priority for some of their threads) not working in bwrap

    This can't work the way you hope it does. The kernel's data model is that each process can only have capabilities in the "innermost" user namespace; and to be able to do its job, bubblewrap needs to create a new user namespace.

    This means that the most-capable your process inside the container can possibly be is to have CAP_SYS_NICE in the user namespace that was created by bubblewrap. It cannot have CAP_SYS_NICE in the "init namespace" (the namespace where the kernel started init), which is the requirement for being allowed to set real-time priority on yourself.

    Instead, you'll need to send D-Bus messages to RealtimeKit, the Realtime portal or a similar service outside the container, and ask it to give your threads real-time priority "from outside".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions