[UNIX] Directory.php Allows Arbitrary Code Execution

From: support@securiteam.com
Date: 03/11/02


From: support@securiteam.com
To: list@securiteam.com
Date: Mon, 11 Mar 2002 13:31:51 +0100 (CET)

The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
- - promotion

When was the last time you checked your server's security?
How about a monthly report?
http://www.AutomatedScanning.com - Know that you're safe.
- - - - - - - - -

  Directory.php Allows Arbitrary Code Execution
------------------------------------------------------------------------

SUMMARY

 <http://www.xenakis.net> Marcus S. Xenakis has developed some quite nice
PHP scripts to support shell commands.
The "directory.php" script is based on the "ls" command and reads the
directory based upon the passed parameter.

A security problem in this script allows viewing of arbitrary directories
on the file system.
Furthermore it allows arbitrary code execution caused by missing filters
for dangerous characters such as ";". This is quite the same as the
<http://www.securiteam.com/unixfocus/6K00B2A3FG.html> Unix Manual PHP
Script bug of the same author, which was discovered and fixed recently.

DETAILS

Marcus S. Xenakis PHP-Scripts very often use simple calls of shell
commands:

exec("ls -la $dir",$lines,$rc);

This is quite easy programming but doesn't deal with dangers that calls of
shell commands can bring.

Impact:
It is possible to execute arbitrary code with the rights of the
HTTP-Daemon

Exploit:
In contrary to the "Unix Manual PHP Script" this script doesn't offer a
form where you can enter the commands. Because of that you have to call
the script directly including the parameter and command you want to
execute.

http://www.example.com/directory.php?dir=%3Bmore%20/etc/passwd
will show you the Password File.

http://www.example.com/directory.php?dir=%3Bps+-aux
will show you all running processes.

Solution:
Implement a filter which filters dangerous characters, especially ";".

Vendor Status:
Vendor has been contacted.

ADDITIONAL INFORMATION

The information has been provided by
<mailto:advisories@it-checkpoint.net> BlueScreen.

========================================

This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com

====================
====================

DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.



Relevant Pages

  • SUMMARY WAS: OT? Philosophical Question on SA responsibilities
    ... helpful for managers interested in hiring new administrators. ... Would you go thru the 14,600 messages in root and admin ... If I was a new SA I would if encountering a security hole, ... I can see some use for the passwd -s part of the crontab script, ...
    (SunManagers)
  • Re: Clarification-Win2k Netstat sockets interpretation
    ... snip.. ... Before I could manually download every security upate and servicepack from MS.com but now...they send you a bit of Cop-code that fails to run unless ALL defences are down ... Are you sure the script from ntsvcfg is benign in addition to being useful? ... You are absolutely correct there HAL, er ah, Sebastian. ...
    (alt.computer.security)
  • [NT] Flaw in Windows Script Engine Could Allow Code Execution
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... The Windows Script Engine provides Windows operating systems with the ... blocked by Outlook Express 6.0 and Outlook 2002 in their default ...
    (Securiteam)
  • Re: BUG with RES/SCRIPT/XP-SP2
    ... I consider JavaScript (known to security people as JavaVirus) as one of the Really Top ... to have a bad script cause damage to my machine. ... This security feature is called the "Local Machine Zone Lockdown". ... Tags, and the CDHtmlDialog class in this forum, and got no response. ...
    (microsoft.public.vc.mfc)
  • BUG with RES/SCRIPT/XP-SP2
    ... This security feature is called the "Local Machine Zone Lockdown". ... past week since I started posting problems with the RES Protocol, SCRIPT ... Tags, and the CDHtmlDialog class in this forum, and got no response. ...
    (microsoft.public.vc.mfc)