LWN.net Logo

Advertisement

GStreamer, Embedded Linux, Android, VoD, Smooth Streaming, DRM, RTSP, HEVC, PulseAudio, OpenGL. Register now to attend.

Advertise here

App confinement for Ubuntu mobile devices

By Nathan Willis
April 24, 2013

Ubuntu has started outlining its plans for supporting third-party applications on mobile devices. The larger plan involves enabling independent developers to deliver their apps to phone and tablet users, but without going through the lengthy process currently used for maintaining packages in the desktop and server repositories. Consequently, new measures are planned to protect system security from potentially malicious applications. The blueprint is based on AppArmor, but it attempts to address several distinctions in the mobile device platform that AppArmor on desktops usually ignores.

The primary motivator for the new security work is that on desktop systems, the user session has historically been treated as "trusted"; Unix-like systems sport mechanisms that programs could use to attack other programs, but in practice programs have generally been trusted not to do so. Perhaps this is because the vast majority of desktop software on Linux systems is delivered through distribution (or project-specific) software repositories, which by and large have established review processes in place—or else the software in question is compiled locally, which places more of the burden for watching out for security issues on the user or administrator.

But mobile Linux systems are different. Casual phone users are less likely to be security-conscious developers or longstanding participants in the (at times) wild open source community. A far higher percentage of mobile phones apps are deployed as third-party apps on Linux desktop applications. Android copes with this distinct risk profile by several means, including restricting apps to its application sandbox and running each app as a separate user, but also by developing its own services for inter-process communication (IPC) and similar features.

The Ubuntu mobile platform, however, is intended to stay as close as possible to the system stack used on desktops and servers. Creating a separate IPC mechanism, permission system, and storage system solely for mobile devices is out of the question. The Ubuntu Security Team has published a specification outlining both the security risks found in the desktop environment, and how it plans to compensate for those risks on mobile devices.

The risks and requirements

The basic requirements needed from the "application confinement" framework (as it is called) include the ability to pre-define filesystem locations that the app can access, the ability to restrict Internet access, and the ability to log events for debugging and auditing purposes. AppArmor already meets those requirements, and it offers several additional options, such as the ability to restrict things like library loading, capabilities, and certain privileged operations.

But AppArmor does not currently address some other important system components, such as D-Bus, the GConf or GSettings configuration storage frameworks, or the display server. D-Bus runs several IPC "buses," including the privileged system bus and the user session bus. But on desktop systems it does not enforce any restrictions on using the session bus, so malicious apps could potentially send harmful messages to other programs. GConf generally uses a single settings database for all applications associated with a user account, and GSettings has a similar per-user settings database. The X display server features several mechanisms that a malicious app could use to sniff data from other applications, such as the clipboard, screenshots, input events, drag-and-drop, and the XSETTINGS configuration framework.

Many desktop systems also take a lax approach to environment variables, such as allowing applications to load arbitrary modules by setting a special environment variable. Applications can also send signals to other processes (such as SIGTERM), and potentially discover information about other processes through /proc. The specification also notes that the GNOME Keyring and Ubuntu Online Accounts programs are both potential security risks, since they store user credentials of various types, but both respond to queries from other applications over D-Bus.

And they have a plan

The risks posed by X constitute a challenge on their own. Obviously, the display server issues fall under Ubuntu's plans to develop its own Mir display server and Unity-Next graphical shell. The application confinement specification notes in brief that Mir should prevent arbitrary applications from taking screenshots and from sniffing input events belonging to other applications, and that Mir will not support XSETTINGS. Mir will also utilize AppArmor policy rules to limit access to the clipboard and to drag-and-drop events.

Many of the other challenges will be addressed through AppArmor profiles, though some necessitate changes to AppArmor or to the system frameworks involved. Each app will be shipped with its own AppArmor profile, which will enumerate its permissions. The app launcher will handle loading the AppArmor profile, configuring the environment, and launching the app (as well as cleaning up after the app shuts down). This process also requires some changes to AppArmor, since the way it currently works, all profiles are loaded at system start-up. The launcher process will also remain alive to monitor running apps, shutting them down if they violate CPU or memory limits, or cause an AppArmor failure event. The specification notes that cgroups were considered for this resource-monitoring task, but that they were not deemed a good fit for the mobile use-case.

