Skip to content

Commit

Permalink
fix: use upstream bwrap-userns-restrict for debian
Browse files Browse the repository at this point in the history
  • Loading branch information
R1kaB3rN committed Dec 23, 2024
1 parent 6189d0d commit 4ef785c
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "subprojects/python-xlib"]
path = subprojects/python-xlib
url = https://github.com/python-xlib/python-xlib.git
[submodule "subprojects/apparmor"]
path = subprojects/apparmor
url = https://gitlab.com/apparmor/apparmor.git
85 changes: 85 additions & 0 deletions packaging/deb/debian/apparmor/bwrap-userns-restrict
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This profile allows almost everything and only exists to allow bwrap
# to work on a system with user namespace restrictions being enforced.
# bwrap is allowed access to user namespaces and capabilities within
# the user namespace, but its children do not have capabilities,
# blocking bwrap from being able to be used to arbitrarily by-pass the
# user namespace restrictions.

# Note: the bwrap child is stacked against the bwrap profile due to
# bwraps use of no-new-privs.

abi <abi/4.0>,

include <tunables/global>

profile bwrap /usr/bin/bwrap flags=(attach_disconnected,mediate_deleted) {
allow capability,
# not allow all, to allow for pix stack on systems that don't support
# rule priority.
#
# sadly we have to allow 'm' every where to allow children to work under
# profile stacking atm.
allow file rwlkm /{**,},
allow network,
allow unix,
allow ptrace,
allow signal,
allow mqueue,
allow io_uring,
allow userns,
allow mount,
allow umount,
allow pivot_root,
allow dbus,

# stacked like this due to no-new-privs restriction
# this will stack a target profile against bwrap and unpriv_bwrap
# Ideally
# - there would be a transition at userns creation first. This would allow
# for the bwrap profile to be tighter, and looser within the user
# ns. bwrap will still have to fairly loose until a transition at
# namespacing in general (not just user ns) is available.
# - there would be an independent second target as fallback
# This would allow for select target profiles to be used, and not
# necessarily stack the unpriv_bwrap in cases where this is desired
#
# the ix works here because stack will apply to ix fallback
# Ideally we would sanitize the environment across a privilege boundry
# (leaving bwarp into application) but flatpak etc use environment glibc
# sanitized environment variables as part of the sandbox setup.
allow pix /** -> &bwrap//&unpriv_bwrap,

# the local include should not be used without understanding the userns
# restriction.
# Site-specific additions and overrides. See local/README for details.
include if exists <local/bwrap-userns-restrict>
}

# The unpriv_bwrap profile is used to strip capabilities within the userns
profile unpriv_bwrap flags=(attach_disconnected,mediate_deleted) {
# not allow all, to allow for pix stack
allow file rwlkm /{**,},
allow network,
allow unix,
allow ptrace,
allow signal,
allow mqueue,
allow io_uring,
allow userns,
allow mount,
allow umount,
allow pivot_root,
allow dbus,

# bwrap profile does stacking against itself this will keep the target
# profile from having elevated privileges in the container.
# If done recursively the stack will remove any duplicate
allow pix /** -> &unpriv_bwrap,

audit deny capability,

# the local include should not be used without understanding the userns
# restriction.
# Site-specific additions and overrides. See local/README for details.
include if exists <local/unpriv_bwrap>
}
1 change: 0 additions & 1 deletion packaging/deb/debian/apparmor/bwrap-userns-restrict-umu

This file was deleted.

2 changes: 1 addition & 1 deletion packaging/deb/debian/python3-umu-launcher.install
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ usr/bin/umu-run
usr/share/man/*
usr/share/steam/compatibilitytools.d/umu-launcher/
usr/lib/python3/dist-packages/umu*
debian/apparmor/bwrap-userns-restrict-umu etc/apparmor.d/
debian/apparmor/bwrap-userns-restrict etc/apparmor.d/
1 change: 1 addition & 0 deletions subprojects/apparmor
Submodule apparmor added at 8e431e

0 comments on commit 4ef785c

Please sign in to comment.