<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>86585</bug_id>
          
          <creation_ts>2005-03-24 14:42 0000</creation_ts>
          <short_desc>dev-java/sun-jdk: ebuild insecure temporary file handling</short_desc>
          <delta_ts>2005-03-28 09:52:59 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Security</product>
          <component>Vulnerabilities</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <status_whiteboard>B3 [noglsa] jaervosz</status_whiteboard>
          
          <priority>P2</priority>
          <bug_severity>minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>taviso@gentoo.org</reporter>
          <assigned_to>security@gentoo.org</assigned_to>
          <cc>java@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>taviso@gentoo.org</who>
            <bug_when>2005-03-24 14:42:54 0000</bug_when>
            <thetext>the sun-jdk ebuild uses a predictable tmp filename for it&apos;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&apos;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 &apos;s#/tmp/unpack.log#/dev/null\x00\x00\x00\x00\x00\x00#sg&apos; $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).</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>luckyduck@gentoo.org</who>
            <bug_when>2005-03-24 16:33:05 0000</bug_when>
            <thetext>ok, patch applied</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2005-03-25 00:47:45 0000</bug_when>
            <thetext>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 &quot;fixed&quot; from version.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>taviso@gentoo.org</who>
            <bug_when>2005-03-25 02:28:13 0000</bug_when>
            <thetext>Koon: it&apos;s part of the installation routine from sun (ie, not gentoo&apos;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</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>axxo@gentoo.org</who>
            <bug_when>2005-03-25 10:37:29 0000</bug_when>
            <thetext>can this be done with sed too?
don&apos;t want to be DEPEND&apos;ing on perl </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>taviso@gentoo.org</who>
            <bug_when>2005-03-25 11:31:47 0000</bug_when>
            <thetext>axxo: yep, if you&apos;ld prefer.

This works fine:

sed -i &apos;s#/tmp/unpack.log#/dev/null\x00\x00\x00\x00\x00\x00#g&apos; $UNPACK_CMD</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>luckyduck@gentoo.org</who>
            <bug_when>2005-03-25 14:40:50 0000</bug_when>
            <thetext>applied to all vulnerable packages/versions. old and vulnerable revisions are removed from the tree, the new revisions which aren&apos;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&apos;t make use of $UNPACK_CMD at all. i havn&apos;t touch these version.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-03-25 22:12:02 0000</bug_when>
            <thetext>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.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>lu_zero@gentoo.org</who>
            <bug_when>2005-03-26 02:24:55 0000</bug_when>
            <thetext>ppc doesn&apos;t use blackdown.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>blubb@gentoo.org</who>
            <bug_when>2005-03-26 03:17:39 0000</bug_when>
            <thetext>blackdown-jdk-1.4.2.01-r2 stable on amd64</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>weeve@gentoo.org</who>
            <bug_when>2005-03-26 06:11:00 0000</bug_when>
            <thetext>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.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>luckyduck@gentoo.org</who>
            <bug_when>2005-03-26 08:11:45 0000</bug_when>
            <thetext>i think the keywords are fine now, there was no sparc and no ppc keyword in any of the vulnerable versions. version &lt;=1.4.1 don&apos;t make use of this installing scheme and $UNPACK_CMD etc. seems that everything is fine now</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>weeve@gentoo.org</who>
            <bug_when>2005-03-26 09:26:29 0000</bug_when>
            <thetext>Removing SPARC then since we aren&apos;t affected.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-03-27 01:23:12 0000</bug_when>
            <thetext>This one is ready for GLSA decision.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2005-03-28 05:08:03 0000</bug_when>
            <thetext>I would vote no... My logic being that upgrading won&apos;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.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>luckyduck@gentoo.org</who>
            <bug_when>2005-03-28 09:05:55 0000</bug_when>
            <thetext>i don&apos;t have a right to vote, but i agree. all affected versions aren&apos;t in the tree any longer.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-03-28 09:52:59 0000</bug_when>
            <thetext>I agree -&gt; closing without GLSA.</thetext>
          </long_desc>
      
    </bug>

</bugzilla>