The Ubuntu SDK is intended to help developers create these per-app AppArmor profiles; there will be some sort of review process involved which will hopefully catch security violations, but it is still in development. Ultimately, though, the purpose of the confinement scheme is to make the app review process short, but still provide end users with improved security.

To that end, Ubuntu is working on adding D-Bus monitoring to AppArmor policies. Apps will not be allowed to access D-Bus services that belong to the system; there is a blacklist including com.canonical.*, net.launchpad.*, org.gnome.*, org.gtk.*, and other reserved namespaces. Access to GConf and GSettings will be blocked by default. Since GConf has been deprecated in favor of GSettings, it will not receive any further work, but the plan is to develop a fine-grained access mechanism for GSettings. Each app will be allowed to access only specific, whitelisted GSettings paths.

The current plan for environment variable handling is for each AppArmor profile to specify which environment variables the app is authorized to change, and to either deny the app from launching if it attempts to set other environment variables, or to "scrub" those variables before launch. Similarly, AppArmor profiles will whitelist which signals an app is allowed to send. AppArmor will also get support for using the PID variable in profile rules, so profiles will restrict apps to reading only the information in their own /proc/PID directory.

The plan is for Ubuntu Online Accounts to gain AppArmor integration; initially this will be boolean support—an app will either be allowed to access online accounts, or it will not—but support for finer-grained access in later releases is planned, which will enable restricting access on the basis of each configured account. The plan for GNOME Keyring is less clear. Initially, it, too, will be subject to coarse, boolean access restrictions (which will default to "no access"). Apps will also be restricted so that those with GNOME Keyring access will only be permitted to read credentials that the app itself has stored. But the specification says that it is possible that fine-grain access may be added later, perhaps prompting the user when an app requests access to a credential stored by a different application.

The specification also lays out a plan for confining an app's access to the filesystem. Each app will have its own private directory for storing data and settings, in ~/.confined/foo. For access to other data in the filesystem, apps will first need permission for the specific data type in their AppArmor profile (e.g., "Photos", "Contacts", "Music", and so on). When the app requests a file, a separate file-chooser process will launch, allowing the user to select the file; this selection will then be returned to the app over D-Bus. The point of this setup is to force file-selection to be run past the user, so that unauthorized access will not go unnoticed. But the specification points out that exactly how the selected file gets returned may depend on the file type; the details have yet to be fleshed out.

All in all, the Ubuntu application confinement scheme is designed to be "lightweight"; a decision that the wiki says rules out several other possible sandboxing mechanisms, such as LXC containers and virtualization. It is also interesting to note how the decision to run all programs as the same user drives many of the engineering decisions which follow. Android, by comparison, creates a separate user for each app. The Ubuntu application confinement scheme does not use separate user IDs, which in turn is what necessitates setting up security mechanisms to restrict signals, environment variables, D-Bus, and the GConf and GSettings configuration systems.

An interesting thought experiment is to consider that all of the risks that these well-known frameworks present on mobile devices also exist on desktops and servers. But users and administrators are accustomed to them, perhaps in large part because third-party binary applications are relatively scarce on desktops and servers. Although if Linux were to ever "hit it big" in the traditional, world-marketshare-domination sense, that could change. That might make much of the AppArmor work in Ubuntu's application confinement plan considerably more widely applicable.


(Log in to post comments)

App confinement for Ubuntu mobile devices

