Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 1 | # The entries in this file define how security contexts for apps are determined. |
| 2 | # Each entry lists input selectors, used to match the app, and outputs which are |
| 3 | # used to determine the security contexts for matching apps. |
| 4 | # |
Nick Kralevich | 4be3190 | 2014-07-01 13:59:50 -0700 | [diff] [blame] | 5 | # Input selectors: |
Michael Peck | f54b362 | 2017-02-14 09:48:57 -0800 | [diff] [blame] | 6 | # isSystemServer (boolean) |
| 7 | # isEphemeralApp (boolean) |
| 8 | # isOwner (boolean) |
| 9 | # user (string) |
| 10 | # seinfo (string) |
| 11 | # name (string) |
| 12 | # path (string) |
| 13 | # isPrivApp (boolean) |
| 14 | # minTargetSdkVersion (unsigned integer) |
Yabin Cui | ffa2b61 | 2018-11-02 14:34:06 -0700 | [diff] [blame] | 15 | # fromRunAs (boolean) |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 16 | # |
| 17 | # All specified input selectors in an entry must match (i.e. logical AND). |
| 18 | # An unspecified string or boolean selector with no default will match any |
| 19 | # value. |
| 20 | # A user, name, or path string selector that ends in * will perform a prefix |
| 21 | # match. |
| 22 | # String matching is case-insensitive. |
| 23 | # See external/selinux/libselinux/src/android/android_platform.c, |
| 24 | # seapp_context_lookup(). |
| 25 | # |
| 26 | # isSystemServer=true only matches the system server. |
Stephen Smalley | dd31ddf | 2012-07-27 17:08:21 -0400 | [diff] [blame] | 27 | # An unspecified isSystemServer defaults to false. |
Chad Brubaker | 06cf31e | 2016-10-06 13:15:44 -0700 | [diff] [blame] | 28 | # isEphemeralApp=true will match apps marked by PackageManager as Ephemeral |
Stephen Smalley | ff4db91 | 2014-09-15 15:16:06 -0400 | [diff] [blame] | 29 | # isOwner=true will only match for the owner/primary user. |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 30 | # user=_app will match any regular app process. |
| 31 | # user=_isolated will match any isolated service process. |
| 32 | # Other values of user are matched against the name associated with the process |
| 33 | # UID. |
| 34 | # seinfo= matches aginst the seinfo tag for the app, determined from |
| 35 | # mac_permissions.xml files. |
| 36 | # The ':' character is reserved and may not be used in seinfo. |
| 37 | # name= matches against the package name of the app. |
| 38 | # path= matches against the directory path when labeling app directories. |
Jeff Vander Stoep | ee9c0b5 | 2015-10-05 09:15:04 -0700 | [diff] [blame] | 39 | # isPrivApp=true will only match for applications preinstalled in |
| 40 | # /system/priv-app. |
Michael Peck | f54b362 | 2017-02-14 09:48:57 -0800 | [diff] [blame] | 41 | # minTargetSdkVersion will match applications with a targetSdkVersion |
| 42 | # greater than or equal to the specified value. If unspecified, |
| 43 | # it has a default value of 0. |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 44 | # fromRunAs=true means the process being labeled is started by run-as. Default |
| 45 | # is false. |
Nick Kralevich | 4be3190 | 2014-07-01 13:59:50 -0700 | [diff] [blame] | 46 | # |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 47 | # Precedence: entries are compared using the following rules, in the order shown |
| 48 | # (see external/selinux/libselinux/src/android/android_platform.c, |
| 49 | # seapp_context_cmp()). |
Michael Peck | f54b362 | 2017-02-14 09:48:57 -0800 | [diff] [blame] | 50 | # (1) isSystemServer=true before isSystemServer=false. |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 51 | # (2) Specified isEphemeralApp= before unspecified isEphemeralApp= |
| 52 | # boolean. |
Nick Kralevich | 795add5 | 2019-04-16 15:56:33 -0700 | [diff] [blame] | 53 | # (3) Specified isOwner= before unspecified isOwner= boolean. |
| 54 | # (4) Specified user= string before unspecified user= string; |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 55 | # more specific user= string before less specific user= string. |
Nick Kralevich | 795add5 | 2019-04-16 15:56:33 -0700 | [diff] [blame] | 56 | # (5) Specified seinfo= string before unspecified seinfo= string. |
| 57 | # (6) Specified name= string before unspecified name= string; |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 58 | # more specific name= string before less specific name= string. |
Nick Kralevich | 795add5 | 2019-04-16 15:56:33 -0700 | [diff] [blame] | 59 | # (7) Specified path= string before unspecified path= string. |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 60 | # more specific name= string before less specific name= string. |
Nick Kralevich | 795add5 | 2019-04-16 15:56:33 -0700 | [diff] [blame] | 61 | # (8) Specified isPrivApp= before unspecified isPrivApp= boolean. |
| 62 | # (9) Higher value of minTargetSdkVersion= before lower value of |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 63 | # minTargetSdkVersion= integer. Note that minTargetSdkVersion= |
| 64 | # defaults to 0 if unspecified. |
Nick Kralevich | 795add5 | 2019-04-16 15:56:33 -0700 | [diff] [blame] | 65 | # (10) fromRunAs=true before fromRunAs=false. |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 66 | # (A fixed selector is more specific than a prefix, i.e. ending in *, and a |
| 67 | # longer prefix is more specific than a shorter prefix.) |
| 68 | # Apps are checked against entries in precedence order until the first match, |
| 69 | # regardless of their order in this file. |
| 70 | # |
| 71 | # Duplicate entries, i.e. with identical input selectors, are not allowed. |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 72 | # |
| 73 | # Outputs: |
Michael Peck | f54b362 | 2017-02-14 09:48:57 -0800 | [diff] [blame] | 74 | # domain (string) |
| 75 | # type (string) |
| 76 | # levelFrom (string; one of none, all, app, or user) |
| 77 | # level (string) |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 78 | # |
| 79 | # domain= determines the label to be used for the app process; entries |
| 80 | # without domain= are ignored for this purpose. |
| 81 | # type= specifies the label to be used for the app data directory; entries |
| 82 | # without type= are ignored for this purpose. |
| 83 | # levelFrom and level are used to determine the level (sensitivity + categories) |
| 84 | # for MLS/MCS. |
| 85 | # levelFrom=none omits the level. |
| 86 | # levelFrom=app determines the level from the process UID. |
| 87 | # levelFrom=user determines the level from the user ID. |
| 88 | # levelFrom=all determines the level from both UID and user ID. |
Nick Kralevich | 795add5 | 2019-04-16 15:56:33 -0700 | [diff] [blame] | 89 | # |
Stephen Smalley | 3808414 | 2012-11-28 10:46:18 -0500 | [diff] [blame] | 90 | # levelFrom=user is only supported for _app or _isolated UIDs. |
| 91 | # levelFrom=app or levelFrom=all is only supported for _app UIDs. |
Nick Kralevich | 4be3190 | 2014-07-01 13:59:50 -0700 | [diff] [blame] | 92 | # level may be used to specify a fixed level for any UID. |
Stephen Smalley | 2dd4e51 | 2012-01-04 12:33:27 -0500 | [diff] [blame] | 93 | # |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 94 | # For backwards compatibility levelFromUid=true is equivalent to levelFrom=app |
| 95 | # and levelFromUid=false is equivalent to levelFrom=none. |
| 96 | # |
William Roberts | 81e1f90 | 2015-06-03 21:57:47 -0700 | [diff] [blame] | 97 | # |
| 98 | # Neverallow Assertions |
Alan Stokes | 6b576bd | 2019-01-31 15:16:01 +0000 | [diff] [blame] | 99 | # Additional compile time assertion checks for the rules in this file can be |
| 100 | # added as well. The assertion |
William Roberts | 81e1f90 | 2015-06-03 21:57:47 -0700 | [diff] [blame] | 101 | # rules are lines beginning with the keyword neverallow. Full support for PCRE |
| 102 | # regular expressions exists on all input and output selectors. Neverallow |
| 103 | # rules are never output to the built seapp_contexts file. Like all keywords, |
| 104 | # neverallows are case-insensitive. A neverallow is asserted when all key value |
| 105 | # inputs are matched on a key value rule line. |
| 106 | # |
| 107 | |
| 108 | # only the system server can be in system_server domain |
| 109 | neverallow isSystemServer=false domain=system_server |
| 110 | neverallow isSystemServer="" domain=system_server |
| 111 | |
| 112 | # system domains should never be assigned outside of system uid |
| 113 | neverallow user=((?!system).)* domain=system_app |
| 114 | neverallow user=((?!system).)* type=system_app_data_file |
| 115 | |
| 116 | # anything with a non-known uid with a specified name should have a specified seinfo |
| 117 | neverallow user=_app name=.* seinfo="" |
| 118 | neverallow user=_app name=.* seinfo=default |
| 119 | |
| 120 | # neverallow shared relro to any other domain |
| 121 | # and neverallow any other uid into shared_relro |
| 122 | neverallow user=shared_relro domain=((?!shared_relro).)* |
| 123 | neverallow user=((?!shared_relro).)* domain=shared_relro |
| 124 | |
| 125 | # neverallow non-isolated uids into isolated_app domain |
| 126 | # and vice versa |
| 127 | neverallow user=_isolated domain=((?!isolated_app).)* |
| 128 | neverallow user=((?!_isolated).)* domain=isolated_app |
| 129 | |
| 130 | # uid shell should always be in shell domain, however non-shell |
| 131 | # uid's can be in shell domain |
| 132 | neverallow user=shell domain=((?!shell).)* |
| 133 | |
Max Bires | 77d41f7 | 2018-01-24 21:17:18 +0000 | [diff] [blame] | 134 | # only the package named com.android.shell can run in the shell domain |
| 135 | neverallow domain=shell name=((?!com\.android\.shell).)* |
| 136 | neverallow user=shell name=((?!com\.android\.shell).)* |
| 137 | |
Chad Brubaker | 06cf31e | 2016-10-06 13:15:44 -0700 | [diff] [blame] | 138 | # Ephemeral Apps must run in the ephemeral_app domain |
| 139 | neverallow isEphemeralApp=true domain=((?!ephemeral_app).)* |
Jeff Vander Stoep | 400d3ac | 2015-10-30 12:43:19 -0700 | [diff] [blame] | 140 | |
Nick Kralevich | caf42d6 | 2018-10-04 10:57:29 -0700 | [diff] [blame] | 141 | isSystemServer=true domain=system_server_startup |
| 142 | |
Max Bires | 4ea5569 | 2017-12-11 16:19:23 -0800 | [diff] [blame] | 143 | user=_app seinfo=platform name=com.android.traceur domain=traceur_app type=app_data_file levelFrom=all |
William Roberts | 92dfa31 | 2014-09-29 10:29:48 -0700 | [diff] [blame] | 144 | user=system seinfo=platform domain=system_app type=system_app_data_file |
| 145 | user=bluetooth seinfo=platform domain=bluetooth type=bluetooth_data_file |
Xiao Ma | c06f0f6 | 2019-03-08 12:33:03 +0900 | [diff] [blame] | 146 | user=network_stack seinfo=network_stack domain=network_stack levelFrom=all type=radio_data_file |
William Roberts | 92dfa31 | 2014-09-29 10:29:48 -0700 | [diff] [blame] | 147 | user=nfc seinfo=platform domain=nfc type=nfc_data_file |
Ruchi Kandoi | 8a2b4a7 | 2018-01-04 10:33:20 -0800 | [diff] [blame] | 148 | user=secure_element seinfo=platform domain=secure_element levelFrom=all |
William Roberts | 92dfa31 | 2014-09-29 10:29:48 -0700 | [diff] [blame] | 149 | user=radio seinfo=platform domain=radio type=radio_data_file |
Nick Kralevich | b5ffbb7 | 2015-01-07 13:52:43 -0800 | [diff] [blame] | 150 | user=shared_relro domain=shared_relro |
Max Bires | 77d41f7 | 2018-01-24 21:17:18 +0000 | [diff] [blame] | 151 | user=shell seinfo=platform domain=shell name=com.android.shell type=shell_data_file |
Robert Sesek | bacb19b | 2018-01-30 10:54:33 -0500 | [diff] [blame] | 152 | user=webview_zygote seinfo=webview_zygote domain=webview_zygote |
Jeff Vander Stoep | 6231b4d | 2017-12-17 20:55:12 -0800 | [diff] [blame] | 153 | user=_isolated domain=isolated_app levelFrom=all |
Martijn Coenen | 1bbda7e | 2018-11-05 11:39:15 +0100 | [diff] [blame] | 154 | user=_app seinfo=app_zygote domain=app_zygote levelFrom=all |
Jerry Zhang | 9f152d9 | 2017-04-10 16:57:48 -0700 | [diff] [blame] | 155 | user=_app seinfo=media domain=mediaprovider name=android.process.media type=app_data_file levelFrom=user |
Stephen Smalley | a833763 | 2014-09-11 14:07:28 -0400 | [diff] [blame] | 156 | user=_app seinfo=platform domain=platform_app type=app_data_file levelFrom=user |
Nick Kralevich | 795add5 | 2019-04-16 15:56:33 -0700 | [diff] [blame] | 157 | user=_app isEphemeralApp=true domain=ephemeral_app type=app_data_file levelFrom=all |
Nick Kralevich | 5d17551 | 2018-09-12 12:30:32 -0700 | [diff] [blame] | 158 | user=_app isPrivApp=true domain=priv_app type=privapp_data_file levelFrom=user |
Yabin Cui | 5dc2c8c | 2018-11-02 11:12:43 -0700 | [diff] [blame] | 159 | user=_app minTargetSdkVersion=29 domain=untrusted_app type=app_data_file levelFrom=all |
| 160 | user=_app minTargetSdkVersion=28 domain=untrusted_app_27 type=app_data_file levelFrom=all |
Jeff Vander Stoep | 6231b4d | 2017-12-17 20:55:12 -0800 | [diff] [blame] | 161 | user=_app minTargetSdkVersion=26 domain=untrusted_app_27 type=app_data_file levelFrom=user |
Jeff Vander Stoep | bacb6d7 | 2017-02-13 13:33:27 -0800 | [diff] [blame] | 162 | user=_app domain=untrusted_app_25 type=app_data_file levelFrom=user |
Yabin Cui | 770a4f6 | 2019-01-07 16:37:24 -0800 | [diff] [blame] | 163 | user=_app minTargetSdkVersion=28 fromRunAs=true domain=runas_app levelFrom=all |
| 164 | user=_app fromRunAs=true domain=runas_app levelFrom=user |