Commit Graph

9349 Commits

Author SHA1 Message Date
Rhed Jao
b0b1ddb4b4 [RESTRICT AUTOMERGE] Fix bypass BG-FGS and BAL via package manager APIs
Opt-in for BAL of PendingIntent for following APIs:

* PackageInstaller.uninstall()
* PackageInstaller.installExistingPackage()
* PackageInstaller.uninstallExistingPackage()
* PackageInstaller.Session.commit()
* PackageInstaller.Session.commitTransferred()
* PackageManager.freeStorage()

Bug: 230492955
Bug: 243377226
Test: atest android.security.cts.PackageInstallerTest
Test: atest CtsStagedInstallHostTestCases
Change-Id: I9b6f801d69ea6d2244a38dbe689e81afa4e798bf
2023-01-17 19:20:43 +08:00
Winson Chiu
43437b4ee6 Encode Intent scheme when serializing to URI string RESTRICT AUTOMERGE
Avoids deserialization error when the scheme contains a
reserved character.

Bug: 261858325

Test: atest android.content.cts.IntentTest#testEncoding

Merged-In: Ic34b3f796b762763db5aa7b5d7c109ae70607470
Change-Id: Ic34b3f796b762763db5aa7b5d7c109ae70607470
2023-01-09 19:09:32 +00:00
William Loh
3ae3406b97 Limit length and number of MIME types you can set
Limit character length of MIME types to 255. If this length is exceeded
then a IllegalArugmentException is thrown. The number of MIME types that
can be set is also limited to 500 per MIME group with the number of
total MIME Groups also limited to 500. A IllegalStateException is thrown if this number is exceeded.

Bug: 237291548
Test: Installed and ran POC app from b/237291548
Change-Id: I1d57e674f778cfacdc89225ac3273c432a39af63
Merged-In: I1d57e674f778cfacdc89225ac3273c432a39af63
2022-10-11 01:50:25 +00:00
Manjeet Rulhania
bbe2a11827 Remove package name from SafetyNet logs
Bug: 213323615
Test: AppSecurityTests
Change-Id: I993832e148636f1795ffe393c6dc74a08b9442f8
Merged-In: I8f823487ca16861a35135cfc3383fa2ce8258017
Merged-In: I4b61d13256ce0bfb8fc9d21db52ee78ce2097f14
2022-06-30 22:33:32 +00:00
Makoto Onuki
ea69ad5892 Merge "Only allow the system server to connect to sync adapters" into qt-dev am: 99ccb4e5b0 am: 822fbf618b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18701369

Change-Id: I19750ed605001905eee78852893d1b18e8f274bb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-08 19:55:08 +00:00
Makoto Onuki
822fbf618b Merge "Only allow the system server to connect to sync adapters" into qt-dev am: 99ccb4e5b0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18701369

Change-Id: Ie919bc05747a1009507a29de429c3e8d043fed9d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-08 19:20:45 +00:00
Makoto Onuki
7d1397a544 Only allow the system server to connect to sync adapters
Bug: 203229608
Test: Manual test with changing the check logic + debug log
Change-Id: If18009f61360564d02dcda9b1e5fa15685e3250f
(cherry picked from commit 58270527d1)
2022-06-01 20:35:21 +00:00
Manjeet Rulhania
e545a5dbbf Merge "Fix duplicate permission privilege escalation" into qt-dev am: b22a6d7372
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18078651

Change-Id: I0e25a20970648244c2a72581478f5a09ac6c10b4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Merged-In: I1910dca44104e35a57eba4acfa8188cd9b8626ac
Merged-In: I34120fff2ec2a158dfa55779d2afd4bbd49487ff
Merged-In: I9bc839836786a0876e67fd73c05f8944bb532249
2022-05-16 19:49:21 +00:00
Manjeet Rulhania
31bd425bb6 Fix duplicate permission privilege escalation
Duplicate permissions definition with different group allows
privilege permission escalation to a different permission group.

Android studio and gradle plugin does not allow duplicate
permissions with different attributes, these tools only allow
if duplicate permissions are exact copies.

Also platform stores permissions in map at multiple places with
permission name as key. This suggests that we can disallow
duplicate permissions during package install/update.

