A.J. Clark

Solutions Architect

Mitigating PHP attacks with noexec file system mounts

with 2 comments

Recently, I investigated a security-compromised Apache web server. This particular web server hosted 500+ web sites and had fallen victim to script kiddies / attackers. An investigation revealed that the attackers exploitedan old Joomla CMS installation that a customer failed to update.  The attackers used the Joomla vulnerability to upload and execute a binary to /var/tmp.

An analysis of this nasty executable revealed that it was apparently capable of performing SYN floods and UDP floods as well as other nasty attacks. When launched, the executable connected to a private IRC server (active-sound.de:6667) where the bot received it’s orders. The Joomla installation was subsequently brought up to date, and the binary was removed. The owner of the web server realises that these problems are typical of an unmanaged hosting business, but never the less he would like to take steps to mitigate and/or prevent this happening again.

A simple and effective solution to this problem is to remount /tmp && /var/tmp file systems with noexec,nosuid options. If it is not possible to repartition the disk, you can mount these two directories as tmpfs. This protects against any backdoors or irc DDoS bots from actually executing thus preventing the server from falling in to the hands of attackers. This protection can be mean the difference between your server being rooted and/or being turned in to a DDoS / spam drone.

Written by napta2k

March 13, 2009 at 3:45 pm

Posted in Linux

2 Responses

Subscribe to comments with RSS.

  1. noexec is a good idea but don’t rely on it too heavily. It’s easily circumvented as shown below

    playground ~ # cat /test/evil.sh
    #!/bin/bash
    echo ‘Evil deeds!’

    playground ~ # /test/evil.sh
    -bash: /test/evil.sh: /bin/bash: bad interpreter: Permission denied

    playground ~ # bash /test/evil.sh
    Evil deeds!

    No real reason not to use the noexec feature but it’s no solution for poorly written PHP scripts.

    sethisroot

    March 23, 2009 at 8:38 am

    • Hi Scott,

      Quite right, this will not prevent interpreted languages from being read from the noexec file system. Although I don’t agree that the above circumvents the noexec in the technical sense since nothing is actually executed ;) – point taken on the real world usage, though. If an attacker can’t exec a binary, he may resort to running some evil perl/bash/python/php/…

      Thanks :)

      napta2k

      March 24, 2009 at 8:56 am


Leave a Reply

You must be logged in to post a comment.