Google Play上架警示:Zip Path Traversal === ###### tags: `Google Play` `Cordova` 使用web app的基礎作為技術開發(如cordova/phonegap)上傳到Play Store平台時,出現了以下警告 **您的應用程式內含的解壓縮模式不安全,可能導致 Path Traversal 安全漏洞。** ![](https://i.imgur.com/9EdhV77.png) 目前檢查後發現問題存在於使用了cordova-plugin-zip這一個plugin所存在的潛藏安全性問題,只是目前這個plugin已經很久沒更新,github開源社群有提供解決版本並發出pull request但尚未被merge到正式版本。 因此我們根據發出pull request的版本自己手動做以下修改: src/android/Zip.java ```=128 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(); ``` 參考解法:https://github.com/MobileChromeApps/cordova-plugin-zip/pull/92