<?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>105000</bug_id>
          
          <creation_ts>2005-09-06 04:05 0000</creation_ts>
          <short_desc>app-backup/flexbackup &lt;= 1.2.1 multiples vulnerabilities</short_desc>
          <delta_ts>2005-12-23 10:43:57 0000</delta_ts>
          
          
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Security</product>
          <component>Default Configs</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <status_whiteboard>[noglsa] jaervosz</status_whiteboard>
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>zataz@zataz.net</reporter>
          <assigned_to>security@gentoo.org</assigned_to>
          <cc>jochen@gentoo.erwied.de</cc>
    
    <cc>max@gentoo.org</cc>
    
    <cc>mholzer@gentoo.org</cc>
    
    <cc>tester@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>zataz@zataz.net</who>
            <bug_when>2005-09-06 04:05:02 0000</bug_when>
            <thetext>Hello,

* In /etc/flexbackup.conf :

$tmpdir = &apos;/tmp&apos;;

* Into flexbackup :

&amp;checkvar(\$cfg::tmpdir,&apos;tmpdir&apos;,&apos;exist&apos;,&apos;/tmp&apos;);

If tmpdir is not defined /tmp is used by default, but here into conf file tmpdir
is by default set to /tmp

5229     my $tmp_script = &quot;$cfg::tmpdir/buftest.$host.$PROCESS_ID.sh&quot;;

