Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 86585 - dev-java/sun-jdk: ebuild insecure temporary file handling
Summary: dev-java/sun-jdk: ebuild insecure temporary file handling
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All All
: High minor (vote)
Assignee: Gentoo Security
URL:
Whiteboard: B3 [noglsa] jaervosz
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-24 14:42 UTC by Tavis Ormandy (RETIRED)
Modified: 2005-03-28 09:52 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tavis Ormandy (RETIRED) gentoo-dev 2005-03-24 14:42:54 UTC
the sun-jdk ebuild uses a predictable tmp filename for it's extraction log.

users could abuse this by creating files at arbitrary locations via a symlink attack. example:

$ ls -l /etc/nologin
ls: /etc/nologin: No such file or directory
$ ln -fs /etc/nologin /tmp/unpack.log
# wait for root to emerge java
$ ls -l /etc/nologin
-rw-r--r--  1 root root 390 Mar 24 22:36 /etc/nologin

I've thought of a solution, 

$ cvs diff sun-jdk-1.4.2.07.ebuild 
Index: sun-jdk-1.4.2.07.ebuild
===================================================================
RCS file: /var/cvsroot/gentoo-x86/dev-java/sun-jdk/sun-jdk-1.4.2.07.ebuild,v
retrieving revision 1.2
diff -u -w -r1.2 sun-jdk-1.4.2.07.ebuild
--- sun-jdk-1.4.2.07.ebuild     3 Feb 2005 05:43:51 -0000       1.2
+++ sun-jdk-1.4.2.07.ebuild     24 Mar 2005 22:38:56 -0000
@@ -76,6 +76,7 @@
        if [ -f ${S}/lib/unpack ]; then
                UNPACK_CMD=${S}/lib/unpack
                chmod +x $UNPACK_CMD
+               perl -pi -e 's#/tmp/unpack.log#/dev/null\x00\x00\x00\x00\x00\x00#sg' $UNPACK_CMD
                for i in $PACKED_JARS; do
                        PACK_FILE=${S}/`dirname $i`/`basename $i .jar`.pack
                        if [ -f ${PACK_FILE} ]; then

replace the hardcoded predictable name with /dev/null (note the null padding is required).
Comment 1 Jan Brinkmann (RETIRED) gentoo-dev 2005-03-24 16:33:05 UTC
ok, patch applied
Comment 2 Thierry Carrez (RETIRED) gentoo-dev 2005-03-25 00:47:45 UTC
Is this bug Gentoo-ebuild-specific ? Or does it affect every JDK installer ? In which case we should transmit to Sun.

luckyduck: you should revbump so that if we issue a GLSA about this we get a "fixed" from version.
Comment 3 Tavis Ormandy (RETIRED) gentoo-dev 2005-03-25 02:28:13 UTC
Koon: it's part of the installation routine from sun (ie, not gentoo's fault), so we should inform upstream?

these are also affected:

dev-java/sun-jre-bin
dev-java/blackdown-jdk 
dev-java/blackdown-jre

the same patch should work
Comment 4 Thomas Matthijs (RETIRED) gentoo-dev 2005-03-25 10:37:29 UTC
can this be done with sed too?
don't want to be DEPEND'ing on perl 
Comment 5 Tavis Ormandy (RETIRED) gentoo-dev 2005-03-25 11:31:47 UTC
axxo: yep, if you'ld prefer.

This works fine:

sed -i 's#/tmp/unpack.log#/dev/null\x00\x00\x00\x00\x00\x00#g' $UNPACK_CMD
Comment 6 Jan Brinkmann (RETIRED) gentoo-dev 2005-03-25 14:40:50 UTC
applied to all vulnerable packages/versions. old and vulnerable revisions are removed from the tree, the new revisions which aren't vulnerable are:

sun-jdk-1.4.2.07-r1
sun-jdk-1.5.0.02-r1

sun-jre-bin-1.4.2.07-r1
sun-jre-bin-1.5.0.01-r1

blackdown-jdk-1.4.2.01-r2

blackdown-jre-1.4.2.01-r1


there are versions in the tree which don't make use of $UNPACK_CMD at all. i havn't touch these version.
Comment 7 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2005-03-25 22:12:02 UTC
Arches please test and mark stable (if possible)

blackdown-jdk-1.4.2.01-r2: amd64, ppc?, sparc?, x86
blackdown-jre-1.4.2.01-r1: ppc?, sparc?

Jan, please check that the Sun packages have proper keywords.
Comment 8 Luca Barbato gentoo-dev 2005-03-26 02:24:55 UTC
ppc doesn't use blackdown.
Comment 9 Simon Stelling (RETIRED) gentoo-dev 2005-03-26 03:17:39 UTC
blackdown-jdk-1.4.2.01-r2 stable on amd64
Comment 10 Jason Wever (RETIRED) gentoo-dev 2005-03-26 06:11:00 UTC
At last check, there was no blackdown-j*-1.4.2* for SPARC.  The latest we have is 1.4.1.  Not sure how you want to handle that.
Comment 11 Jan Brinkmann (RETIRED) gentoo-dev 2005-03-26 08:11:45 UTC
i think the keywords are fine now, there was no sparc and no ppc keyword in any of the vulnerable versions. version <=1.4.1 don't make use of this installing scheme and $UNPACK_CMD etc. seems that everything is fine now
Comment 12 Jason Wever (RETIRED) gentoo-dev 2005-03-26 09:26:29 UTC
Removing SPARC then since we aren't affected.
Comment 13 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2005-03-27 01:23:12 UTC
This one is ready for GLSA decision.
Comment 14 Thierry Carrez (RETIRED) gentoo-dev 2005-03-28 05:08:03 UTC
I would vote no... My logic being that upgrading won't solve anything. People with the affected package already installed are not vulnerable to anything. Only people re-installing old versions would be.

So I would remove all affected versions and close this one without GLSA.
Comment 15 Jan Brinkmann (RETIRED) gentoo-dev 2005-03-28 09:05:55 UTC
i don't have a right to vote, but i agree. all affected versions aren't in the tree any longer.
Comment 16 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2005-03-28 09:52:59 UTC
I agree -> closing without GLSA.