<?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>160130</bug_id>
          
          <creation_ts>2007-01-04 15:51 0000</creation_ts>
          <short_desc>sci-astronomy/predict:  Insecure /tmp file usage in files/predict-update</short_desc>
          <delta_ts>2009-01-11 19:04:16 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>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <status_whiteboard>B3? [noglsa]</status_whiteboard>
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>shellsage@gentoo.org</reporter>
          <assigned_to>security@gentoo.org</assigned_to>
          <cc>sci@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>shellsage@gentoo.org</who>
            <bug_when>2007-01-04 15:51:56 0000</bug_when>
            <thetext>The file files/predict-update that is distributed with the sci-astronomy/predict ebuild insecurely writes to files in /tmp.  If the files were to exist, or be created by a local attacker in a race condition with wget, as symlinks, arbitrary files could possibly be overwritten upon the installation of sci-astronomy/predict.  wget should not be used to write to files in /tmp, and even otherwise, the existence of files in wget should be checked for existence before data is written to them.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2007-01-06 12:57:48 0000</bug_when>
            <thetext>sci please advise.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>markusle@gentoo.org</who>
            <bug_when>2007-01-07 18:06:12 0000</bug_when>
            <thetext>Hi Vic,

Thanks for pointing this out! Unfortunately, I am not familiar with this
package, but it seems that the predict-update script is provided
by gentoo rather than being part of the upstream package. It was committed
by phosphan, so maybe he can advise on what to do.

There are two options I can think of right now to resolve this issue: 
(1) We add &quot;-nc&quot; to wget to prevent it from overwriting already existing files.
(2) We remove the script altogether and provide the user with a brief set of
instructions on how to update his database &quot;by hand&quot;.

If (1) would be fine and sufficient with the security folks I could do that 
right away.

Thanks,
Markus

</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>taviso@gentoo.org</who>
            <bug_when>2007-01-07 18:10:03 0000</bug_when>
            <thetext>Hi Markus, an easy way to use /tmp securely from a shellscript is like so:

mkdir /tmp/predict-$$ || exit 1
cd /tmp/predict-$$

now you can use wget safely, then just rm -rf the directory when finished...the imnportant part is you _must_ abort if mkdir returns error. If you dont mind making this minor change, that would be fine from a security perspective!
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>markusle@gentoo.org</who>
            <bug_when>2007-01-07 23:49:44 0000</bug_when>
            <thetext>Created an attachment (id=105965)
proposed patch to remove insecure file handling

Hi Tavis,

Thanks for the tip and this should work perfectly!
I&apos;ve attached a proposed patch for predict-update.
If this looks fine to the security team I&apos;ll apply it asap and
revision bump the ebuild.

Thanks,
Markus</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>markusle@gentoo.org</who>
            <bug_when>2007-01-12 02:41:10 0000</bug_when>
            <thetext>@security folks:

I&apos;ve just bumped predict to version 2.2.3 which will pull in
the updated predict-update script (see the posted patch).
This should fix the insecure /tmp file handling, unless there
are additional concerns with the updated version.
The bumped ebuild is currently in ~amd64 and ~x86
and needs to be stabled on both arches to get the insecure
version of predict-update off of user&apos;s systems.

Please let me know if there&apos;s anything else you would like
me to do.

Thanks,
Markus </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vorlon@gentoo.org</who>
            <bug_when>2007-01-26 11:28:42 0000</bug_when>
            <thetext>thanks Markus

amd64/x86, pls test predict-2.2.3 and mark stable if possible</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>armin76@gentoo.org</who>
            <bug_when>2007-01-26 11:43:18 0000</bug_when>
            <thetext>x86 stable</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>beandog@gentoo.org</who>
            <bug_when>2007-01-26 14:43:59 0000</bug_when>
            <thetext>amd64 stable</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vorlon@gentoo.org</who>
            <bug_when>2007-01-26 14:45:16 0000</bug_when>
            <thetext>security please vote on glsa publication</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>shellsage@gentoo.org</who>
            <bug_when>2007-01-27 21:36:03 0000</bug_when>
            <thetext>I vote yes; there were a bunch of these packages we found, we should probably do GLSAs for all of them.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2007-01-27 22:52:05 0000</bug_when>
            <thetext>Well if we can bundle a lot of similar issues it would be fine. Otherwise I tend to vote NO.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>falco@gentoo.org</who>
            <bug_when>2007-02-10 19:03:54 0000</bug_when>
            <thetext>(In reply to comment #11)
&gt; Well if we can bundle a lot of similar issues it would be fine. Otherwise I
&gt; tend to vote NO.
&gt; 

IMHO it should depend on the package, the severity and if the exploitation if easy. Here it&apos;s only during emerge, so i vote NO, and  i close the bug. Feel free to reopen if you disagree</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>105965</attachid>
            <date>2007-01-07 23:49 0000</date>
            <desc>proposed patch to remove insecure file handling</desc>
            <filename>predict-update.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIHByZWRpY3QtdXBkYXRlLm9sZAkyMDA3LTAxLTA3IDE4OjQyOjE5LjAwMDAwMDAwMCAtMDUw
MAorKysgcHJlZGljdC11cGRhdGUJMjAwNy0wMS0wNyAxODozOToyNi4wMDAwMDAwMDAgLTA1MDAK
QEAgLTEsOCArMSw3IEBACiAjIS9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