5236     # Create a script which tests the buffer program
5237     open(SCR,&quot;&gt; $tmp_script&quot;) || die;
5238     print SCR &quot;#!/bin/sh\n&quot;;
5239     print SCR &quot;tmp_data=/tmp/bufftest\$\$.txt\n&quot;;
5240     print SCR &quot;tmp_err=/tmp/bufftest\$\$.err\n&quot;;
5241     print SCR &quot;echo testme &gt; \$tmp_data\n&quot;;
5242     print SCR &quot;$buffer_cmd &gt; /dev/null 2&gt; \$tmp_err &lt; \$tmp_data\n&quot;;
5243     print SCR &quot;res=\$?\n&quot;;
5244     print SCR &quot;out=\`cat \$tmp_err\`\n&quot;;
5245     print SCR &quot;if [ \$res -eq 0 ]; then\n&quot;;
5246     print SCR &quot;   echo successful\n&quot;;
5247     print SCR &quot;else\n&quot;;
5248     print SCR &quot;   echo \&quot;unsuccessful: exit code \$res: \$out\&quot; \n&quot;;
5249     print SCR &quot;fi\n&quot;;
5250     print SCR &quot;rm -f \$tmp_data \$tmp_err\n&quot;;
5251     close(SCR);

Here we have possible symlink attack (race condition), and also possibility to
create a untrusted script into the tmp_script (race condition).

The script how is created is also vulnerable to possible symlink attack (race
condition).

5253     if ($host eq &apos;localhost&apos;) {
5254         print $::msg &quot;| Checking &apos;$cfg::buffer&apos; on this machine... &quot;;
5255         $pipecmd = &quot;sh $tmp_script &quot;;
5256     } else {
5257         print $::msg &quot;| Checking &apos;$cfg::buffer&apos; on host $host... &quot;;
5258         $pipecmd =  &quot;cat $tmp_script | ($::remoteshell $host &apos;cat &gt;
$tmp_script; sh $tmp_script; rm -f $tmp_script&apos;        )&quot;;

We see here that the untrusted script could be executed on localhost or remote host.

5446     my $tmp1 = &quot;$cfg::tmpdir/test1.$PROCESS_ID&quot;;
5447     my $tmp2 = &quot;$cfg::tmpdir/test2.$PROCESS_ID&quot;;
5448     my $tmp3 = &quot;$cfg::tmpdir/test3.$PROCESS_ID&quot;;

Here the $cfg::pad_blocks should be false to exploit the possible symlink attack
(race condition). By default in the conf file pad_blocks is true. No risk if no
configuration modification.

359     if (defined($::pkgdelta)) {
360         if (defined($::local)) {
361             &amp;list_packages(&apos;localhost&apos;);
362             &amp;find_packaged_files(&apos;localhost&apos;);
363             &amp;find_changed_files(&apos;localhost&apos;);
364         }
365         foreach my $host (keys %::remotehosts) {
366             &amp;list_packages($host);
367             &amp;find_packaged_files($host);
368             &amp;find_changed_files($host);
369         }
370         $::pkgdelta_filelist = &quot;$cfg::tmpdir/pkgdelta.$PROCESS_ID&quot;;
371         &amp;line();
372     }

Here we have possible symlink attack (race condition)

619     my $exitscript = &quot;$cfg::tmpdir/collectexit.$PROCESS_ID.sh&quot;;
620     my $result = &quot;$cfg::tmpdir/exitstatus.$PROCESS_ID&quot;;

841         unlink($result);
842         open(SCR, &quot;&gt; $exitscript&quot;) || die;
843         print SCR &apos;#!/bin/sh&apos; . &quot;\n&quot;; 
844         print SCR &apos;&quot;$@&quot;&apos; . &quot;\n&quot;;;
845         print SCR &apos;[ $? = 0 ] || echo $@ &gt;&gt; &apos; . $result . &quot;\n&quot;;
846         close(SCR);
847         chmod(0755, $exitscript);
848 
849         push(@cmds, &quot;[ ! -e $result ]&quot;);
850     }

This one is more difficult to race.

Regards.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>taviso@gentoo.org</who>
            <bug_when>2005-09-13 05:50:59 0000</bug_when>
            <thetext>yes, looks like a Default Config issue, changing component..</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>zataz@zataz.net</who>
            <bug_when>2005-09-13 05:59:20 0000</bug_when>
            <thetext>Hello,

Upsteam provide the config file with $tmpdir = &apos;/tmp&apos;;

Should I contact upstream ?

Regards.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>zataz@zataz.net</who>
            <bug_when>2005-09-19 02:00:09 0000</bug_when>
            <thetext>Hello,

Email send to upstream.

Edwin Huffstutler &lt;edwinh+flexbackup@edwinh.org&gt;

Regards.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>zataz@zataz.net</who>
            <bug_when>2005-09-30 01:07:41 0000</bug_when>
            <thetext>Hello,

No response from upstream.

Release date : 2005-10-15

Send to vendor-sec@lst.de

Regards.
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2005-10-02 02:18:48 0000</bug_when>
            <thetext>Created an attachment (id=69694)
patch.CAN-2005-2965.flexbackup

Patch from Martin Schulze @Debian, removes insecure tmpfile usage rather than
fix the default conf value.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-10-06 12:00:56 0000</bug_when>
            <thetext>max/mholzer please attach an updated ebuild. 
 
Do NOT commit anything to Portage. </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2005-10-06 16:09:23 0000</bug_when>
            <thetext>Created an attachment (id=70020)
flexbackup-1.2.1-r1.ebuild

i think both mholzer/max are afk</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-10-06 22:23:13 0000</bug_when>
            <thetext>Thx Mike.   
   
Calling arch security liaisons to test and report back on this bug:  
  
hppa  hansmi  
ppc  hansmi  
x86  tester  </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>hansmi@gentoo.org</who>
            <bug_when>2005-10-08 06:35:06 0000</bug_when>
            <thetext>Works on ppc and hppa.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>tester@gentoo.org</who>
            <bug_when>2005-10-08 21:08:46 0000</bug_when>
            <thetext>you have my ok to commit straight to stable on x86</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2005-10-17 01:08:21 0000</bug_when>
            <thetext>SpanKY feel free to commit the ebuild</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2005-10-20 10:09:11 0000</bug_when>
            <thetext>added with x86 stable</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>hansmi@gentoo.org</who>
            <bug_when>2005-10-21 11:27:55 0000</bug_when>
            <thetext>Stable on ppc and hppa.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-10-21 23:41:02 0000</bug_when>
            <thetext>Default config -&gt; closing without GLSA. </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jochen@gentoo.erwied.de</who>
            <bug_when>2005-12-23 07:51:13 0000</bug_when>
            <thetext>(In reply to comment #14)
&gt; Default config -&gt; closing without GLSA. 
&gt; 

The patch breaks the ability to backup remote machines.

The additional directory is created only locally, but not promoted to the remote machine.

The errors look like this:

|------------------------------------------------------------
| File number 12, tape index 200512202202
| Backup of: border:/etc
| Date of this level 2 backup: Thu Dec 22 05:31:07 2005
| Date of last level 1 backup: Wed Dec 21 05:21:00 2005
|------------------------------------------------------------
| ssh border &apos;touch -t &quot;200512210521.00&quot; /tmp/6136/refdate.6136&apos;
| ssh border &apos;printf &quot;mp3 MP3 Z z gz gif zip ZIP lha jpeg jpg JPG taz tgz \
|   deb rpm bz2 lzo&quot; &gt; /tmp/6136/nocompress.6136&apos;
| ssh border &apos;printf &quot;Volume Label:\nlevel 2 border:/etc Thu Dec 22 \
|   05:31:07 2005 afio+gzip from joker\n\n&quot; &gt; /tmp/6136/label.6136&apos;
| /tmp/6136/collectexit.6136.sh ssh border &apos;cd &quot;/etc&quot; &amp;&amp; (printf \
|   &quot;//--/tmp/6136/label.6136 flexbackup.volume_header_info\n&quot; &amp;&amp; find . \
|   -depth -xdev ! -type s -newer &quot;/tmp/6136/refdate.6136&quot; ! -regex \
|   &quot;.*/[Cc]ache/.*&quot; ! -regex &quot;.*~&quot;$ -print ) | afio -o -E \
|   /tmp/6136/nocompress.6136 -z -1 m -P gzip -Q -4 -Z -M 2m -T 3k -v -&apos; | \
|   /tmp/6136/collectexit.6136.sh cat &gt; &quot;/dev/nst0&quot;
| ssh border &apos;rm -f /tmp/6136/refdate.6136 /tmp/6136/nocompress.6136 \
|   /tmp/6136/label.6136&apos;
| [ ! -e /tmp/6136/exitstatus.6136 ]
|------------------------------------------------------------
touch: cannot touch `/tmp/6136/refdate.6136&apos;: No such file or directory

