Skip to content

Commit

Permalink
Handle zip traversal vulnerability MobileChromeApps#92
Browse files Browse the repository at this point in the history
  • Loading branch information
remoorejr committed Feb 12, 2022
1 parent 977b57d commit ab9ff92
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/android/Zip.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ private void unzipSync(CordovaArgs args, CallbackContext callbackContext) {
dir.mkdirs();
} else {
File file = new File(outputDirectory + compressedName);
String canonicalPath = file.getCanonicalPath();
if (!canonicalPath.startsWith(outputDirectory)) {
String errorMessage = "Zip traversal security error";
callbackContext.error(errorMessage);
Log.e(LOG_TAG, errorMessage);
return;
}
file.getParentFile().mkdirs();
if(file.exists() || file.createNewFile()){
Log.w("Zip", "extracting: " + file.getPath());
Expand Down

0 comments on commit ab9ff92

Please sign in to comment.