Bug: 213323615
Test: manual
Change-Id: I6f44e740897305e7a0553c1cf6c3af37faf02a2e
Merged-In: I1910dca44104e35a57eba4acfa8188cd9b8626ac
Merged-In: I34120fff2ec2a158dfa55779d2afd4bbd49487ff
Merged-In: I9bc839836786a0876e67fd73c05f8944bb532249
2022-05-16 02:06:24 +00:00
Manjeet Rulhania
f9a9dc720c Fix duplicate permission privilege escalation
Duplicate permissions definition with different group allows
privilege permission escalation to a different permission group.

Android studio and gradle plugin does not allow duplicate
permissions with different attributes, these tools only allow
if duplicate permissions are exact copies.

Also platform stores permissions in map at multiple places with
permission name as key. This suggests that we can disallow
duplicate permissions during package install/update

Bug: 213323615
Test: AppSecurityTests
Change-Id: I1910dca44104e35a57eba4acfa8188cd9b8626ac
Merged-Id: I34120fff2ec2a158dfa55779d2afd4bbd49487ff
Merged-In: I9bc839836786a0876e67fd73c05f8944bb532249
2022-05-14 03:55:04 +00:00
TreeHugger Robot
972089ad30 Merge "Always restart apps if base.apk gets updated." into qt-dev am: 1adea76f46
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17111536

Change-Id: Ia35c96940c76b46ff5754f493e4f0c64df211483
2022-03-09 06:21:41 +00:00
Alex Buynytskyy
52a4337a47 Always restart apps if base.apk gets updated.
Bug: 219044664
Fixes: 219044664
Test: atest PackageManagerShellCommandTest
Change-Id: I27a0c5009b2d5f1ea51618b9acfa1e6ccee71296
Merged-In: I27a0c5009b2d5f1ea51618b9acfa1e6ccee71296
2022-03-09 00:51:17 +00:00
Alex Buynytskyy
a5dd59db6d Always restart apps if base.apk gets updated.
Bug: 219044664
Fixes: 219044664
Test: atest PackageManagerShellCommandTest
Change-Id: I27a0c5009b2d5f1ea51618b9acfa1e6ccee71296
Merged-In: I27a0c5009b2d5f1ea51618b9acfa1e6ccee71296
2022-03-09 00:48:11 +00:00
Winson
37a0b6de89 Fix parsing code parcelling errors
Address problems reading/writing:
- ParsingPackageImpl mKeySetMapping
- ParsingPackageImpl mQueriesIntent

Bug: 187043377
Bug: 195962697

Test: atest com.android.server.pm.test.parsing.parcelling

Merged-In: I5b33315f8248d5fcbdef2cc04ecf77cc18dbd7b6
Change-Id: I5b33315f8248d5fcbdef2cc04ecf77cc18dbd7b6
(cherry picked from commit f93af7ef7e)
2021-08-16 18:03:08 +00:00
Rhed Jao
6172201637 DO NOT MERGE Apply a maximum char count to the load label api
The system is overwhelmed by an enormous label string returned by
the load label api. This cl truncates the label string if it exceeds
the maximum safe length.

Also update the max safe label length to 1000 characters, which is
enough.

Bug: 67013844
Test: atest PackageManagerTest
Change-Id: Ia4d768cc93a47cfb8b6f7c4b6dc73abd801809bd
Merged-in: Ia4d768cc93a47cfb8b6f7c4b6dc73abd801809bd
2021-08-02 19:44:04 +08:00
Rhed Jao
3c26a24644 DO NOT MERGE Apply a maximum char count to the load label api
The system is overwhelmed by an enormous label string returned by
the load label api. This cl truncates the label string if it exceeds
the maximum safe length.

Bug: 67013844
Test: atest PackageManagerTest
Change-Id: Ia4d768cc93a47cfb8b6f7c4b6dc73abd801809bd
Merged-in: Ia4d768cc93a47cfb8b6f7c4b6dc73abd801809bd
2021-08-02 16:13:21 +08:00
Winson
75214cc510 Remove ParsedIntentInfo CREATOR
Its existence allows implicit readParcelable calls to invoke a Parcel
operation with mismatched read/write data sizes, allowing someone to
swap out the data on a reparcel.

Internal classes will use writeIntentInfoToParcel, so this is safe to
remove.

Bug: 191055353

Test: atest com.android.server.pm.test.parsing.parcelling

Change-Id: I44faa635faf8a77894a3dda8adf89c10064e53f1
2021-06-23 18:04:15 +00:00
Kevin Hufnagle
09478539ae docs: Mention app query filters on Android 11
For apps that target Android 11 and higher, the methods in this class
each return a filtered list by default, because of the new package
visibility behavior.

Test: m ds-docs-java