ERROR: non-zero exit from:



</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2005-12-23 10:35:09 0000</bug_when>
            <thetext>You should open a new bug, this is no longer a security issue, it&apos;s just a patch that broke functionality... and needs to be fixed.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jochen@gentoo.erwied.de</who>
            <bug_when>2005-12-23 10:43:57 0000</bug_when>
            <thetext>&gt; You should open a new bug, this is no longer a security issue, it&apos;s just a
&gt; patch that broke functionality... and needs to be fixed.

You&apos;re correct. Filed as bug #116510
</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>69694</attachid>
            <date>2005-10-02 02:18 0000</date>
            <desc>patch.CAN-2005-2965.flexbackup</desc>
            <filename>patch.CAN-2005-2965.flexbackup</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIGZsZXhiYWNrdXB+CTIwMDMtMTAtMTAgMTY6MTI6MDkuMDAwMDAwMDAwICswMjAwCisrKyBm
bGV4YmFja3VwCTIwMDUtMTAtMDEgMTk6MzU6MjUuMDAwMDAwMDAwICswMjAwCkBAIC0yNjksNiAr
MjY5LDcgQEAgaWYgKCgkOjptb2RlICF+IG0vXihsaXN0fGV4dHJhY3R8cmVzdG9yZQogICAgIHVu
dGllKCU6OmluZGV4KTsKIH0KIAorc3lzdGVtICgncm0nLCAnLXJmJywgJGNmZzo6dG1wZGlyKSBp
ZiAoZGVmaW5lZCgkY2ZnOjpkZWx0bXBkaXIpKTsKIGV4aXQoMCk7CiAKICMjIyMjIyMjIyMjIyMj
IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMK
QEAgLTI3MjUsNiArMjcyNiwxMyBAQCBzdWIgb3B0aW9uY2hlY2sgewogICAgICZjaGVja3Zhcihc
JGNmZzo6cHJlZml4LCdwcmVmaXgnLCdleGlzdCcsJycpOwogICAgICZjaGVja3ZhcihcJG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cbiI7CiAgICAgcHJpbnQgU0NSICJyZXM9XCQ/XG4iOwo=
</data>        

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>70020</attachid>
            <date>2005-10-06 16:09 0000</date>
            <desc>flexbackup-1.2.1-r1.ebuild</desc>
            <filename>flexbackup-1.2.1-r1.ebuild</filename>
            <type>text/plain</type>
            <data encoding="base64">IyBDb3B5cmlnaHQgMTk5OS0yMDA1IEdlbnRvbyBGb3VuZGF0aW9uCiMgRGlzdHJpYnV0ZWQgdW5k
ZXIgdGhlIHRlcm1zIG9mIHRoZSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSB2MgojICRIZWFk
ZXI6IC92YXIvY3Zzcm9vdC9nZW50b28teDg2L2FwcC1iYWNrdXAvZmxleGJhY2t1cC9mbGV4YmFj
a3VwLTEuMi4xLmVidWlsZCx2IDEuMSAyMDA1LzA3LzA0IDA1OjE2OjU0IHJvYmJhdDIgRXhwICQK
CmluaGVyaXQgZXV0aWxzCgpERVNDUklQVElPTj0iRmxleGlibGUgYmFja3VwIHNjcmlwdCB1c2lu
ZyBwZXJsIgpIT01FUEFHRT0iaHR0cDovL2ZsZXhiYWNrdXAuc291cmNlZm9yZ2UubmV0LyIKU1JD
X1VSST0ibWlycm9yOi8vc291cmNlZm9yZ2UvJHtQTn0vJHtQfS50YXIuZ3oiCgpMSUNFTlNFPSJH
UEwtMiIKU0xPVD0iMCIKS0VZV09SRFM9In5hbWQ2NCB+aHBwYSB+cHBjIH54ODYiCklVU0U9IiIK
ClJERVBFTkQ9ImRldi1sYW5nL3BlcmwKCXN5cy1hcHBzL2ZpbmR1dGlscwoJYXBwLWFyY2gvdGFy
CglhcHAtYXJjaC9tdC1zdCIKCnNyY191bnBhY2soKSB7Cgl1bnBhY2sgJHtBfQoJY2QgIiR7U30i
CgllcGF0Y2ggIiR7RklMRVNESVJ9Ii8ke1B9LUNBTi0yMDA1LTI5NjUucGF0Y2gKCXNlZCA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