Skip to content

Commit 4ae2e43

Browse files
Pranav MadapurmathAndroid Build Coastguard Worker
authored andcommitted
Merge "Resolve StatusHints image exploit across user." into sc-v2-dev am: e371b3018f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23465066 Fixes: 285211549 Fixes: 280797684 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:3fc6dd50937d23c854fde540380c51fd451b1c55) Merged-In: Idd360f69fc9e5a9f32fd3ca76ec0440c8bb12cf4 Change-Id: Idd360f69fc9e5a9f32fd3ca76ec0440c8bb12cf4
1 parent cc11391 commit 4ae2e43

2 files changed

Lines changed: 61 additions & 4 deletions

File tree

telecomm/java/android/telecom/ParcelableConference.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
import android.os.Parcel;
2222
import android.os.Parcelable;
2323

24+
import com.android.internal.telecom.IVideoProvider;
25+
2426
import java.util.ArrayList;
2527
import java.util.Collections;
2628
import java.util.List;
2729

28-
import com.android.internal.telecom.IVideoProvider;
29-
3030
/**
3131
* A parcelable representation of a conference connection.
3232
* @hide
@@ -287,6 +287,14 @@ public int getCallDirection() {
287287
return mCallDirection;
288288
}
289289

290+
public String getCallerDisplayName() {
291+
return mCallerDisplayName;
292+
}
293+
294+
public int getCallerDisplayNamePresentation() {
295+
return mCallerDisplayNamePresentation;
296+
}
297+
290298
public static final @android.annotation.NonNull Parcelable.Creator<ParcelableConference> CREATOR =
291299
new Parcelable.Creator<ParcelableConference> () {
292300
@Override

telecomm/java/android/telecom/StatusHints.java

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@
1616

1717
package android.telecom;
1818

19+
import android.annotation.Nullable;
1920
import android.annotation.SystemApi;
2021
import android.content.ComponentName;
2122
import android.content.Context;
2223
import android.graphics.drawable.Drawable;
2324
import android.graphics.drawable.Icon;
25+
import android.os.Binder;
2426
import android.os.Bundle;
2527
import android.os.Parcel;
2628
import android.os.Parcelable;
29+
import android.os.UserHandle;
30+
31+
import com.android.internal.annotations.VisibleForTesting;
2732

2833
import java.util.Objects;
2934

@@ -33,7 +38,7 @@
3338
public final class StatusHints implements Parcelable {
3439

3540
private final CharSequence mLabel;
36-
private final Icon mIcon;
41+
private Icon mIcon;
3742
private final Bundle mExtras;
3843

3944
/**
@@ -48,10 +53,30 @@ public StatusHints(ComponentName packageName, CharSequence label, int iconResId,
4853

4954
public StatusHints(CharSequence label, Icon icon, Bundle extras) {
5055
mLabel = label;
51-
mIcon = icon;
56+
mIcon = validateAccountIconUserBoundary(icon, Binder.getCallingUserHandle());
5257
mExtras = extras;
5358
}
5459

60+
/**
61+
* @param icon
62+
* @hide
63+
*/
64+
@VisibleForTesting
65+
public StatusHints(@Nullable Icon icon) {
66+
mLabel = null;
67+
mExtras = null;
68+
mIcon = icon;
69+
}
70+
71+
/**
72+
*
73+
* @param icon
74+
* @hide
75+
*/
76+
public void setIcon(@Nullable Icon icon) {
77+
mIcon = icon;
78+
}
79+
5580
/**
5681
* @return A package used to load the icon.
5782
*
@@ -112,6 +137,30 @@ public int describeContents() {
112137
return 0;
113138
}
114139

140+
/**
141+
* Validates the StatusHints image icon to see if it's not in the calling user space.
142+
* Invalidates the icon if so, otherwise returns back the original icon.
143+
*
144+
* @param icon
145+
* @return icon (validated)
146+
* @hide
147+
*/
148+
public static Icon validateAccountIconUserBoundary(Icon icon, UserHandle callingUserHandle) {
149+
// Refer to Icon#getUriString for context. The URI string is invalid for icons of
150+
// incompatible types.
151+
if (icon != null && (icon.getType() == Icon.TYPE_URI
152+
|| icon.getType() == Icon.TYPE_URI_ADAPTIVE_BITMAP)) {
153+
String encodedUser = icon.getUri().getEncodedUserInfo();
154+
// If there is no encoded user, the URI is calling into the calling user space
155+
if (encodedUser != null) {
156+
int userId = Integer.parseInt(encodedUser);
157+
// Do not try to save the icon if the user id isn't in the calling user space.
158+
if (userId != callingUserHandle.getIdentifier()) return null;
159+
}
160+
}
161+
return icon;
162+
}
163+
115164
@Override
116165
public void writeToParcel(Parcel out, int flags) {
117166
out.writeCharSequence(mLabel);

0 commit comments

Comments
 (0)