Bug: 173104139

Exempt-From-Owner-Approval: Docs-only change
Change-Id: Idd239a6a9b4e1764b8285f73a341adc024281be2
2020-12-01 19:02:29 -05:00
Hall Liu
12a3f5cfdc Skip carrier priv check for trusted UIDs
Checking carrier privileges for UIDs with lots of shared apps can incur
a significant performance hit. For UIDs that are fixed and trusted
(system and phone), skip the permission check and always allow.

Also, double the cache size for getPackageInfo in order to reduce the
rate of cache misses.

Bug: 160971853
Test: manual verification -- observed lower rate of cache misses for
getPackageInfo from com.android.phone.

Change-Id: I1399cab579308479d7cf191b8795441cbcd3ff65
2020-07-13 12:45:00 -07:00
Patrick Baumann
a1b6280ec8 Merge "Don't assume host is wildcard if not provided" into rvc-dev 2020-07-09 23:31:56 +00:00
Patrick Baumann
aab67c2b9d Don't assume host is wildcard if not provided
This change ensures that while parsing a package, we require an explicit
wildcard in the queries->intent->data->host field. Prior to this change,
we were defaulting to wildcard when not provided. This resulted in,
e.g. someone trying to get visibility to just browsers actually getting
access to all packages that handle any web intent.

Fixes: 160868841
Test: atest AppEnumerationTests IntentFilterTest
Change-Id: I771845467928b6655fe19efe89bd2ca548dca6e5
2020-07-09 12:28:54 -07:00
Charles Chen
5c25605da0 Merge "Fix NPE when invoking Context#isUiContext" into rvc-dev 2020-07-08 17:46:09 +00:00
Charles Chen
3b8e8d7631 Fix NPE when invoking Context#isUiContext
Add null checks in both ContextWrapper and before obtaining
ContextImpl#getOuterContext.

Test: atest ContextTest#testIsUiContext_ContextWrapper
fixes: 160037462
Change-Id: Ic6a71dd9ac4b195d219d6e5431f2f2b199a400fa
2020-07-08 23:58:58 +08:00
Eugene Susla
aad46b8980 Remove references to undocumented WHITELIST_AUTO_REVOKE_PERMISSIONS from javadoc
Fixes: 160119966
Test: presubmit
Change-Id: If7db38ae7d96441cabab1141e93abf357daf8164
2020-07-06 10:23:25 -07:00
Patrick Baumann
b059bd3947 Do not set referrerUri on SessionInfo for non-owners
This change leaves the referrerUri field null when the caller leading to
its production is not the owner of the session.

Bug: 142125338
Test: atest SessionReferrerUriTest
Merged-In: I84679ea0636aa2097e25e23813c48134c9cc1d75
Change-Id: I84679ea0636aa2097e25e23813c48134c9cc1d75
2020-06-26 16:23:36 +00:00
Patrick Baumann
6ad6ca2dbb Do not set referrerUri on SessionInfo for non-owners
This change leaves the referrerUri field null when the caller leading to
its production is not the owner of the session.

Bug: 142125338
Test: atest SessionReferrerUriTest

Merged-In: I84679ea0636aa2097e25e23813c48134c9cc1d75
Change-Id: I84679ea0636aa2097e25e23813c48134c9cc1d75
2020-06-26 16:22:07 +00:00
TreeHugger Robot
8411d73710 Merge "Update Java doc for FLAG_ACTIVITY_LAUNCH_ADJACENT" into rvc-dev 2020-06-18 16:40:32 +00:00
Michael Groover
67cb3a610d Merge "Relax minimum signature scheme version for apps on system partition" into rvc-dev 2020-06-18 16:13:30 +00:00
jun.h.cho
c3540cc2f9 Update Java doc for FLAG_ACTIVITY_LAUNCH_ADJACENT
The behavior of the adjacent flag is changed. It can be changed to split-screen mode if supported by the system.

Fixes: 155050369
Test: n/a
Change-Id: Ia19e0228442e7c8847d403ee2def841f1c0b712b
2020-06-18 07:55:15 -07:00
Michael Groover
b71e398935 Relax minimum signature scheme version for apps on system partition
Android 11 requires a minimum V2 APK signature for apps targeting SDK
version 30+; however some apps on a system partition can only be signed
with the V1 signature scheme. This commit relaxes the minimum signature
scheme version to allow for these apps on a system partition.

