Check and enforce canonical destination path of new file to resolve zip
slip vulnerability in 'DaeximOffsiteBackupProvider.java'
Issue-ID: CCSDK-3376
Signed-off-by: Jonathan Platt <jonathan.platt@att.com>
Change-Id: I249752d7a8bb1a8075502b5130f94c32986ab8ee
while(zipEntry != null){
String fileName = zipEntry.getName();
File newFile = new File(DAEXIM_DIR + fileName);
+ // To remediate zip slip vulnerability, ensure file has the expected canonical path
+ if (!newFile.getCanonicalPath().startsWith(DAEXIM_DIR)) {
+ throw new IOException("Entry is outside of the target directory");
+ }
FileOutputStream fos = new FileOutputStream(newFile);
int len;
while ((len = zis.read(bytes)) > 0) {