32807795 Security Vulnerability - AOSP Messaging App: thirdparty can attach private files from "/data/data/com.android.messaging/" directory to the messaging app. am: a2aa53f83a am: 90bf70396d am: 305a004e19 am: 2397f2fbef am: 313284eee7
am: 4dfcff98da
Change-Id: I0e6378adbd3c2d0b518cfe9f81e6c91abb6b85d4
This commit is contained in:
+4
-2
@@ -317,11 +317,13 @@
|
|||||||
|
|
||||||
<provider android:name=".datamodel.MmsFileProvider"
|
<provider android:name=".datamodel.MmsFileProvider"
|
||||||
android:authorities="com.android.messaging.datamodel.MmsFileProvider"
|
android:authorities="com.android.messaging.datamodel.MmsFileProvider"
|
||||||
android:grantUriPermissions="true" />
|
android:grantUriPermissions="true"
|
||||||
|
android:exported="false" />
|
||||||
|
|
||||||
<provider android:name=".datamodel.MediaScratchFileProvider"
|
<provider android:name=".datamodel.MediaScratchFileProvider"
|
||||||
android:authorities="com.android.messaging.datamodel.MediaScratchFileProvider"
|
android:authorities="com.android.messaging.datamodel.MediaScratchFileProvider"
|
||||||
android:grantUriPermissions="true" />
|
android:grantUriPermissions="true"
|
||||||
|
android:exported="false" />
|
||||||
|
|
||||||
|
|
||||||
<!-- Action Services -->
|
<!-- Action Services -->
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import com.android.messaging.util.LogUtil;
|
|||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,8 +90,23 @@ public class MediaScratchFileProvider extends FileProvider {
|
|||||||
|
|
||||||
private static File getFileWithExtension(final String path, final String extension) {
|
private static File getFileWithExtension(final String path, final String extension) {
|
||||||
final Context context = Factory.get().getApplicationContext();
|
final Context context = Factory.get().getApplicationContext();
|
||||||
return new File(getDirectory(context),
|
final File filePath = new File(getDirectory(context),
|
||||||
TextUtils.isEmpty(extension) ? path : path + "." + extension);
|
TextUtils.isEmpty(extension) ? path : path + "." + extension);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!filePath.getCanonicalPath()
|
||||||
|
.startsWith(getDirectory(context).getCanonicalPath())) {
|
||||||
|
LogUtil.e(TAG, "getFileWithExtension: path "
|
||||||
|
+ filePath.getCanonicalPath()
|
||||||
|
+ " does not start with "
|
||||||
|
+ getDirectory(context).getCanonicalPath());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogUtil.e(TAG, "getFileWithExtension: getCanonicalPath failed ", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File getDirectory(final Context context) {
|
private static File getDirectory(final Context context) {
|
||||||
|
|||||||
@@ -18,12 +18,14 @@ package com.android.messaging.datamodel;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.messaging.Factory;
|
import com.android.messaging.Factory;
|
||||||
import com.android.messaging.util.LogUtil;
|
import com.android.messaging.util.LogUtil;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A very simple content provider that can serve mms files from our cache directory.
|
* A very simple content provider that can serve mms files from our cache directory.
|
||||||
@@ -60,7 +62,22 @@ public class MmsFileProvider extends FileProvider {
|
|||||||
|
|
||||||
private static File getFile(final String path) {
|
private static File getFile(final String path) {
|
||||||
final Context context = Factory.get().getApplicationContext();
|
final Context context = Factory.get().getApplicationContext();
|
||||||
return new File(getDirectory(context), path + ".dat");
|
final File filePath = new File(getDirectory(context), path + ".dat");
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!filePath.getCanonicalPath()
|
||||||
|
.startsWith(getDirectory(context).getCanonicalPath())) {
|
||||||
|
LogUtil.e(TAG, "getFile: path "
|
||||||
|
+ filePath.getCanonicalPath()
|
||||||
|
+ " does not start with "
|
||||||
|
+ getDirectory(context).getCanonicalPath());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogUtil.e(TAG, "getFile: getCanonicalPath failed ", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File getDirectory(final Context context) {
|
private static File getDirectory(final Context context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user