Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Fix / Security - remove old Content Provider
Browse files Browse the repository at this point in the history
Remove obsolete and buggy ContentProvider which could allow a malicious local app to compromise account data
  • Loading branch information
BillCarsonFr committed May 3, 2019
1 parent ff63603 commit 096dfbe
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 155 deletions.
14 changes: 11 additions & 3 deletions CHANGES.rst
@@ -1,23 +1,31 @@
Changes in Riot 0.9.00 (2019-XX-XX) Changes in Riot 0.9.00 (2019-04-23)
=================================================== ===================================================


/!\ This version is the first version published with app id "im.vector.app". /!\ This version is the first version published with app id "im.vector.app".




Changes in Riot 0.8.99 (2019-04-23)
===================================================

/!\ This version is the last version published with app id "im.vector.alpha". It contains a screen which introduce the new application "im.vector.app"
/!\ This release contains security related bugfixes, users should upgrade asap

MatrixSdk: MatrixSdk:
- Upgrade MatrixSdk to version 0.9.21. - Upgrade MatrixSdk to version 0.9.22.
- Changelog: https://github.com/matrix-org/matrix-android-sdk/releases/tag/v0.9.21 - Changelog: https://github.com/matrix-org/matrix-android-sdk/releases/tag/v0.9.22


Other changes: Other changes:
- Remove Amplitude tracker and Calendars permissions added by Jitsi lib (jitsi/jitsi-meet#4068, jitsi/jitsi-meet#4080) - Remove Amplitude tracker and Calendars permissions added by Jitsi lib (jitsi/jitsi-meet#4068, jitsi/jitsi-meet#4080)
- Exclude code of Firebase analytics (#2481) - Exclude code of Firebase analytics (#2481)


Bugfix: Bugfix:
- Fix / Illegal States exceptions when starting event stream service X - Fix / Illegal States exceptions when starting event stream service X
- Security Fix / Remove obsolete and buggy ContentProvider which could allow a malicious local app to compromise account data. Many thanks to Julien Thomas (twitter.com/@julien_thomas) from Protektoid Project (https://protektoid.com) for identifying this and responsibly disclosing it!


Build: Build:
- Exclude Firebase analytics code (#2481) - Exclude Firebase analytics code (#2481)



Changes in Riot 0.8.29 (2019-04-04) Changes in Riot 0.8.29 (2019-04-04)
=================================================== ===================================================


Expand Down
Binary file modified vector/libs/matrix-sdk.aar
Binary file not shown.
7 changes: 1 addition & 6 deletions vector/src/main/AndroidManifest.xml
Expand Up @@ -539,12 +539,7 @@
<service <service
android:name=".services.CallService" android:name=".services.CallService"
android:exported="false" /> android:exported="false" />


<provider
android:name=".db.VectorContentProvider"
android:authorities="${applicationId}.VectorApp.provider"
android:exported="true" />

</application> </application>


</manifest> </manifest>
Expand Up @@ -20,6 +20,7 @@
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.content.FileProvider;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
Expand All @@ -39,11 +40,11 @@
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;


import im.vector.BuildConfig;
import im.vector.Matrix; import im.vector.Matrix;
import im.vector.R; import im.vector.R;
import im.vector.VectorApp; import im.vector.VectorApp;
import im.vector.adapters.VectorMediaViewerAdapter; import im.vector.adapters.VectorMediaViewerAdapter;
import im.vector.db.VectorContentProvider;
import im.vector.util.PermissionsToolsKt; import im.vector.util.PermissionsToolsKt;
import im.vector.util.SlidableMediaInfo; import im.vector.util.SlidableMediaInfo;


Expand Down Expand Up @@ -265,14 +266,16 @@ public void onSuccess(String savedMediaPath) {
// shared / forward // shared / forward
Uri mediaUri = null; Uri mediaUri = null;
try { try {
mediaUri = VectorContentProvider.absolutePathToUri(VectorMediaViewerActivity.this, file.getAbsolutePath()); mediaUri = FileProvider.getUriForFile(VectorMediaViewerActivity.this, BuildConfig.APPLICATION_ID + ".fileProvider", file);
} catch (Exception e) { } catch (Exception e) {
Log.e(LOG_TAG, "onMediaAction onAction.absolutePathToUri: " + e.getMessage(), e); Log.e(LOG_TAG, "onMediaAction Selected File cannot be shared " + e.getMessage(), e);
} }


if (null != mediaUri) { if (null != mediaUri) {
try { try {
final Intent sendIntent = new Intent(); final Intent sendIntent = new Intent();
// Grant temporary read permission to the content URI
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType(mediaInfo.mMimeType); sendIntent.setType(mediaInfo.mMimeType);
sendIntent.putExtra(Intent.EXTRA_STREAM, mediaUri); sendIntent.putExtra(Intent.EXTRA_STREAM, mediaUri);
Expand Down
140 changes: 0 additions & 140 deletions vector/src/main/java/im/vector/db/VectorContentProvider.java

This file was deleted.

Expand Up @@ -27,6 +27,7 @@
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
Expand Down Expand Up @@ -74,6 +75,7 @@
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;


import im.vector.BuildConfig;
import im.vector.Matrix; import im.vector.Matrix;
import im.vector.R; import im.vector.R;
import im.vector.activity.CommonActivityUtils; import im.vector.activity.CommonActivityUtils;
Expand All @@ -83,7 +85,6 @@
import im.vector.activity.VectorMemberDetailsActivity; import im.vector.activity.VectorMemberDetailsActivity;
import im.vector.activity.VectorRoomActivity; import im.vector.activity.VectorRoomActivity;
import im.vector.adapters.VectorMessagesAdapter; import im.vector.adapters.VectorMessagesAdapter;
import im.vector.db.VectorContentProvider;
import im.vector.extensions.MatrixSdkExtensionsKt; import im.vector.extensions.MatrixSdkExtensionsKt;
import im.vector.listeners.IMessagesAdapterActionsListener; import im.vector.listeners.IMessagesAdapterActionsListener;
import im.vector.listeners.YesNoListener; import im.vector.listeners.YesNoListener;
Expand Down Expand Up @@ -868,19 +869,22 @@ public void onSuccess(String savedMediaPath) {
} else { } else {
// Move the file to the Share folder, to avoid it to be deleted because the Activity will be paused while the // Move the file to the Share folder, to avoid it to be deleted because the Activity will be paused while the
// user select an application to share the file // user select an application to share the file
// only files in this folder can be shared with external apps, with temporary read access
file = mediasCache.moveToShareFolder(file, trimmedFileName); file = mediasCache.moveToShareFolder(file, trimmedFileName);


// shared / forward // shared / forward
Uri mediaUri = null; Uri mediaUri = null;
try { try {
mediaUri = VectorContentProvider.absolutePathToUri(getActivity(), file.getAbsolutePath()); mediaUri = FileProvider.getUriForFile(getActivity(), BuildConfig.APPLICATION_ID + ".fileProvider", file);
} catch (Exception e) { } catch (Exception e) {
Log.e(LOG_TAG, "onMediaAction VectorContentProvider.absolutePathToUri: " + e.getMessage(), e); Log.e(LOG_TAG, "onMediaAction Selected File cannot be shared " + e.getMessage(), e);
} }


if (null != mediaUri) { if (null != mediaUri) {
final Intent sendIntent = new Intent(); final Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setAction(Intent.ACTION_SEND);
// Grant temporary read permission to the content URI
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sendIntent.setType(mediaMimeType); sendIntent.setType(mediaMimeType);
sendIntent.putExtra(Intent.EXTRA_STREAM, mediaUri); sendIntent.putExtra(Intent.EXTRA_STREAM, mediaUri);


Expand Down
3 changes: 3 additions & 0 deletions vector/src/main/res/xml/vector_provider_paths.xml
Expand Up @@ -3,4 +3,7 @@
<external-path <external-path
name="external_files" name="external_files"
path="." /> path="." />
<files-path
name="shared"
path="ext_share" />
</paths> </paths>

0 comments on commit 096dfbe

Please sign in to comment.