20.08.2015 Views

SELinux in Android Lollipop and M

lss2015_selinuxinandroidlollipopandm_smalley

lss2015_selinuxinandroidlollipopandm_smalley

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>SEL<strong>in</strong>ux</strong> <strong>in</strong> <strong>Android</strong> <strong>Lollipop</strong> <strong>and</strong> MStephen SmalleyTrusted Systems ResearchNational Security Agency


CLASSIFICATION HEADERBackground• At LSS 2014, we looked at how <strong>SEL<strong>in</strong>ux</strong> had beenapplied to protect the <strong>Android</strong> TrustedComput<strong>in</strong>g Base (TCB).• Start<strong>in</strong>g with selective root daemon conf<strong>in</strong>ement<strong>in</strong> <strong>Android</strong> 4.4 KitKat.• Mov<strong>in</strong>g toward full conf<strong>in</strong>ement <strong>and</strong> TCBprotection.• Culm<strong>in</strong>ated <strong>in</strong> the <strong>Android</strong> 5.0 <strong>Lollipop</strong> release.CLASSIFICATION FOOTER2


CLASSIFICATION HEADERToday's Talk• Review f<strong>in</strong>al state of <strong>SEL<strong>in</strong>ux</strong> <strong>in</strong> <strong>Android</strong> 5.0<strong>Lollipop</strong> release <strong>and</strong> updates.• Look at advances <strong>in</strong> <strong>SEL<strong>in</strong>ux</strong> <strong>in</strong> AOSP masterexpected <strong>in</strong> the upcom<strong>in</strong>g <strong>Android</strong> M release.• Discuss the state of <strong>Android</strong> & upstream <strong>SEL<strong>in</strong>ux</strong>.• Summarize ongo<strong>in</strong>g <strong>and</strong> future work.CLASSIFICATION FOOTER3


<strong>Android</strong> 5.0 <strong>Lollipop</strong>• Officially announced mid-October 2014.• Released to AOSP on November 4, 2014.• First shipped on the Nexus 6, 9, <strong>and</strong> Player.• Currently runn<strong>in</strong>g on ~18% of active <strong>Android</strong> devices.• First official <strong>Android</strong> release to ship with <strong>SEL<strong>in</strong>ux</strong>enforc<strong>in</strong>g for all processes.– From the root daemons to the apps.– M<strong>and</strong>ated by <strong>Android</strong> 5.0 CDD, tested by CTS.4


<strong>SEL<strong>in</strong>ux</strong> <strong>in</strong> <strong>Android</strong> 5.0 <strong>Lollipop</strong>• All system services <strong>and</strong> apps are conf<strong>in</strong>ed.– Includ<strong>in</strong>g root daemons.• Only two doma<strong>in</strong>s are “unconf<strong>in</strong>ed”.– kernel <strong>and</strong> <strong>in</strong>it• Even these two doma<strong>in</strong>s are not completelyunrestricted by <strong>SEL<strong>in</strong>ux</strong>.– TCB protection goals are applied universally.– No doma<strong>in</strong>/process is all-powerful.5


Protect<strong>in</strong>g the <strong>Android</strong> TCB via <strong>SEL<strong>in</strong>ux</strong>• Noth<strong>in</strong>g can map low memory or access /dev/{k}mem.• Only <strong>in</strong>it can set sensitive kernel sett<strong>in</strong>gs/policy.• Only recovery can write to / or /system (the OS).• Native services can only execute from / <strong>and</strong> /system.• Only debuggerd can ptrace others.• Apps cannot write to most netl<strong>in</strong>k sockets.• Apps cannot write to most service sockets.• No read<strong>in</strong>g/follow<strong>in</strong>g untrusted syml<strong>in</strong>ks.6


Service-specific Protection via <strong>SEL<strong>in</strong>ux</strong>• <strong>Android</strong> keystore– Provides secure storage of keys.• <strong>SEL<strong>in</strong>ux</strong> kernel-enforced guarantees:– Noth<strong>in</strong>g can ptrace the keystore.– Noth<strong>in</strong>g else can open /data/misc/keystore files.• <strong>SEL<strong>in</strong>ux</strong> userspace access control:– Keystore checks <strong>SEL<strong>in</strong>ux</strong> policy for client requests.– Sensitive operations restricted via policy.7


<strong>Android</strong> 5.0 CTS <strong>SEL<strong>in</strong>ux</strong> Tests●●●●●●●Enforc<strong>in</strong>g for all.Policy satisfies neverallow rules.Core system services runn<strong>in</strong>g <strong>in</strong> their doma<strong>in</strong>s.Only <strong>in</strong>it <strong>in</strong> the <strong>in</strong>it doma<strong>in</strong>.Only kernel threads <strong>in</strong> the kernel doma<strong>in</strong>.Noth<strong>in</strong>g runn<strong>in</strong>g <strong>in</strong> recovery or su doma<strong>in</strong>s.No policy booleans.8