Bug: 158728035
Test: atest PackageManagerTest
Test: atest PackageManagerTests
Test: atest PkgInstallSignatureVerificationTest
Change-Id: I1a95fd6894cc937e00ad1ac54d1846b51b48e9cd
2020-06-17 11:02:18 -07:00
TreeHugger Robot
f40975ee76 Merge "Add tron metrics to track iorap." into rvc-dev 2020-06-16 02:20:26 +00:00
yawanng
35a0090975 Add tron metrics to track iorap.
Bug: 158007508
Test: Make and manually check the log using
"adb logcat -b events | grep sysui_multi_action".
Change-Id: I8365bbaa0abf65bdffd8da9462a2295a5e37b3c2
2020-06-15 17:01:04 +00:00
Alex Buynytskyy
0403545508 Don't provide read logs for shell-initiated installations.
Only if the application is profileable.

Bug: 158238023
Fixes: 158238023
Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest IncrementalServiceTest PackageParserTest
Change-Id: I8575830ec3f29850297fdbfbaa157072d6350a28
Merged-In: I8575830ec3f29850297fdbfbaa157072d6350a28
2020-06-12 13:30:45 -07:00
TreeHugger Robot
0561690cac Merge "Apply theme shape clipping to group convo avatars" into rvc-dev 2020-06-11 18:22:46 +00:00
Steve Elliott
86bc69a491 Apply theme shape clipping to group convo avatars
Fixes: 158493588
Test: manual
Change-Id: I57b5e0712822b345c9dcce74b8a6d6ff33409de6
2020-06-10 15:23:33 -04:00
Winson
6bdadaf0a0 Fix PackagePartitions contains null check
The subfolders can be null depending on the partition.

Bug: 158671002

Test: manual was tested as part of not yet merged
	Ie09ccf4b64a0be26d19c9034a68ca4877ca49b81

Change-Id: Ic3a07867cb50b6b0b0e265e9540c52ee94c68050
2020-06-10 11:07:12 -07:00
TreeHugger Robot
9f15ba2e1a Merge "Fix up discrepancies between v1 and v2 package parsing" into rvc-dev 2020-06-04 18:12:56 +00:00
Eugene Susla
c43f49dfc4 Merge "Deprecate docs for auto revoke manifest and Intent APIs" into rvc-dev 2020-06-04 01:08:10 +00:00
Eugene Susla
c7cae60a64 Deprecate docs for auto revoke manifest and Intent APIs
Test: presubmit
Bug: 153607914
Change-Id: I9c8d0aa1432ca00b729f19749e751cb117374b0a
2020-06-03 13:46:00 -07:00
Winson
10d51880e2 Add PackageInstaller SessionParams restrictions
To mitigate a boot loop with reading a massive
install_sessions.xml file, this restricts the amount of
data that can be written by limiting the size of
unbounded parameters like package name and app label.

This introduces a lowered max session count. 50 for general
applications without the INSTALL_PACKAGES permission, and
the same 1024 for those with the permission.

Also truncates labels read from PackageItemInfo to 1000
characters, which is probably enough.

These changes restrict a malicious third party app to ~0.15 MB
written to disk, and a valid installer to ~3.6 MB, as opposed to
the >1000 MB previously allowed.

These numbers assume no install granted runtime permissions.
Those were not restricted since there's no good way to do so,
but it's assumed that any installer with that permission is
highly privleged and doesn't need to be limited.

Along the same lines, DataLoaderParams are also not restricted.
This will have to be added if that API is ever made public.

However, installer package was restricted, even though the API is
hidden. It was an easy add and may have some effect since the value
is derived from other data and passed through by other system
components.

It's still possible to inflate the file size if a lot of
different apps attempt to install a large number of packages,
but that would require thousands of malicious apps to be installed.

Bug: 157224146

Test: atest android.content.pm.PackageSessionTests

Change-Id: Iec42bee08d19d4ac53b361a92be6bc1401d9efc8
2020-06-02 12:58:53 -07:00
Zimuzo Ezeozue
efbc3f2d5e Merge "Support apps sharing file:// URIs with the camera API" into rvc-dev 2020-06-02 10:45:33 +00:00
Zim
c7496a3a62 Support apps sharing file:// URIs with the camera API
The camera API, MediaStore.ACTION_IMAGE_CAPTURE requires apps to pass
a content:// URI with write permissions to the camera. Unfortunately,
apps haven't been doing this and we only started hitting problems in R
for two reasons:
1. The FileUriExposedException that should crash apps when they try to
share file:// URIs acroos binder is skipped. This is because, the
image_capture intent is passed across binder as a field in a
ChooserActivity Intent and the child intents are not checked for
file URI exposed
2. Prior to R, when camera gets a file:// URI, camera issues a file
open(2) in its process. This open(2) succeeds because the camera had
write_external_storage permission which gave it write access to all
files on external storage