Posted Apr 25, 2013 5:12 UTC (Thu) by pabs (subscriber, #43278) [Link]

Users run plenty of non-free software on Linux (Skype, Flash, Windows apps via Wine, games etc) but generally don't bother to restrict them. Maybe it is time that desktops like GNOME and KDE started doing that.

App confinement for Ubuntu mobile devices

Posted Apr 25, 2013 8:56 UTC (Thu) by ovitters (subscriber, #27950) [Link]

GNOME has started working on that a while ago, see various LWN articles. It won't be a GNOME-only thing AFAIC. Such things obviously take time.

App confinement for Ubuntu mobile devices

Posted Apr 25, 2013 9:32 UTC (Thu) by khim (subscriber, #9252) [Link]

It's not just non-free applications. Even free applications can be buggy. Unix permissions and the whole security model was invented for the world where large iron machines server tens or may be hundreds of users and you need to protect users from other users. In today's desktop world this deteriorates to this XKCD strip. Practically speaking today Linux desktop "security" is much closer to MS DOS security model then to any other security model.

I know these things take time but this is getting ridiculous: change in security happened twenty years ago when Internet become ubiquitous yet Linux security model is still centered around "one standalone large machine with hundreds of terminals" which is barely ever used anymore.

App confinement for Ubuntu mobile devices

Posted Apr 26, 2013 11:37 UTC (Fri) by sorpigal (subscriber, #36106) [Link]

A much better model would be per-process users (or rather per-application) which, hello, looks a lot like Android. To make this practical I would want to combine it with some kind of (de)centralized authorization system such that I don't have to have a different password for each application for each device. It takes a rather hefty amount of infrastructure to set this up and not be locked out of all of your stuff when the network goes down.

App confinement for Ubuntu mobile devices

Posted Apr 26, 2013 16:08 UTC (Fri) by dlang (✭ supporter ✭, #313) [Link]

note that now that android is trying to support multiple users, they are having some fun with their use of users for apps

App confinement for Ubuntu mobile devices

Posted Apr 26, 2013 19:12 UTC (Fri) by dtlin (✭ supporter ✭, #36537) [Link]

Each user gets a different UID space so every (user × app signature) gets a different UID. I'm not sure what you mean by "fun", this part seems pretty straightforward.

Having mostly-separate data and settings (with a few globals shared between users) is the interesting part, but that's probably equal amounts of fun with either 2 or M+N UIDs.

App confinement for Ubuntu mobile devices

Posted Apr 25, 2013 9:31 UTC (Thu) by ibukanov (subscriber, #3942) [Link]

I doubt that one can protect a traditional Linux desktop by extra filtering and rules so a user can run untrusted code without bad consequences. AppArmor and Selinux is similar in spirit to Java Security Manager when one starts with code that is allowed to do anything and then tries to restrict it using policies. Java model failed the moment it started to be exploited seriously.

One really has to start from a very restricted sandbox model and then gradually loose it with explicit permissions on case by case basis. This is what Google did with Android and Chromeos and is what Mozilla does with FirefoxOS. Of cause, Android started from scratch with new API and HTML OSes take advantage that HTML is already sandoxed so legacy code can run as is.

It is harder to do if one has legacy code that should be secured. One way to solve it is to run each application in its own VM like www.qubes-os.org does. But such approach is a resource hog and cannot yet be applied to mobile phones or tablets. Ubuntu at least could try to take advantage that they have source of the whole desktop and most applications. For example, they could create sand-boxed system libraries and recompile applications against them. Essentially it virtualizes the application code without overhead of the running each application in its own VM so the application can run on a mobile phone.

App confinement for Ubuntu mobile devices

Posted Apr 25, 2013 10:29 UTC (Thu) by geissert (subscriber, #61258) [Link]

Env vars control and a few other interesting things are already available in the in-kernel tree version of TOMOYO Linux.

I for one would welcome the file-chooser point of access control. In practice, however, I think a more elaborate solution is needed.
Applications tend to use locks, create ".part" files when downloading and then using an atomic rename, etc. All that is not very easy to handle by dynamically adding exceptions to the MAC system.
It might be easier to end up writing a FUSE-based overlay a-la unionfs which incorporates the confinement policy with the help of AppArmor.

App confinement for Ubuntu mobile devices

Posted Apr 25, 2013 14:38 UTC (Thu) by mathstuf (subscriber, #69389) [Link]

> Each app will have its own private directory for storing data and settings, in ~/.confined/foo.

...so they're basically ignoring XDG? Or will the relevant directories/files be bind mounted? If this is done better than patching hard coded paths, maybe more apps will stop dumping things directly in $HOME once and for all.

App confinement for Ubuntu mobile devices

Posted Apr 26, 2013 14:04 UTC (Fri) by jdstrand (subscriber, #53302) [Link]

~/.confined/foo is meant as an example. The exact location is TBD.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds