<?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>91785</bug_id>
          
          <creation_ts>2005-05-07 04:03 0000</creation_ts>
          <short_desc>net-www/webapp-config insecure temporary file creation</short_desc>
          <delta_ts>2005-07-23 23:07:50 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>A3 [glsa] jaervosz</status_whiteboard>
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>eromang@zataz.net</reporter>
          <assigned_to>security@gentoo.org</assigned_to>
          <cc>web-apps@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>eromang@zataz.net</who>
            <bug_when>2005-05-07 04:03:46 0000</bug_when>
            <thetext>Hello,

They are some code in webapp-config how could permit to a normal user, to execute command as root, if the malicious user can get $my_file pointing to a file he owns.

-------------------------------------------------------------------
Code how is in concern :
-------------------------------------------------------------------

Begin line 2711

fn_show_postinst ()
{
        if [ ! -f &quot;${MY_APPDIR}/postinst-en.txt&quot; ]; then 
                return  
        fi      

        local my_file=&quot;/tmp/$$.postinst.txt&quot;

        fn_run_vars

        # we create a temporary file, so that we can expand the variables
        # that are used in the file
        
        echo &quot;cat &lt;&lt;webapp-EOF&quot; &gt; &quot;$my_file&quot;
        cat &quot;${MY_APPDIR}/postinst-en.txt&quot; &gt;&gt; &quot;$my_file&quot;
        echo &quot;webapp-EOF&quot; &gt;&gt; &quot;$my_file&quot;

        # execute the temporary file, to generate the output

        echo    
        . &quot;$my_file&quot;
        echo    

        # it&apos;s a temporary file, so let&apos;s get rid of it now

        rm -f &quot;$my_file&quot;
}

The creation of my_file should be done with mktemp, and chmod this file.

-----------------------------------------------------------

Another possible issue :

fn_remove_emptylines ()
{       
        egrep -v &apos;^$&apos; &quot;$1&quot; &gt; /tmp/$$
        cat /tmp/$$ &gt; &quot;$1&quot;
        rm -f /tmp/$$
}

All this two are hardly exploitable, because is a race condition, but it&apos;s possible.

Regards

Reproducible: Always
Steps to Reproduce:
1.
2.
3.

Actual Results:  
webapp-config don&apos;t use mktemp and don&apos;t chmod the temporary files

Expected Results:  
webapp-config should use mktemp and chmod temporary files</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-05-07 09:48:27 0000</bug_when>
            <thetext>Web-apps please provide an updated ebuild.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>beu@gentoo.org</who>
            <bug_when>2005-05-08 22:19:17 0000</bug_when>
            <thetext>Fixed in webapp-config-1.10-r14.  Also fixes security issues from bugs #88831 (configuration file permissions) and #87708 (top-level website directories created with mode 777).

Tested and marked stable on x86.  Arches, please test and mark net-www/webapp-config-1.10-r14 stable.  Thanks !</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>corsair@gentoo.org</who>
            <bug_when>2005-05-09 01:23:07 0000</bug_when>
            <thetext>stable on ppc64</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>zataz@zataz.net</who>
            <bug_when>2005-05-09 02:05:15 0000</bug_when>
            <thetext>Hello,

Tested with phpmyadmin, every thing work fine.

Just one thing to say :

-rw-r--r--  1 root root      333 May  9 10:59 /var/www/locahost/htdocs/phpmyadmin/.webapp

inside :

WEB_INSTALLEDFOR=&quot;root:apache&quot;

Could the files : .webapp-soft-version and .webapp be only root readable ?

Regards.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>gustavoz@gentoo.org</who>
            <bug_when>2005-05-09 08:22:46 0000</bug_when>
            <thetext>stable on sparc.
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>killerfox@gentoo.org</who>
            <bug_when>2005-05-09 10:15:56 0000</bug_when>
            <thetext>Stable on hppa</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>hansmi@gentoo.org</who>
            <bug_when>2005-05-09 10:18:50 0000</bug_when>
            <thetext>Stable on ppc.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>kloeri@gentoo.org</who>
            <bug_when>2005-05-09 14:29:17 0000</bug_when>
            <thetext>Stable on alpha + ia64.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>cryos@gentoo.org</who>
            <bug_when>2005-05-09 16:18:31 0000</bug_when>
            <thetext>Stable on amd64, sorry for the delay.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-05-09 22:38:45 0000</bug_when>
            <thetext>This one is ready for GLSA decision. I vote for NO GLSA, if this is only an issue with the latest stable version.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>zataz@zataz.net</who>
            <bug_when>2005-05-09 23:00:44 0000</bug_when>
            <thetext>Hello,

So how to force people to update webapp-config if they are no GLSA ?
3 securiry issues resolved in this version and no GLSA ?

Regards.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-05-09 23:24:27 0000</bug_when>
            <thetext>AFAIR (sorry pretty busy handling a lot of other bugs) the only real issue here is the temp file. The others are an improvement to default config. If anything sensitive is in .webapp files it&apos;s another matter.

Feel free to disagree and if so please elaborate:-)</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>taviso@gentoo.org</who>
            <bug_when>2005-05-10 00:53:08 0000</bug_when>
            <thetext>I would vote YES to a glsa on this issue.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>tigger@gentoo.org</who>
            <bug_when>2005-05-10 01:17:05 0000</bug_when>
            <thetext>vote YES for glsa (tavis 0wns me)</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-05-10 01:20:51 0000</bug_when>
            <thetext>Ok, this issue is not recently introduced-&gt;reversing vote to YES.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>beu@gentoo.org</who>
            <bug_when>2005-05-10 10:46:21 0000</bug_when>
            <thetext>I&apos;ve compiled a list of webapps in the tree that install config files which would have been installed world-readable with webapp-config &lt;1.10-r14:

  http://dev.gentoo.org/~beu/webapps-with-cfg-files.txt

These webapps will need to be re-installed by the user to be re-created with correct permissions.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>beu@gentoo.org</who>
            <bug_when>2005-05-10 12:17:30 0000</bug_when>
            <thetext>Waiting on arm/mips to go stable, then the webapp eclasses *DEPEND will be changed to require this version of webapp-config (the wait is needed, or stable arm/mips webapps will have a masked dependency).</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2005-05-10 15:16:36 0000</bug_when>
            <thetext>this is GLSA material</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2005-05-10 15:18:07 0000</bug_when>
            <thetext>arm/mips/s390 stable</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>beu@gentoo.org</who>
            <bug_when>2005-05-10 16:03:48 0000</bug_when>
            <thetext>DEPEND updated in webapp.eclass.  All your folks :)</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-05-10 22:02:31 0000</bug_when>
            <thetext>Elfyn would a simple chmod -R -orwx VHOST_ROOT fix the problem or just create new ones?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-05-10 22:10:24 0000</bug_when>
            <thetext>r2d2 just pointed out that you&apos;d of cause need a chown -R root:apache VHOST_ROOT as well.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-05-13 23:59:57 0000</bug_when>
            <thetext>Elfyn any news on this one?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>beu@gentoo.org</who>
            <bug_when>2005-05-15 08:48:43 0000</bug_when>
            <thetext>webapp-config-1.10-r15 will be hitting cvs in about 15-20 minutes, just have to polish off a little bit and beat the crap out of the new webapp-fixperms tool ;)

TO save time when I bump webapp-config, the usage that needs to be referenced in the glsa is as follows:

  # /usr/sbin/webapp-fixperms --fix-toplevel-vhost-perms-only all

The ebove command line will fix any directories that exist in /var/www (by default) that are world-writable - it just removes the write-bit on the directory&apos;s file mode.

Another webapp-fixperms invocation:

  # /usr/sbin/webapp-fixperms -p -d /var/www2 all
  # /usr/sbin/webapp-fixperms -d /var/www2 all

(-p and --pretend are much like emerge&apos;s pretend mode.)  The combination will check permission on installed config files for all webapps found in /var/www{,2}/*/htdocs.  You can also replace the &apos;all&apos; target with a specific package name, or names, and it will fix the permissions on only those webapp installs.

There&apos;s a few other little things, though they&apos;ll be properly documented in a man page shortly.  /me gets back to rolling 1.10-r15 .. :)</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>beu@gentoo.org</who>
            <bug_when>2005-05-15 09:49:20 0000</bug_when>
            <thetext>InCVS, though p.mask&apos;d as I have to go off for a few hours, and there&apos;s still a buglet remaining .. however, the the webapp-config bump has better error messages, permissions checks and all options bar --fix-toplevel-vhost-perms-only are working perfectly, from my _hours_ of testing ;)

Will get the last bug I know fixed when I get back and un p.mask then ..</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>beu@gentoo.org</who>
            <bug_when>2005-05-15 12:51:19 0000</bug_when>
            <thetext>Okay, I&apos;m back ;) - -r15 will be taken out of p.mask and unleashed within the hour ..
&lt;/bugspam&gt; ;p</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-05-16 05:32:20 0000</bug_when>
            <thetext>Woops still package masked-&gt;back to ebuild status.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>carlo@gentoo.org</who>
            <bug_when>2005-05-17 11:55:58 0000</bug_when>
            <thetext>Are you sure to fix the correct directories and don&apos;t go wild on the tree? &gt;&gt;
Bug 92958</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2005-05-20 10:28:51 0000</bug_when>
            <thetext>Elfyn,

I don&apos;t get it, -r15 was removed ? Which one is the fixed package ? Can we issue
a GLSA now on it ?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2005-05-27 04:52:24 0000</bug_when>
            <thetext>Stuart is on it and will keep us posted.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>stuart@gentoo.org</who>
            <bug_when>2005-05-30 04:59:17 0000</bug_when>
            <thetext>I&apos;m currently testing webapp-config v1.11 locally.  I&apos;ll let you know once 
it&apos;s in the tree.

Best regards,
Stu</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>stuart@gentoo.org</who>
            <bug_when>2005-05-30 12:57:05 0000</bug_when>
            <thetext>Hi,

webapp-config 1.11 is now in the tree.  Assuming I haven&apos;t missed anything, it 
includes fixes for all the security bugs discovered against webapp-config 1.10-
r11 or -r12.  v1.11 isn&apos;t marked stable yet - it needs wider testing before we 
can do that.  Hopefully I&apos;ll have some feedback in a couple of days.

I&apos;ve removed webapp-config v1.10-r14 from the tree.  It was too broken, sorry.

Best regards,
Stu</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>bmschwar@fas.harvard.edu</who>
            <bug_when>2005-05-30 14:45:39 0000</bug_when>
            <thetext>1.11 better go stable mighty quick.  Currently, anyone who&apos;s installed a recent
webapp like awstats 6.4 gets this message:

root # emerge -puDv world

These are the packages that I would merge, in order:

Calculating world dependencies        r                                  
!!! All ebuilds that could satisfy &quot;&gt;=net-www/webapp-config-1.10-r14&quot; have been
masked.
!!! One of the following masked packages is required to complete your request:
- net-www/webapp-config-1.11 (masked by: ~x86 keyword)

For more information, see MASKED PACKAGES section in the emerge man page or 
section 2.2 &quot;Software Availability&quot; in the Gentoo Handbook.
!!!    (dependency required by &quot;net-www/awstats-6.4&quot; [ebuild])


!!! Problem with ebuild net-www/awstats-6.4
!!! Possibly a DEPEND/*DEPEND problem.

!!! Depgraph creation failed.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jakub@gentoo.org</who>
            <bug_when>2005-05-30 15:47:21 0000</bug_when>
            <thetext>(In reply to comment #32)
&gt; v1.11 isn&apos;t marked stable yet - it needs wider testing before we 
&gt; can do that.  Hopefully I&apos;ll have some feedback in a couple of days.

Well, sorry, but you have broken portage (Bug 94559). Either mark it stable or
fix the eclass. :/</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-05-31 07:24:42 0000</bug_when>
            <thetext>web-apps please fix this. </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-05-31 07:30:55 0000</bug_when>
            <thetext>Sorry my mistake, already fixed. </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-06-04 00:41:48 0000</bug_when>
            <thetext>Stuart, are we ready to start stable marking? </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2005-06-12 03:03:18 0000</bug_when>
            <thetext>We have the go-ahead from Stuart.

Arches, please test and mark webapp-config-1.11 stable...
Target KEYWORDS=&quot;alpha amd64 arm hppa ia64 mips ppc ppc64 s390 sparc x86&quot;
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>hansmi@gentoo.org</who>
            <bug_when>2005-06-12 03:30:07 0000</bug_when>
            <thetext>Stable on ppc.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>killerfox@gentoo.org</who>
            <bug_when>2005-06-12 03:46:45 0000</bug_when>
            <thetext>Stable on hppa</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>kugelfang@gentoo.org</who>
            <bug_when>2005-06-12 09:48:50 0000</bug_when>
            <thetext>stable on amd64.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>weeve@gentoo.org</who>
            <bug_when>2005-06-12 10:52:14 0000</bug_when>
            <thetext>Stable on SPARC.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>corsair@gentoo.org</who>
            <bug_when>2005-06-13 07:27:48 0000</bug_when>
            <thetext>stable on ppc64 </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ferdy@gentoo.org</who>
            <bug_when>2005-06-13 07:59:29 0000</bug_when>
            <thetext>alpha happy</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>kloeri@gentoo.org</who>
            <bug_when>2005-06-15 12:19:02 0000</bug_when>
            <thetext>ia64 stable.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>tester@gentoo.org</who>
            <bug_when>2005-06-16 18:59:35 0000</bug_when>
            <thetext>sorry for the delauy, done on x86</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2005-06-16 19:08:57 0000</bug_when>
            <thetext>arm/s390 done</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2005-06-17 07:17:14 0000</bug_when>
            <thetext>GLSA 200506-13 
 
mips please remember to mark stable to benifit from the GLSA. </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>hardave@gentoo.org</who>
            <bug_when>2005-07-23 23:07:50 0000</bug_when>
            <thetext>Stable on mips.</thetext>
          </long_desc>
      
    </bug>

</bugzilla>