Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 74698 - dev-php/asp2php-0.76.19: preparse() overflows token and temp buffer
Summary: dev-php/asp2php-0.76.19: preparse() overflows token and temp buffer
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All All
: High enhancement (vote)
Assignee: Gentoo Security
URL:
Whiteboard: B2 [upstream+ masked toremove]
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-16 15:25 UTC by Sascha Silbe
Modified: 2005-10-04 10:21 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
File 29-1.asp from advisory (bug74698-29-1.asp,1.38 KB, application/octet-stream)
2004-12-16 15:26 UTC, Sascha Silbe
no flags Details
File 29-2.asp from advisory (bug74698-29-2.asp,2.39 KB, application/octet-stream)
2004-12-16 15:26 UTC, Sascha Silbe
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sascha Silbe 2004-12-16 15:25:37 UTC
The following advisory from securesoftware@list.cr.yp.to for asp2php 0.76.23, but I was able to get dev-php/asp2php-0.76.19 to SegFault using the given exploits, so it's probably vulnerable.

Date: 15 Dec 2004 08:21:54 -0000
From: "D. J. Bernstein" <djb@cr.yp.to>
Subject: [remote] [control] asp2php 0.76.23 preparse() overflows token buffer;
+preparse() overflows temp buffer
To: securesoftware@list.cr.yp.to, mike@mikekohn.net
X-HELOcheck: OK: FQDN
Mailing-List: contact securesoftware-help@list.cr.yp.to; run by ezmlm
Mail-Followup-To: securesoftware@list.cr.yp.to, mike@mikekohn.net
Automatic-Legal-Notices: See http://cr.yp.to/mailcopyright.html.

