473,756 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

security question(s)

I am new to PHP but have done other programming
can someone please hold my hand and slowly talk me through some simple
security issues?

I have seen in PHP documents that there are 'strip slashes' commands and
so on but I dont understand where the security issues actually are.

i am writing some scripts that will shell out and call different linux
shell programs such as 'ls' or 'grep' or 'sed' and so on and possibly
update a 'mysql' database.

can you tell me at what point in this procedure security is needed and
what exactly as ideally I would like to not hamper anything I send to
grep and so on? In other words I would like any security modification of
my parameters to happen as late in the process as possible.

I am obviously interested in how to stop someone using pipes '||' or
redirecting the output '>' or entering anything that might trigger the
database to think i was getting code or a varialble of some sort - I
think that may just be '$' but dont really know. Are there any actual
strings rather than characters that must be watched for?

can someone explain what point the issues take effect - is it php, or
when php passes the parameters or is it the (eg) 'grep' program itself
that is written to do things that must be prevented or is it linux
itself when it passes the parameters?

and is there anything else I need to watch out for?

can anyone explain in simple terms please (perhaps a security table ?)

nancy
Nov 27 '06 #1
1 1497
>I am new to PHP but have done other programming
>can someone please hold my hand and slowly talk me through some simple
security issues?
"simple" and "security issues" don't go together.
>I have seen in PHP documents that there are 'strip slashes' commands and
so on but I dont understand where the security issues actually are.
If you allow user-supplied input on a shell command-line unaltered, you are
asking for trouble. Consider, for example, the search pattern:

`rm -rf /`

and if you stick it into a shell command:

grep "`rm -rf /`" INDEX.txt | pretty_up_index _entries

it's likely to do a lot of damage to your system. One approach to
dealing with this is to quote the string appropriately for the shell
being invoked.

>i am writing some scripts that will shell out and call different linux
shell programs such as 'ls' or 'grep' or 'sed' and so on and possibly
update a 'mysql' database.
Also beware of wierdly-formatted stuff that becomes dangerous SQL,
such as entering a user name such as:
george' OR '' LIKE '
substitued into sql that says:
DELETE FROM users where user = '$user'

DELETE FROM users where user = 'george' OR '' LIKE ''
which deletes all the records in users.
>can you tell me at what point in this procedure security is needed and
what exactly as ideally I would like to not hamper anything I send to
grep and so on? In other words I would like any security modification of
my parameters to happen as late in the process as possible.
Security should be designed in as EARLY as possible. Bolting a
very secure vault door onto a building originally intended as a
greenhouse (including its glass walls and rickety screen back door with
no lock) doesn't make a very good bank vault.
>I am obviously interested in how to stop someone using pipes '||' or
redirecting the output '>' or entering anything that might trigger the
database to think i was getting code or a varialble of some sort - I
think that may just be '$' but dont really know. Are there any actual
strings rather than characters that must be watched for?
What USER-SUPPLIED input is going to be used (especially on the command
line, but worry about the data passed to the command also)? Where?

If you are putting stuff in as a command-line argument, you probably
have to worry about:

- quotes
- shell variable substitutions
- backquote substitutions
- any way to get command terminators (like semicolon, |, ||,
&, &&, etc.) followed by a new command outside quotes

If you pass the input through the PHP function escapeshellarg( )
before putting it on the command line, it should be safe (at least
for reasonably normal UNIX shells).

If you are substituting stuff for use within a quoted string in a
SQL query, you need to make sure it can't get outside the quotes
(mysql_escape_s tring() is one possibility).
>can someone explain what point the issues take effect - is it php, or
when php passes the parameters or is it the (eg) 'grep' program itself
that is written to do things that must be prevented or is it linux
itself when it passes the parameters?
Unchecked user-supplied strings in shell commands are very touchy.
Unchecked user-supplied strings in file names (e.g. passed to PHP
fopen()) are touchy. For example, "../../../../../../../etc/passwd"
is likely to refer to the password file, which someone might download
for cracking or spamming purposes. Unchecked user-supplied strings
in any mail headers you send are very touchy (they can be abused
to spam large numbers of people). Unchecked user-supplied parameters
passed to the PHP eval function are very touchy. Unchecked
user-supplied parameters passed to include() are very touchy,
especially if remote URLs are allowed, and this is used by a number
of viruses. Allowing the user to post articles containing raw
Javascript (or for that matter, even certain HTML) allows that user
to hijack other user's browsers when they view the post.

