Skip to content

Commit ab9ff92

Browse files
committed
Handle zip traversal vulnerability MobileChromeApps#92
1 parent 977b57d commit ab9ff92

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/android/Zip.java

+7
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ private void unzipSync(CordovaArgs args, CallbackContext callbackContext) {
126126
dir.mkdirs();
127127
} else {
128128
File file = new File(outputDirectory + compressedName);
129+
String canonicalPath = file.getCanonicalPath();
130+
if (!canonicalPath.startsWith(outputDirectory)) {
131+
String errorMessage = "Zip traversal security error";
132+
callbackContext.error(errorMessage);
133+
Log.e(LOG_TAG, errorMessage);
134+
return;
135+
}
129136
file.getParentFile().mkdirs();
130137
if(file.exists() || file.createNewFile()){
131138
Log.w("Zip", "extracting: " + file.getPath());

0 commit comments

Comments
 (0)