Now, camera targets R and (2) fails because camera does not have write
access to files owned by other apps. To workaround, we do the
following in the apps process when it targets < R:
a. When we detect a file:// URI for the camera in an Intent, we create
the file on disk if it is not already created.
b. Scan the file to insert it in the database and retrieve a
content:// URI
c. Replace the file:// URI with the content URI in the image_capture
intent

This works because, the system will ensure the camera is granted write
access to the content URI.

Test: Manual
Bug: 156336269
Change-Id: I4849ff5e806a8207650ff7534846c36ecdc6d3c0
2020-06-01 20:33:52 +01:00
Winson
69738c7547 Fix up discrepancies between v1 and v2 package parsing
For Activity aliases, it's possible some values are already
set, which means they cannot be assumed to be 0, and can't be
overwritten if a attribute in the alias is undefined. For the
parsing v2 refactor, this was cleaned up to avoid
redundant != 0 checks, but those checks are indeed necessary.
This copies over the old logic and uses it exactly.

In some future cleanup, there should be a more structured way
of doing this, since it's not immediately obvious which values
are overridden or not. For example, description is always
overwritten even if no new value is provided in the alias.

This also fixes up the comparison tests and other bugs that
popped up because of them. The core issue was that when
auto-generating the dumpToString methods, the Alt+Insert
macro default selects all the fields in the current class,
but not all the parent classes, so some shared fields like
name/icon were not considered.

A notable case that was found when running the comparison tests
is that persistableMode is now "fixed" with v2. Previously,
a bug in PackageParser caused this value to be dropped if
the ActivityInfo object ever had to be copied. This is a change
from Q behavior, but there's no good way to reconcile this, and
it's better to be correct and consistent than broken, so this
fix was left in and excluded from the comparison tests.

Bug: 150106908

Test: manual run through steps in bug
Test: atest com.android.server.pm.parsing

Merged-In: I1301e28540314d0e643b73af7146c1a366eca6b5
Change-Id: I1301e28540314d0e643b73af7146c1a366eca6b5
2020-06-01 17:53:18 +00:00
Kwangho Lim
2141f707b7 [wm] Introduce meta-data tag (android.supports_size_changes)
Introduce meta-data tag "android.supports_size_changes" which will indicated that an activity works well with size changes like display changing size.

Test: Manual - Run by adding metadata to the app running with SizeCompatMode.
Bug: 155041354
Change-Id: I0f358f63c9e14c63294275c0bfcd08744bee1108
2020-06-01 08:34:38 -07:00
TreeHugger Robot
e40b321ee6 Merge "Add test for permission APEX." into rvc-dev 2020-05-29 21:40:19 +00:00
Ryan Mitchell
d32418a72a Merge "Install system app in greatest priority partition" into rvc-dev 2020-05-29 18:05:31 +00:00
TreeHugger Robot
d220529254 Merge "Add DPC restriction for INTERACT_ACROSS_PROFILES to javadoc." into rvc-dev 2020-05-29 13:22:27 +00:00
Alex Kershaw
4da9c2097d Add DPC restriction for INTERACT_ACROSS_PROFILES to javadoc.
Fixes: 157229284
Test: Javadoc only
Change-Id: I21f6276ba08e62c1f17a279241838fdbd352c8d8
2020-05-29 12:43:08 +01:00
Hai Zhang
3562068af9 Add test for permission APEX.
Bug: 152055112
Test: atest PermissionApexTests
Change-Id: I4201501d586fe62df7a04d0e2da955d6d873d3df
2020-05-28 16:19:07 -07:00
Ryan Mitchell
d4e7f93df5 Install system app in greatest priority partition
On Pixel 2 devices, /product is a symlink to /system/product. The
product partition has a higher partition precedence than the system
partition so the app should be installed as a system app on the product
partition.

This change also unifies methods for checking whether a file is within
a partition so we will paths will always be canonicalized before the
check.

Bug: 152522330
Test: update system app in system/product/privapp, uninstall updates,
      verify that the app was scanned as privileged
Change-Id: I646a5f293b977a78daa2102b73f1d3122f774a2a
2020-05-28 16:06:30 -07:00