|
| 1 | +# This profile allows almost everything and only exists to allow bwrap |
| 2 | +# to work on a system with user namespace restrictions being enforced. |
| 3 | +# bwrap is allowed access to user namespaces and capabilities within |
| 4 | +# the user namespace, but its children do not have capabilities, |
| 5 | +# blocking bwrap from being able to be used to arbitrarily by-pass the |
| 6 | +# user namespace restrictions. |
| 7 | + |
| 8 | +# Note: the bwrap child is stacked against the bwrap profile due to |
| 9 | +# bwraps use of no-new-privs. |
| 10 | + |
| 11 | +abi <abi/4.0>, |
| 12 | + |
| 13 | +include <tunables/global> |
| 14 | + |
| 15 | +profile bwrap /usr/bin/bwrap flags=(attach_disconnected,mediate_deleted) { |
| 16 | + allow capability, |
| 17 | + # not allow all, to allow for pix stack on systems that don't support |
| 18 | + # rule priority. |
| 19 | + # |
| 20 | + # sadly we have to allow 'm' every where to allow children to work under |
| 21 | + # profile stacking atm. |
| 22 | + allow file rwlkm /{**,}, |
| 23 | + allow network, |
| 24 | + allow unix, |
| 25 | + allow ptrace, |
| 26 | + allow signal, |
| 27 | + allow mqueue, |
| 28 | + allow io_uring, |
| 29 | + allow userns, |
| 30 | + allow mount, |
| 31 | + allow umount, |
| 32 | + allow pivot_root, |
| 33 | + allow dbus, |
| 34 | + |
| 35 | + # stacked like this due to no-new-privs restriction |
| 36 | + # this will stack a target profile against bwrap and unpriv_bwrap |
| 37 | + # Ideally |
| 38 | + # - there would be a transition at userns creation first. This would allow |
| 39 | + # for the bwrap profile to be tighter, and looser within the user |
| 40 | + # ns. bwrap will still have to fairly loose until a transition at |
| 41 | + # namespacing in general (not just user ns) is available. |
| 42 | + # - there would be an independent second target as fallback |
| 43 | + # This would allow for select target profiles to be used, and not |
| 44 | + # necessarily stack the unpriv_bwrap in cases where this is desired |
| 45 | + # |
| 46 | + # the ix works here because stack will apply to ix fallback |
| 47 | + # Ideally we would sanitize the environment across a privilege boundry |
| 48 | + # (leaving bwarp into application) but flatpak etc use environment glibc |
| 49 | + # sanitized environment variables as part of the sandbox setup. |
| 50 | + allow pix /** -> &bwrap//&unpriv_bwrap, |
| 51 | + |
| 52 | + # the local include should not be used without understanding the userns |
| 53 | + # restriction. |
| 54 | + # Site-specific additions and overrides. See local/README for details. |
| 55 | + include if exists <local/bwrap-userns-restrict> |
| 56 | +} |
| 57 | + |
| 58 | +# The unpriv_bwrap profile is used to strip capabilities within the userns |
| 59 | +profile unpriv_bwrap flags=(attach_disconnected,mediate_deleted) { |
| 60 | + # not allow all, to allow for pix stack |
| 61 | + allow file rwlkm /{**,}, |
| 62 | + allow network, |
| 63 | + allow unix, |
| 64 | + allow ptrace, |
| 65 | + allow signal, |
| 66 | + allow mqueue, |
| 67 | + allow io_uring, |
| 68 | + allow userns, |
| 69 | + allow mount, |
| 70 | + allow umount, |
| 71 | + allow pivot_root, |
| 72 | + allow dbus, |
| 73 | + |
| 74 | + # bwrap profile does stacking against itself this will keep the target |
| 75 | + # profile from having elevated privileges in the container. |
| 76 | + # If done recursively the stack will remove any duplicate |
| 77 | + allow pix /** -> &unpriv_bwrap, |
| 78 | + |
| 79 | + audit deny capability, |
| 80 | + |
| 81 | + # the local include should not be used without understanding the userns |
| 82 | + # restriction. |
| 83 | + # Site-specific additions and overrides. See local/README for details. |
| 84 | + include if exists <local/unpriv_bwrap> |
| 85 | +} |
0 commit comments