Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 28359
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Richard Guenther <rguenth@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: marcus@jet.franken.de
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
cups.jar cups.jar application/octet-stream 2006-07-12 14:50 34.30 KB Edit
xx.pat fix.patch patch 2006-07-12 14:54 258 bytes Edit | Diff
p different fix patch 2006-07-12 15:14 429 bytes Edit | Diff
p fixed patch patch 2006-07-17 14:03 538 bytes Edit | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 28359 depends on: Show dependency tree
Show dependency graph
Bug 28359 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2006-07-13 07:40 Opened: 2006-07-12 14:49
fastjar contains the following security problem:

When a JAR archive is extracted with filenames with "../" inside, it can
extract files outside of the current directory (a so called directory
traversal).

Unconspicious users unpacking such files could overwrite their own files,
or even system files when being root.

I am attaching a sample "cups.jar" from an earlier CUPS tarball, which exposes
this problem.

------- Comment #1 From marcus@jet.franken.de 2006-07-12 14:50 -------
Created an attachment (id=11868) [edit]
cups.jar

sample file with ../ paths inside.

------- Comment #2 From marcus@jet.franken.de 2006-07-12 14:54 -------
Created an attachment (id=11869) [edit]
fix.patch

i would propose this patch to fix this problem.

------- Comment #3 From Richard Guenther 2006-07-12 15:08 -------
Confirmed.

------- Comment #4 From Richard Guenther 2006-07-12 15:14 -------
Created an attachment (id=11870) [edit]
different fix

------- Comment #5 From Richard Guenther 2006-07-12 15:19 -------
I have applied the 2nd fix to the upstream (savannah) fastjar CVS.

------- Comment #6 From Andrew Pinski 2006-07-12 16:57 -------
Fastjar no longer is included with GCC so closing as will not fix.

------- Comment #7 From Richard Guenther 2006-07-12 17:47 -------
Well... maybe the RM has an opinion on this.

------- Comment #8 From marcus@jet.franken.de 2006-07-12 18:30 -------
yes, this could still be fixed for release branches ;)

------- Comment #9 From Mark Mitchell 2006-07-13 05:04 -------
There's certainly no reason not to fix this on release branches.

------- Comment #10 From Richard Guenther 2006-07-13 07:39 -------
Reopening then...

------- Comment #11 From Richard Guenther 2006-07-13 07:40 -------
...to assign myself.

------- Comment #12 From Jakub Jelinek 2006-07-17 12:21 -------
The patch in #4 is insufficient.  Consider paths like ././../.././../etc/passwd
which satisfies the depth tests, yet clearly escapes the current dir tree.
Another question is about symlinks, if there is a foo -> ../../../../etc
symlink in the current tree, then I believe fastjar will happily store
foo/passwd into ../../../../etc/passwd, is that something that can be declared
as user's fault or should fastjar always canonicalize the filename and don't
allow leaving the current directory tree in any way?

------- Comment #13 From marcus@jet.franken.de 2006-07-17 12:25 -------
CVE-2006-3619

------- Comment #14 From Richard Guenther 2006-07-17 13:57 -------
Indeed.  Now for symlinks it is only a problem if you can package them like

 foo -> ../../
 foo/x

i.e., if uncompressing a zip archive can _create_ symlinks.  On unix it can,
but it seems to "defer" their creation.

Archive:  ../t.zip
   creating: b/
    linking: b/foo                   -> ../ 
checkdir error:  b/foo exists but is not directory
                 unable to process b/foo/bar.
finishing deferred symbolic links:
  b/foo                  -> ../

------- Comment #15 From Richard Guenther 2006-07-17 14:03 -------
Created an attachment (id=11904) [edit]
fixed patch

Version of the patch that doesn't count "." parts in the filename as depth.

------- Comment #16 From Matthias Klose 2006-08-05 09:27 -------
Subject: Bug 28359

Author: doko
Date: Sat Aug  5 09:27:11 2006
New Revision: 115945

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115945
Log:
        PR fastjar/28359 / CVE-2006-3619

        2006-07-17  Richard Guenther  <rguenther@suse.de>
        * jartool.c (extract_jar): Do not allow directory traversal
        to parents of the extraction root.

Modified:
    branches/gcc-4_1-branch/fastjar/ChangeLog
    branches/gcc-4_1-branch/fastjar/jartool.c

------- Comment #17 From Matthias Klose 2006-08-05 09:43 -------
Subject: Bug 28359

Author: doko
Date: Sat Aug  5 09:43:02 2006
New Revision: 115946

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115946
Log:
        PR fastjar/28359 / CVE-2006-3619

        2006-07-17  Richard Guenther  <rguenther@suse.de>
        * jartool.c (extract_jar): Do not allow directory traversal
        to parents of the extraction root.

Modified:
    branches/gcc-4_0-branch/fastjar/ChangeLog
    branches/gcc-4_0-branch/fastjar/jartool.c

------- Comment #18 From Richard Guenther 2006-08-11 19:46 -------
I think this is now fixed.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug