32161610 Security Vulnerability - Information disclosure vulnerability in AOSP Messaging am: 69ed579fb8 am: 10dccb12ad

am: a21b8f936e

Change-Id: I5198e8db836d97da6aa05e56958a667af9388076
This commit is contained in:
Tom Taylor
2016-12-06 22:20:14 +00:00
committed by android-build-merger
2 changed files with 25 additions and 0 deletions

View File

@@ -24,8 +24,13 @@ import android.os.Bundle;
import com.android.messaging.Factory; import com.android.messaging.Factory;
import com.android.messaging.datamodel.data.PendingAttachmentData; import com.android.messaging.datamodel.data.PendingAttachmentData;
import com.android.messaging.ui.UIIntents; import com.android.messaging.ui.UIIntents;
import com.android.messaging.util.LogUtil;
import com.android.messaging.util.FileUtil;
import com.android.messaging.util.ImageUtils; import com.android.messaging.util.ImageUtils;
import com.android.messaging.util.SafeAsyncTask; import com.android.messaging.util.SafeAsyncTask;
import com.android.messaging.util.UriUtil;
import java.io.File;
/** /**
* Wraps around the functionalities to allow the user to pick images from the document * Wraps around the functionalities to allow the user to pick images from the document
@@ -111,12 +116,24 @@ public class DocumentImagePicker {
new SafeAsyncTask<Void, Void, String>() { new SafeAsyncTask<Void, Void, String>() {
@Override @Override
protected String doInBackgroundTimed(final Void... params) { protected String doInBackgroundTimed(final Void... params) {
if (UriUtil.isFileUri(documentUri) &&
FileUtil.isInDataDir(new File(documentUri.getPath()))) {
// hacker sending private app data. Bail out
if (LogUtil.isLoggable(LogUtil.BUGLE_TAG, LogUtil.ERROR)) {
LogUtil.e(LogUtil.BUGLE_TAG, "Aborting attach of private app data ("
+ documentUri + ")");
}
return null;
}
return ImageUtils.getContentType( return ImageUtils.getContentType(
Factory.get().getApplicationContext().getContentResolver(), documentUri); Factory.get().getApplicationContext().getContentResolver(), documentUri);
} }
@Override @Override
protected void onPostExecute(final String contentType) { protected void onPostExecute(final String contentType) {
if (contentType == null) {
return; // bad uri on input
}
// Ask the listener to create a temporary placeholder item to show the progress. // Ask the listener to create a temporary placeholder item to show the progress.
final PendingAttachmentData pendingItem = final PendingAttachmentData pendingItem =
PendingAttachmentData.createPendingAttachmentData(contentType, PendingAttachmentData.createPendingAttachmentData(contentType,

View File

@@ -17,6 +17,7 @@
package com.android.messaging.util; package com.android.messaging.util;
import android.content.Context; import android.content.Context;
import android.os.Environment;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import com.android.messaging.Factory; import com.android.messaging.Factory;
@@ -116,6 +117,13 @@ public class FileUtil {
} }
} }
// Checks if the file is in /data, and don't allow any app to send personal information.
// We're told it's possible to create world readable hardlinks to other apps private data
// so we ban all /data file uris. b/28793303
public static boolean isInDataDir(File file) {
return isSameOrSubDirectory(Environment.getDataDirectory(), file);
}
/** /**
* Checks, whether the child directory is the same as, or a sub-directory of the base * Checks, whether the child directory is the same as, or a sub-directory of the base
* directory. * directory.