Merge "Fix vulnerability in AttributionSource due to incorrect Binder call" into sc-dev am: accb88c894
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21780041 Change-Id: I2cc31e4e246010022738e68ada1aceb175d803a4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -30,6 +30,7 @@ import android.os.Parcelable;
|
||||
import android.os.Process;
|
||||
import android.permission.PermissionManager;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.Immutable;
|
||||
|
||||
@@ -86,6 +87,8 @@ import java.util.Set;
|
||||
*/
|
||||
@Immutable
|
||||
public final class AttributionSource implements Parcelable {
|
||||
private static final String TAG = "AttributionSource";
|
||||
|
||||
private static final String DESCRIPTOR = "android.content.AttributionSource";
|
||||
|
||||
private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
|
||||
@@ -153,9 +156,20 @@ public final class AttributionSource implements Parcelable {
|
||||
AttributionSource(@NonNull Parcel in) {
|
||||
this(AttributionSourceState.CREATOR.createFromParcel(in));
|
||||
|
||||
// Since we just unpacked this object as part of it transiting a Binder
|
||||
// call, this is the perfect time to enforce that its UID and PID can be trusted
|
||||
enforceCallingUidAndPid();
|
||||
if (!Binder.isHandlingTransaction()) {
|
||||
Log.e(TAG, "Unable to verify calling UID #" + mAttributionSourceState.uid + " PID #"
|
||||
+ mAttributionSourceState.pid + " when not handling Binder transaction; "
|
||||
+ "clearing.");
|
||||
mAttributionSourceState.pid = -1;
|
||||
mAttributionSourceState.uid = -1;
|
||||
mAttributionSourceState.packageName = null;
|
||||
mAttributionSourceState.attributionTag = null;
|
||||
mAttributionSourceState.next = null;
|
||||
} else {
|
||||
// Since we just unpacked this object as part of it transiting a Binder
|
||||
// call, this is the perfect time to enforce that its UID and PID can be trusted
|
||||
enforceCallingUidAndPid();
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
|
||||
Reference in New Issue
Block a user