2012-08-24 12:07:19 -05:00
|
|
|
# This publication is intellectual property of Canonical Ltd. Its contents
|
|
|
|
# can be duplicated, either in part or in whole, provided that a copyright
|
|
|
|
# label is visibly located on each copy.
|
|
|
|
#
|
|
|
|
# All information found in this book has been compiled with utmost
|
|
|
|
# attention to detail. However, this does not guarantee complete accuracy.
|
|
|
|
# Neither Canonical Ltd, the authors, nor the translators shall be held
|
|
|
|
# liable for possible errors or the consequences thereof.
|
|
|
|
#
|
|
|
|
# Many of the software and hardware descriptions cited in this book
|
|
|
|
# are registered trademarks. All trade names are subject to copyright
|
|
|
|
# restrictions and may be registered trade marks. Canonical Ltd
|
|
|
|
# essentially adheres to the manufacturer's spelling.
|
|
|
|
#
|
|
|
|
# Names of products and trademarks appearing in this book (with or without
|
|
|
|
# specific notation) are likewise subject to trademark and trade protection
|
|
|
|
# laws and may thus fall under copyright restrictions.
|
|
|
|
#
|
|
|
|
|
|
|
|
=pod
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
aa-sandbox - AppArmor sandboxing
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
B<aa-sandbox> [option] E<lt>path to binaryE<gt>
|
2012-08-24 12:07:19 -05:00
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
B<aa-sandbox> provides a mechanism for sandboxing an application using an
|
|
|
|
existing profile or via dynamic profile generation. Please note that while this
|
2012-08-24 12:16:20 -05:00
|
|
|
tool can help with quickly confining an application, its utility is dependent on
|
2012-08-24 12:07:19 -05:00
|
|
|
the quality of the templates, policy groups and abstractions used. Also, this
|
2012-08-27 16:11:01 -05:00
|
|
|
tool may create policy which is less restrictive than creating policy by hand or
|
2012-08-24 12:07:19 -05:00
|
|
|
with B<aa-genprof> and B<aa-logprof>.
|
|
|
|
|
|
|
|
=head1 OPTIONS
|
|
|
|
|
|
|
|
B<aa-sandbox> accepts the following arguments:
|
|
|
|
|
|
|
|
=over 4
|
|
|
|
|
|
|
|
=item -t TEMPLATE, --template=TEMPLATE
|
|
|
|
|
|
|
|
Specify the template used to generate a profile. May specify either a system
|
2012-08-24 12:16:20 -05:00
|
|
|
template or a filename for the template to use. If not specified, uses
|
|
|
|
B<sandbox> or B<sandbox-x> when B<-X> is specified. See aa-easyprof(8) for
|
|
|
|
details. Privileged access is required to load the dynamically generated
|
|
|
|
profile (B<aa-sandbox> will prompt for a password).
|
2012-08-24 12:07:19 -05:00
|
|
|
|
|
|
|
=item -p POLICYGROUPS, --policy-groups=POLICYGROUPS
|
|
|
|
|
|
|
|
Specify POLICYGROUPS as a comma-separated list of policy groups. See
|
|
|
|
aa-easyprof(8) for more information on POLICYGROUPS.
|
|
|
|
|
|
|
|
=item -a ABSTRACTIONS, --abstractions=ABSTRACTIONS
|
|
|
|
|
|
|
|
Specify ABSTRACTIONS as a comma-separated list of AppArmor abstractions.
|
|
|
|
AppArmor abstractions are located in /etc/apparmor.d/abstractions. See
|
|
|
|
apparmor.d(5) for details.
|
|
|
|
|
|
|
|
=item -r PATH, --read-path=PATH
|
|
|
|
|
2012-08-24 12:16:20 -05:00
|
|
|
Specify a PATH to allow reads. May be specified multiple times. If the PATH
|
|
|
|
ends in a '/', then PATH is treated as a directory and reads are allowed to all
|
|
|
|
files under this directory. Can optionally use '/*' at the end of the PATH to
|
|
|
|
only allow reads to files directly in PATH.
|
2012-08-24 12:07:19 -05:00
|
|
|
|
|
|
|
=item -w PATH, --write-dir=PATH
|
|
|
|
|
2012-08-24 12:16:20 -05:00
|
|
|
Like --read-path but also allow writes in addition to reads.
|
2012-08-24 12:07:19 -05:00
|
|
|
|
|
|
|
=item --profile=PROFILE
|
|
|
|
|
|
|
|
Instead of generating a dynamic profile, specify an existing, loaded profile.
|
2012-08-24 12:16:20 -05:00
|
|
|
This does not require privileged access.
|
2012-08-24 12:07:19 -05:00
|
|
|
|
|
|
|
=item -X, --with-x
|
|
|
|
|
|
|
|
Run the sandboxed application in an isolated X server.
|
|
|
|
|
2012-08-27 16:43:20 -05:00
|
|
|
=item --with-xauthority=XAUTHORITY
|
|
|
|
|
|
|
|
Specify an Xauthority file to use rather than a dynamically generated one. This
|
|
|
|
is particularly useful in combination with --profile. This option must be used
|
|
|
|
with care to not allow too much access to the sandboxed application. In
|
|
|
|
particular, the profile specified with --profile must add a rule to deny access
|
|
|
|
to ~/.Xauthority for X sandboxing to be effective. Eg:
|
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
audit deny @{HOME}/.Xauthority mrwlk,
|
2012-08-27 16:43:20 -05:00
|
|
|
|
2012-08-24 12:07:19 -05:00
|
|
|
=item --with-xserver=XSERVER
|
|
|
|
|
2012-08-24 12:16:20 -05:00
|
|
|
Choose the nested XSERVER to use. Supported servers are: B<xpra> (the default),
|
|
|
|
B<xpra3d> and B<xephyr>. xpra uses the Xvfb(1) virtual framebuffer X server
|
|
|
|
while xpra3d uses the Xorg(1) server with the Xdummy (dummy_drv.so) driver.
|
2012-08-24 12:07:19 -05:00
|
|
|
|
2012-08-28 07:44:49 -05:00
|
|
|
=item --with-clipboard
|
|
|
|
|
|
|
|
Allow access to the clipboard when using B<xpra> or B<xpra3d>.
|
|
|
|
|
2012-08-27 16:43:20 -05:00
|
|
|
=item --with-xephyr-geometry=GEOMETRY
|
2012-08-24 12:07:19 -05:00
|
|
|
|
2012-08-27 16:43:20 -05:00
|
|
|
The starting geometry for the Xephyr(1) server to use.
|
2012-08-24 12:07:19 -05:00
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
=head1 EXAMPLES
|
|
|
|
|
|
|
|
Use the existing system profile 'firefox' to sandbox /usr/bin/firefox:
|
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
$ aa-sandbox -X --profile=firefox /usr/bin/firefox
|
2012-08-24 12:07:19 -05:00
|
|
|
|
|
|
|
Sandbox xeyes:
|
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
$ aa-sandbox -X /usr/bin/xeyes
|
2012-08-24 12:07:19 -05:00
|
|
|
|
|
|
|
Sandbox glxgears:
|
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
$ aa-sandbox -X --with-xserver=xpra3d /usr/bin/glxgears
|
2012-08-24 12:07:19 -05:00
|
|
|
|
|
|
|
Sandbox uptime:
|
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
$ aa-sandbox --read-path="/proc/*" /usr/bin/uptime
|
2012-08-24 12:16:20 -05:00
|
|
|
|
2012-08-27 16:11:01 -05:00
|
|
|
=head1 NOTES
|
|
|
|
|
|
|
|
B<aa-sandbox> currently relies on Xsecurity rules based on Xauthority. As such,
|
|
|
|
xhost access controls need to be enabled and server interpreted values for
|
|
|
|
localuser must be removed. One way of achieving this is adding a late running
|
|
|
|
Xsession(5) script of the form:
|
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
# Create an Xauthority file if it doesn't exist
|
2012-08-27 16:11:01 -05:00
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
[ ! -f "$HOME/.Xauthority" ] && [ -x /usr/bin/xauth ] &&
|
|
|
|
xauth generate :0 . trusted > /dev/null
|
2012-08-27 16:11:01 -05:00
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
# Default to the Xauthority file
|
2012-08-27 16:11:01 -05:00
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
[ -f "$HOME/.Xauthority" ] && [ -x /usr/bin/xhost ] && [ -x /usr/bin/id ] &&
|
|
|
|
xhost -si:localuser:`id -un` > /dev/null
|
2012-08-27 16:11:01 -05:00
|
|
|
|
|
|
|
After adding the above, it is recommended you remove the existing ~/.Xauthority
|
|
|
|
file, then restart your session.
|
|
|
|
|
2012-08-28 08:09:46 -05:00
|
|
|
=head1 KNOWN LIMITATIONS
|
2012-08-28 08:01:15 -05:00
|
|
|
|
|
|
|
While B<aa-sandbox> may be useful in certain situations, there are a number
|
2012-08-28 08:09:46 -05:00
|
|
|
of limitations regarding both confinement and usability:
|
2012-08-28 08:01:15 -05:00
|
|
|
|
|
|
|
=over
|
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
=item * As mentioned, the quality of the template or the specified profile directly
|
2012-08-28 08:01:15 -05:00
|
|
|
affects the application's confinement.
|
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
=item * DBus system access is all or nothing and DBus session access is unconditionally
|
2012-08-28 08:01:15 -05:00
|
|
|
allowed.
|
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
=item * No environment filtering is performed.
|
2012-08-28 08:01:15 -05:00
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
=item * X server usage has not been fully audited (though simple attacks are believed
|
2012-08-28 08:09:46 -05:00
|
|
|
to be protected against when the system is properly setup. See B<NOTES>,
|
|
|
|
above).
|
2012-08-28 08:01:15 -05:00
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
=item * Using a nested X server for each application is expensive.
|
2012-08-28 08:01:15 -05:00
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
=item * Only the old X cursor is available with B<xpra> and B<xpra3d>.
|
2012-08-28 08:01:15 -05:00
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
=item * The Ubuntu global menu is not currently supported. Gtk and Qt applications
|
2012-08-29 08:43:48 -05:00
|
|
|
should display the non-global menu by default, but applications like Firefox
|
|
|
|
and Thunderbird should be adjusted to disable the global menu.
|
|
|
|
|
2014-09-15 11:30:47 -07:00
|
|
|
=item * Xpra does not handle screen resizing when hotplugging monitors gracefully.
|
2012-08-29 08:49:15 -05:00
|
|
|
Restarting the sandbox will resolve the issue.
|
|
|
|
|
2012-08-28 08:01:15 -05:00
|
|
|
=back
|
|
|
|
|
2012-08-24 12:07:19 -05:00
|
|
|
=head1 BUGS
|
|
|
|
|
2020-05-02 20:40:55 -07:00
|
|
|
If you find any bugs, please report them to Gitlab at
|
|
|
|
L<https://gitlab.com/apparmor/apparmor/-/issues>.
|
2012-08-24 12:07:19 -05:00
|
|
|
|
|
|
|
=head1 SEE ALSO
|
|
|
|
|
2012-08-28 08:01:15 -05:00
|
|
|
apparmor(7) apparmor.d(5) aa-easyprof(8) Xorg(1) Xecurity(7) xpra(1) Xvfb(1)
|
|
|
|
Xephyr(1)
|
2012-08-24 12:07:19 -05:00
|
|
|
|
|
|
|
=cut
|