[-- Attachment #1 [details] --]
[-- Type: text/plain, Encoding: 7bit, Size: 1.6K --]

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

You are at risk if you take an ASP script from an email message (or a
web page or any other source that could be controlled by an attacker)
and feed that script through asp2php. (The asp2php documentation does
not tell users to avoid taking input from the network.) Whoever provides
that script then has complete control over your account: she 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://downloads.mikekohn.net/asp2php/asp2php-0.76.23.tar.gz
   gunzip < asp2php-0.76.23.tar.gz | tar -xf -
   cd asp2php-0.76.23
   make

to download and compile the asp2php program, version 0.76.23 (current).
Then save the file 29-1.asp attached to this message, and type

   ./asp2php 29-1.asp

with the unauthorized result that a file named EXPLOITED is created in
the current directory. 29-2.asp is similar but uses a separate buffer
overflow. (I tested these with a 541-byte environment, as reported by
printenv | wc -c.)

Both buffer overflows can be blamed on gettoken(), which has a
fundamentally broken gets()-style API. The preparse() function calls
gettoken() to read data into a 1024-byte token[] array, and to read data
into a 1024-byte temp[] array.

---D. J. Bernstein, Associate Professor, Department of Mathematics,
Statistics, and Computer Science, University of Illinois at Chicago
Comment 1 Sascha Silbe 2004-12-16 15:26:33 UTC
Created attachment 46173 [details]
File 29-1.asp from advisory
Comment 2 Sascha Silbe 2004-12-16 15:26:58 UTC
Created attachment 46174 [details]
File 29-2.asp from advisory
Comment 3 Luke Macken (RETIRED) gentoo-dev 2004-12-18 16:09:09 UTC
php herd, please verify/advise.
Comment 4 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-12-18 19:14:51 UTC
asp2php (both 0.76.23 and 0.76.19) segfault for me, but it does NOT create the 'EXPLOITED' file as described here.
Comment 5 Thierry Carrez (RETIRED) gentoo-dev 2004-12-19 05:53:27 UTC
That's expected, since the exploit is tuned for FreeBSD 4.10... Upstream isn't completely dead so we can still hope they will release a fix for it.
Anyway, exploitation path for this is very unlikely and requires serious social engineering, so I think we can wait a little.
Comment 6 Thierry Carrez (RETIRED) gentoo-dev 2004-12-21 06:55:08 UTC
======================================================
Candidate: CAN-2004-1261
URL: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-1261
Reference: MISC:http://tigger.uic.edu/~jlongs2/holes/asp2php.txt

Multiple buffer overflows in the preparse function in asp2php 0.76.23
allow remote attackers to execute arbitrary code via crafted ASP
scripts.
======================================================
Comment 7 Thierry Carrez (RETIRED) gentoo-dev 2004-12-28 04:30:37 UTC
Sent email upstream to get release status.
Comment 8 Thierry Carrez (RETIRED) gentoo-dev 2004-12-30 01:52:41 UTC
Upstream acks but won't fix it.

"This report is the most idiotic thing i've ever heard of in my life... asp2php is a command line program, not a networked program.  if asp2php can be used to delete files or get root access to a system, then the kernel itself has security holes, not asp2php..."

I think we should mask it prior to removal.
Comment 9 Thierry Carrez (RETIRED) gentoo-dev 2004-12-30 08:33:29 UTC
PHP team please comment.
Comment 10 Stuart Herbert (RETIRED) gentoo-dev 2004-12-30 08:54:54 UTC
Okay.  It doesn't look that hard to patch, but I'm not happy with Gentoo carrying packages where there's no support from UPSTREAM on security bugs.  DJB's tone (as per usual) probably didn't help there :-)

I'm masking the package, and sending an email upstream.  If I don't hear back from upstream by the end of January, we'll drop this package.

Best regards,
Stu
Comment 11 Thierry Carrez (RETIRED) gentoo-dev 2004-12-30 08:59:04 UTC
Package has been masked
Comment 12 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-01-04 20:01:24 UTC
(now back from my vacation)
I would agree with the author that the user that runs asp2php on untrusted input deserves everything they get. However I do believe that it should still be fixed.
Comment 13 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2005-02-13 05:40:37 UTC
Any ETA on a fix for this or should we drop the package?
Comment 14 Stuart Herbert (RETIRED) gentoo-dev 2005-02-13 11:06:36 UTC
UPSTREAM has no intention of fixing the package.  I'm in favour of dropping it.

Best regards,
Stu
Comment 15 Dan Margolis (RETIRED) gentoo-dev 2005-03-07 18:20:24 UTC
What's the specific policy regarding masking versus removing? I'd be in favor of masking with a memo about why--after all, so long as a user knows about the vulnerability, it's essentially not a vulnerability (while I'm not as angry as the upstream maintainer, this *is* a fairly minor issue). The vuln treatment policy doesn't say that there's anything wrong with doing this. 
Comment 16 Thierry Carrez (RETIRED) gentoo-dev 2005-03-08 02:19:55 UTC
The (unwritten) policy is that a security-masked package should be removed after 60 days if upstream situation did not evolve... and maintainer agrees.

If you think we should change this policy (and keep security-masked packages in the tree) please submit a new bug, for example in "GLSA Errors" component, so that we can further discuss this, as this is more far-reaching than the asp2php specific case.
Comment 17 Matthias Geerdsen (RETIRED) gentoo-dev 2005-05-13 01:39:22 UTC
ebuild has been masked 30 dec 2004, so it should be read for removal by now
Comment 18 Sebastian Bergmann (RETIRED) gentoo-dev 2005-05-13 01:51:40 UTC
dev-php/asp2php has been removed from the tree.
Comment 19 Patrizio Bassi 2005-10-04 09:16:11 UTC
that's a new upstream version..can you readd this package to tree?  
Comment 20 Thierry Carrez (RETIRED) gentoo-dev 2005-10-04 10:21:15 UTC
According to their Changelog, the issue is not fixed.

When it will be fixed (or when you can prove it has been fixed) you should open
a new bug and ask for it to be included in Portage like a new package.