Merge "Fix vulnerability in AttributionSource due to incorrect Binder call" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
accb88c894
@@ -30,6 +30,7 @@ import android.os.Parcelable;
|
|||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.permission.PermissionManager;
|
import android.permission.PermissionManager;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.annotations.Immutable;
|
import com.android.internal.annotations.Immutable;
|
||||||
|
|
||||||
@@ -86,6 +87,8 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
@Immutable
|
@Immutable
|
||||||
public final class AttributionSource implements Parcelable {
|
public final class AttributionSource implements Parcelable {
|
||||||
|
private static final String TAG = "AttributionSource";
|
||||||
|
|
||||||
private static final String DESCRIPTOR = "android.content.AttributionSource";
|
private static final String DESCRIPTOR = "android.content.AttributionSource";
|
||||||
|
|
||||||
private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
|
private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
|
||||||
@@ -153,9 +156,20 @@ public final class AttributionSource implements Parcelable {
|
|||||||
AttributionSource(@NonNull Parcel in) {
|
AttributionSource(@NonNull Parcel in) {
|
||||||
this(AttributionSourceState.CREATOR.createFromParcel(in));
|
this(AttributionSourceState.CREATOR.createFromParcel(in));
|
||||||
|
|
||||||
// Since we just unpacked this object as part of it transiting a Binder
|
if (!Binder.isHandlingTransaction()) {
|
||||||
// call, this is the perfect time to enforce that its UID and PID can be trusted
|
Log.e(TAG, "Unable to verify calling UID #" + mAttributionSourceState.uid + " PID #"
|
||||||
enforceCallingUidAndPid();
|
+ 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 */
|
/** @hide */
|
||||||
|
|||||||
Reference in New Issue
Block a user