Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 4111b91

Browse files
improve security
Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent ec9da3a commit 4111b91

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyWebAPI.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ void forceQuitRaw(String error) {
6464
void openNativeModuleDialogRaw(String moduleUrl, String moduleId, String installTitle, String checksum, boolean canInstall) {
6565
if (BuildConfig.DEBUG)
6666
Timber.d("ModuleDialog, downloadUrl: " + AndroidacyUtil.hideToken(moduleUrl) + ", moduleId: " + moduleId + ", installTitle: " + installTitle + ", checksum: " + checksum + ", canInstall: " + canInstall);
67+
// moduleUrl should be a valid URL, i.e. in the androidacy.com domain
68+
// if it is not, do not proceed
69+
if (!AndroidacyUtil.isAndroidacyFileUrl(moduleUrl)) {
70+
Timber.e("ModuleDialog, invalid URL: %s", moduleUrl);
71+
return;
72+
}
6773
this.downloadMode = false;
6874
RepoModule repoModule = AndroidacyRepoData.getInstance().moduleHashMap.get(installTitle);
6975
String title, description;
@@ -381,8 +387,10 @@ public boolean isAndroidacyModule(String moduleId) {
381387
*/
382388
@JavascriptInterface
383389
public String getAndroidacyModuleFile(String moduleId, String moduleFile) {
390+
moduleId = moduleId.replaceAll("\\.", "").replaceAll("/", "");
384391
if (moduleFile == null || this.consumedAction || !this.isAndroidacyModule(moduleId))
385392
return "";
393+
moduleFile = moduleFile.replaceAll("\\.", "").replaceAll("/", "");
386394
File moduleFolder = new File("/data/adb/modules/" + moduleId);
387395
File absModuleFile = new File(moduleFolder, moduleFile).getAbsoluteFile();
388396
if (!absModuleFile.getPath().startsWith(moduleFolder.getPath()))
@@ -401,6 +409,7 @@ public String getAndroidacyModuleFile(String moduleId, String moduleFile) {
401409
*/
402410
@JavascriptInterface
403411
public boolean setAndroidacyModuleMeta(String moduleId, String content) {
412+
moduleId = moduleId.replaceAll("\\.", "").replaceAll("/", "");
404413
if (content == null || this.consumedAction || !this.isAndroidacyModule(moduleId))
405414
return false;
406415
File androidacyMetaFile = new File("/data/adb/modules/" + moduleId + "/.androidacy");

app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,7 @@ public void updateCustomRepoList(boolean initial) {
12861286
builder.setView(input);
12871287
builder.setPositiveButton("OK", (dialog, which) -> {
12881288
String text = String.valueOf(input.getText());
1289+
text = text.trim();
12891290
// string should not be empty, start with https://, and not contain any spaces. http links are not allowed.
12901291
if (text.matches("^https://.*") && !text.contains(" ") && !text.isEmpty()) {
12911292
if (customRepoManager.canAddRepo(text)) {

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ buildscript {
2020

2121
// NOTE: Do not place your application dependencies here; they belong
2222
// in the individual module build.gradle files
23-
//noinspection GradleDependency
2423
classpath("io.realm:realm-gradle-plugin:10.15.1")
2524
classpath("io.sentry:sentry-android-gradle-plugin:3.5.0")
2625
}

0 commit comments

Comments
 (0)