<strong>Lollipop</strong> Updates●●●5.0.1 through 5.1.1Carry forward all of the <strong>SEL<strong>in</strong>ux</strong> protections.5.1 CTS has improved neverallow checker.– Check all doma<strong>in</strong>s, not just AOSP doma<strong>in</strong>s.– Back-ported from AOSP master.9


<strong>Android</strong> M●●●●●Next major release of <strong>Android</strong>.Developer Preview first released May 28.Preview 2 released July 9.F<strong>in</strong>al release expected Q3 2015.Includes <strong>SEL<strong>in</strong>ux</strong> changes made to AOSPmaster s<strong>in</strong>ce <strong>Lollipop</strong> was forked.10


<strong>SEL<strong>in</strong>ux</strong> <strong>in</strong> <strong>Android</strong> M●●●●●●ioctl whitelist<strong>in</strong>g (see separate talk)Re<strong>in</strong>forc<strong>in</strong>g <strong>Android</strong> multi-userStrengthen<strong>in</strong>g the Chrome s<strong>and</strong>boxLock<strong>in</strong>g down the B<strong>in</strong>derPolicy Harden<strong>in</strong>gCTS enhancements11


<strong>Android</strong> Multi-User●●●●●●First <strong>in</strong>troduced <strong>in</strong> 4.2 for tablets.Supported on phones start<strong>in</strong>g with 5.0.Also the basis for restricted <strong>and</strong> managed profiles,<strong>in</strong>clud<strong>in</strong>g <strong>Android</strong> for Work.User identity encoded as part of the UID.Middleware enforces certa<strong>in</strong> cross-user restrictions.Kernel enforces the usual DAC restrictions.12


<strong>SEL<strong>in</strong>ux</strong> <strong>and</strong> <strong>Android</strong> Multi-User●●●Goal: Re<strong>in</strong>force <strong>Android</strong> multi-user separationtransparently, without complicat<strong>in</strong>g policy.Map user identity to unique MLS level (us<strong>in</strong>gcategories), assign to app processes <strong>and</strong> files.MLS constra<strong>in</strong>ts prevent communicationsacross different levels.– except via B<strong>in</strong>der, which is mediated by middleware13