This list is nowhere near complete.
>and is there anything else I need to watch out for?
TRUST NO ONE.
>can anyone explain in simple terms please (perhaps a security table ?)
Exercise: list all the ways of stealing money out of a state-of-the-art ATM
that requires a smart card with RSA certificates to open the money-loading
compartment.



Think of your answer, then scroll down.





















If even half of your answers are ways to make a fake smart card,
you aren't thinking far enough outside the box.

If you didn't include anything about wrapping a chain around the
ATM, pulling it out of the ground, driving off with it, and then
blowing it open with explosives, you're not thinking far enough
outside the box.

If you didn't include anything about bribing the guy who loads the
machine, you're not thinking far enough outside the box.

If you didn't at least think about whether it is possible to teleport
the ATM away leaving the cash, you're not thinking far enough outside
the box.

If you didn't include anything about stealing what the cash is
backed with, thereby making the cash worthless, you're not thinking
far enough outside the box.

Nov 29 '06 #2

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

Similar topics

116
7546
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!
32
2817
by: Mike MacSween | last post by:
Further to 'Security - more complex than I thought' Has anybody ever seen any studies? Or anecdotal evidence? Done any studies themselves? Done any lab testing - you know - 10 users asked to get past Access (or other) security? It'd be interesting to know. And no, I don't have any prejudices. Yours, Mike MacSween
5
2186
by: Greg Strong | last post by:
Hello All, What are the best ways to implement security for Access databases (i.e. ..MDB files)? I ask the question from a general perspective. Why? Well I had written a prototype database which I split. So I thought that I'd implement security on it. The security worked great for both groups (i.e. Admins & Users), but after looking at the detail I took it a little further.
1
1918
by: Jeremy S. | last post by:
..NET's code Access Security enables administrators to restrict the types of things that a .NET application can do on a local computer. For example, a ..NET Windows Forms application can be prevented from writing to the Registry or writing a file to the local disk. My question: Is this feature unique to .NET? Or is it just as easy for enterprise network administrators to prevent COM applications from writing to the Registry and doing...
15
10510
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...
0
1823
by: jobs | last post by:
Using the delivered login controls, I see there is something for passwordrecovery. But I can't seem to find how to set properties so it does not ask me for my security question. Is there any way to use the delivered controls to do what most sites do today, where if I lost my password, I simply enter my user name or email address and it mails it to. If my user name or email are not in the database, I get an error, otherwise a new password...
18
2026
by: Earl Anderson | last post by:
First, I feel somewhat embarrassed and apologetic that this post is lengthy, but in an effort to furnish sufficient information (as opposed to too little information) to you, I wanted to supply all of the relevant facts. Second, despite the fact that I think the obvious 'quick' answer to my question would be 'Yes', I am seeking your wisdom and recommendation to the question as to this particular set of circumstances. I have 20 Security...
4
3075
by: vincent90152900 | last post by:
How to remove Security Question and Security Answer from membership provider? Following is my codes. Please tell me how to remove Question and Answer from membership provider. Thank you for replying. CreateNewWizard.aspx <asp:CreateUserWizard ID="CreateUserWizard1" runat="server"> <WizardSteps> <asp:CreateUserWizardStep runat="server"> </asp:CreateUserWizardStep> ...
1
5559
by: =?Utf-8?B?aGVyYmVydA==?= | last post by:
Question 1: How do I turn off WCF security to get my apps out the door quickly? Question 2: Where can I find a step by step article/flowchart how to configure WCF security (the WCF books miss this point)? Background: I have a WCF client / WCF host pair running fine on the same machine. Metadata is offered both via basicHttp and netTcp. Services are offered via netTcp. When distributing the WCF client on the intranet, everybody (my...
2
7667
by: Ken Fine | last post by:
I want to add the security question and answer security feature to the ChangePassword control. I am aware that this functionality is built into the PasswordRecovery tool. I have implemented the PasswordRecovery with a Password reset required; a temporary password is sent to the account on file. I want an extra layer of security to accommodate the very unlikely contingency that someone's e-mail account is compromised. Challenging with the...
0
9716
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
9716
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
9571
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8569
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...
1
7116
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4996
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3676
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
2
3185
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2542
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.