summaryrefslogtreecommitdiffstats
path: root/chrome/common/zip.cc
diff options
context:
space:
mode:
authorcevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 22:31:42 +0000
committercevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 22:31:42 +0000
commit62a206d0ac3305edb0b4c0a7a681c1e8024fe159 (patch)
tree11b49d1a4bf0b33b8a7f99428973e31d0cb5df38 /chrome/common/zip.cc
parent686dd8db46810742a3eeec888c293aa528d4a938 (diff)
downloadchromium_src-62a206d0ac3305edb0b4c0a7a681c1e8024fe159.zip
chromium_src-62a206d0ac3305edb0b4c0a7a681c1e8024fe159.tar.gz
chromium_src-62a206d0ac3305edb0b4c0a7a681c1e8024fe159.tar.bz2
Avoid directory traversal attacks when unpacking zips. The sandbox would tend
to catch & deny this, but the Linux and Mac port does not yet do extension packing inside the sandbox. Therefore, reject any filenames in the zip which have .. in them. BUG=NONE TEST=ZipTest.UnzipEvil Review URL: http://codereview.chromium.org/160028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21460 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/zip.cc')
-rw-r--r--chrome/common/zip.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/chrome/common/zip.cc b/chrome/common/zip.cc
index 6909cc6..9c0adea 100644
--- a/chrome/common/zip.cc
+++ b/chrome/common/zip.cc
@@ -29,6 +29,11 @@ static bool ExtractCurrentFile(unzFile zip_file,
if (filename_inzip[0] == '\0')
return false;
+ // Check the filename here for directory traversal issues. In the name of
+ // simplicity and security, we might reject a valid filename such as "a..b"
+ if (strstr(filename_inzip, "..") != NULL)
+ return false;
+
err = unzOpenCurrentFile(zip_file);
if (err != UNZ_OK)
return false;