<strong>SEL<strong>in</strong>ux</strong> <strong>and</strong> <strong>Android</strong> Multi-User (cont'd)●●●Apps runn<strong>in</strong>g for different users areautomatically assigned different levels.<strong>SEL<strong>in</strong>ux</strong> blocks send<strong>in</strong>g signals, access<strong>in</strong>g/proc/pid, open<strong>in</strong>g app data files, orcommunicat<strong>in</strong>g via local sockets across levels.No per-user or per-app policy configurationrequired; just us<strong>in</strong>g MLS <strong>and</strong> categories.14


The Chrome for <strong>Android</strong> s<strong>and</strong>box●●●●Comb<strong>in</strong>es multi-process architecture with UID isolation.App service components can be declared with aprocess=”name” <strong>and</strong> an isolatedProcess=”true” attribute.<strong>Android</strong> will run such services <strong>in</strong> a separate process <strong>and</strong>UID from the ma<strong>in</strong> app.This process has no <strong>Android</strong> permissions <strong>and</strong> the usualDAC restrictions, i.e. cannot read or write the files of thema<strong>in</strong> app unless they are world accessible.15


<strong>SEL<strong>in</strong>ux</strong> <strong>and</strong> the Chrome s<strong>and</strong>box• Goal: Strengthen the s<strong>and</strong>box beyond DAC.• Isolated service processes already assigned their owndoma<strong>in</strong>, isolated_app.• Removed specific accesses from isolated_app.– No direct open of app data files.– No GPU device access.– No keystore permissions.16


Lock<strong>in</strong>g down the B<strong>in</strong>der• B<strong>in</strong>der is the central IPC primitive for <strong>Android</strong>.• B<strong>in</strong>der has a top-level name service, known as theB<strong>in</strong>der context manager.• On <strong>Android</strong>, this is the servicemanager process.• The servicemanager checks <strong>SEL<strong>in</strong>ux</strong> policy forrequests.– add (register new service by name)– f<strong>in</strong>d (look up a service by name)– list (list all registered service names)17


Lock<strong>in</strong>g down the B<strong>in</strong>der (cont'd)• <strong>Lollipop</strong> shipped with add permission restricted.• M locks down f<strong>in</strong>d <strong>and</strong> list permissions.• Prevents apps from look<strong>in</strong>g up arbitrary b<strong>in</strong>derservices.• If you cannot look up the service b<strong>in</strong>der reference, youcannot call the service.– B<strong>in</strong>der references are kernel-managed capabilities.• Chrome s<strong>and</strong>box / isolated_app restricted to onlym<strong>in</strong>imal required services.18


Policy Harden<strong>in</strong>g• Forced <strong>in</strong>it to transition doma<strong>in</strong>s on exec.– Separate doma<strong>in</strong>s added for helper programs <strong>and</strong> allservices, even oneshot services.• Locked down block device access.– Protect<strong>in</strong>g critical partitions from direct access.– Limit<strong>in</strong>g each doma<strong>in</strong> to only needed partitions.• Removed unconf<strong>in</strong>ed doma<strong>in</strong>.– Even <strong>in</strong>it <strong>and</strong> kernel no longer use it.• Many more neverallows.19


CTS Enhancements• Test validity of all device <strong>SEL<strong>in</strong>ux</strong> configuration files.– Correctness <strong>and</strong> <strong>in</strong>clusion of AOSP def<strong>in</strong>itions.• Test label<strong>in</strong>g of runn<strong>in</strong>g CTS app <strong>and</strong> its files.– Runtime state of device, not just configuration.• Augmented test<strong>in</strong>g of service doma<strong>in</strong>s.– Reverse mapp<strong>in</strong>g, additional services, hostside.• Test MLS attributes.20


<strong>Android</strong> & Upstream <strong>SEL<strong>in</strong>ux</strong>• <strong>Android</strong> <strong>SEL<strong>in</strong>ux</strong> refreshed from upstream for M.• Complete copy of upstream <strong>SEL<strong>in</strong>ux</strong> code importedunder external/sel<strong>in</strong>ux, used for libsepol, checkpolicy.• Work ongo<strong>in</strong>g to synchronize upstream libsel<strong>in</strong>ux <strong>and</strong><strong>Android</strong> fork.• Policy tools imported <strong>in</strong>to <strong>Android</strong> for use by <strong>Android</strong>developers (audit2allow, sesearch, se<strong>in</strong>fo).– Breaks dependency on build host OS support<strong>in</strong>g<strong>Android</strong> <strong>SEL<strong>in</strong>ux</strong> policy version.21


<strong>SEL<strong>in</strong>ux</strong> <strong>in</strong> <strong>Android</strong> vs L<strong>in</strong>ux distributions• > 60% of active <strong>Android</strong> devices are runn<strong>in</strong>g a version of <strong>Android</strong> that has<strong>SEL<strong>in</strong>ux</strong>.– 4.3 Jelly Bean (4.7%), 4.4 KitKat (39.3%), 5.x <strong>Lollipop</strong> (18.1%)• In <strong>Android</strong> 4.4 <strong>and</strong> later, <strong>SEL<strong>in</strong>ux</strong> is always enabled <strong>and</strong> enforc<strong>in</strong>g.• As of 5.0 <strong>and</strong> later, <strong>Android</strong> has a more secure default policy than L<strong>in</strong>uxdistributions.– Fully enforc<strong>in</strong>g, only kernel <strong>and</strong> <strong>in</strong>it “unconf<strong>in</strong>ed”, TCB protection goals.• Yet <strong>Android</strong> has a much smaller <strong>and</strong> simpler policy than L<strong>in</strong>ux distributions.– Roughly 5% the number of rules, 10% the number of types.• Could a similar policy be developed for L<strong>in</strong>ux distributions?22


Ongo<strong>in</strong>g <strong>and</strong> Future Work• Enable apps to opt <strong>in</strong>to stronger protections.– S<strong>and</strong>box<strong>in</strong>g, isolation, file protection• Investigate new runtime permissions feature.– when <strong>Android</strong> M source is released• Improve <strong>SEL<strong>in</strong>ux</strong> tool<strong>in</strong>g for <strong>Android</strong>.• Further userspace policy enforcement.• Kernel self-protection23


Questions?• Send email to se<strong>and</strong>roid-list-jo<strong>in</strong>@tycho.nsa.gov tojo<strong>in</strong> the public SE for <strong>Android</strong> mail<strong>in</strong>g list.• Private email just to our SE for <strong>Android</strong> team:se<strong>and</strong>roid@tycho.nsa.gov• Source code: https://bitbucket.org/se<strong>and</strong>roid• Project page: http://se<strong>and</strong>roid.bitbucket.org• ToDo list:https://bitbucket.org/se<strong>and</strong>roid/wiki/wiki/ToDo24

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!