Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify package name before initializing ACRA and ErrorActivity #2649

Draft
wants to merge 2 commits into
base: hotfix/3.6.2
Choose a base branch
from

Conversation

TranceLove
Copy link
Collaborator

Implementation is a bit primitive, and given the source code is publicly available, we can only slow down, but not prohibiting others from pirating without a decent code signing mechanism that will work across github, f-droid and derivatives, and google play.

Description

Issue tracker

Fixes #2641

Manual tests

  • Done

  • Device: Pixel 2 emulator

  • OS: Android 11

that ErrorActivity will immediately finish() if app package name doesn't start with our designated bundle ID.

Build tasks success

Successfully running following tasks on local:

  • ./gradlew assembledebug
  • ./gradlew spotlessCheck

Fixes #2641.

Implementation is a bit primitive, and given the source code is publicly available, we can only slow down, but not prohibiting others from pirating without a decent code signing mechanism that will work across github, f-droid and derivatives, and google play.
@TranceLove TranceLove added Issue-Bug Related unexpected behavior or something worth investigating. Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. labels Jun 20, 2021
@EmmanuelMess
Copy link
Member

Implementation is a bit primitive, and given the source code is publicly available, we can only slow down, but not prohibiting others from pirating without a decent code signing mechanism that will work across github, f-droid and derivatives, and google play.

Protection via obfuscation would be ideal here.

@@ -109,7 +109,9 @@ public void onCreate() {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
initACRA();
if (base.getPackageName().equals(BuildConfig.APPLICATION_ID)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't build config generated on compile?

@@ -149,6 +151,7 @@ public static void reportError(
final String[] el = new String[] {report.getString(ReportField.STACK_TRACE)};

final Intent intent = new Intent(context, ErrorActivity.class);
intent.setPackage("context.getPackageName()");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you forget to delete the quotes?

if (errorInfo.message != 0) {
errorMessageView.setText(errorInfo.message);
if (ErrorInfo.comparePackageInfo(intent.getPackage()) != 0) {
finish();
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No else needed AFAIK.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least a return to get out of there would make me feel more safe ;)

Copy link
Member

@EmmanuelMess EmmanuelMess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

@TranceLove
Copy link
Collaborator Author

@EmmanuelMess Surely do.

I found this for encrypting strings, but it also noted degrading performance if too many strings are encrypted. Possibly some code reviews required before proceeding.
https://github.com/christopherney/Enigma

@TranceLove
Copy link
Collaborator Author

@TranceLove But also, since other peiple can have full access to source code, it seems code signing shall be the more appropriate method.

@TranceLove TranceLove changed the base branch from release/3.7 to hotfix/3.6.2 June 26, 2021 15:16
@@ -496,5 +502,9 @@ public void writeToParcel(final Parcel dest, final int flags) {
dest.writeString(this.request);
dest.writeInt(this.message);
}

public static int comparePackageInfo(String packageName) {
return packageName.indexOf("com.amaze.filemanager");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this going to work on debug package?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"com.amaze.filemanager.debug".indexOf("com.amaze.filemanager") == 0

EmmanuelMess
EmmanuelMess previously approved these changes Jun 27, 2021
@TranceLove TranceLove marked this pull request as draft June 27, 2021 23:33
- Rewrote the validation routine with Umbrella ;)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Issue-Bug Related unexpected behavior or something worth investigating.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Restrict crash reporting to amaze package name
3 participants