|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
SitePoint Articles
Join Date: Apr 2001
Posts: 0
|
Article Discussion
This is an article discussion thread for discussing the SitePoint article, "Top 7 PHP Security Blunders"
|
|
|
|
|
|
#2 |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Oct 2005
Location: in front of my computer
Posts: 570
|
yes, it's a good article! great idea too!
still many things i need to know when it comes to PHP security.. :'( |
|
|
|
|
|
#3 |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Mar 2005
Posts: 458
|
nice article! enjoyed reading it...
![]() |
|
|
|
|
|
#4 |
|
Team SitePoint
![]() Join Date: Apr 2000
Location: Melbourne
Posts: 1,004
|
Wow. Now that's what I call a comprehensive critique. Impressive, Shiflett.
|
|
|
|
|
|
#5 |
|
SitePoint Enthusiast
![]() Join Date: Aug 2002
Posts: 63
|
An easy way to secure files from being directly accessed is to include the following code at the top of each file. This method has the advantage that does not rely upon the hosting environment to secure the files.
PHP Code:
|
|
|
|
|
|
#6 |
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Apr 2004
Location: germany
Posts: 4,321
|
In addition to what's already said, "$_GET[month]" is an invalid syntax.
|
|
|
|
|
|
#7 |
|
SitePoint Zealot
![]() ![]() Join Date: May 2003
Location: Midwest
Posts: 108
|
No mention by the article or anyone else about the location of there config file..
If at all possible ALWAYS put your config files outside of your web path. This reduces the risk of exposure due to things like a bad php upgrade. |
|
|
|
|
|
#8 | |
|
SitePoint Mentor
![]() Join Date: Apr 2004
Location: Melbourne, Australia
Posts: 903
|
Here we go again... addslashes()
![]() Quote:
Code:
SELECT * FROM users WHERE name='$username' AND pass='$password'; $password = blah' OR 1=1 OR 'blah' = 'blah Solution to this: firstly always have a list of accepted formats for your inputs, and reject whatever doesn't match one of those. Secondly, use a query builder or prepared query, like what PEAR-DB or ADODB support. 1=1 will not work if you use prepared queries. Some more: Configuring PHP For Security -> open_basedir - should set this in your vhost: Code:
<Directory /path/to/website>
php_admin_value open_basedir "/path/to/website:/tmp"
</Directory>
|
|
|
|
|
|
|
#9 |
|
SitePoint Zealot
![]() ![]() Join Date: Nov 2002
Location: Belgium
Posts: 155
|
To my opinion using open_basedir has less use because it only applies to PHP and not to any other language you may use: Perl, Ruby, Python, ...
|
|
|
|
|
|
#10 |
|
SitePoint Zealot
![]() ![]() Join Date: Aug 2005
Posts: 123
|
Magic quotes will almost assuredly be removed from PHP6.
Here's the developers notes from a meeting about PHP6. http://www.php.net/~derick/meeting-n...l#magic-quotes Not every server will have magic quotes enabled anyways, so no matter what you have to check all the incoming data. |
|
|
|
|
|
#11 |
|
SitePoint Zealot
![]() ![]() Join Date: Mar 2004
Location: Australia
Posts: 104
|
Beware of XSS! Some examples of possible ways to inject javascript into your output.
http://ha.ckers.org/xss.html So far, i have found http://pixel-apes.com/safehtml to be a good solution in escape the output. Other solution to reduce XSS in the output are most welcome. Wei. |
|
|
|
|
|
#12 |
|
SitePoint Enthusiast
![]() Join Date: May 2005
Posts: 51
|
A good protection against session-jacking.
When a user logs in, set their ip to a session var using $_SERVER['REMOTE_ADDR']. On ever page, ensure this session var equals $_SERVER['REMOTE_ADDR'], if not, log them out. |
|
|
|
|
|
#13 |
|
SitePoint Enthusiast
![]() Join Date: Jun 2002
Location: Melbourne
Posts: 59
|
Argh. http://phpsec.org should definately be consulted. http://www.hardened-php.net/ is another good site. There are enough mediocre PHP developers out there, we don't need articles like this.
|
|
|
|
|
|
#14 |
|
SitePoint Addict
![]() ![]() ![]() Join Date: Oct 2004
Location: New York
Posts: 359
|
Can we please get this article corrected? I tried to politely (and quickly) point out the errors I noticed at first glance, and others have done the same.
Spreading this type of misinformation from such a popular site is hurting the PHP community. |
|
|
|
|
|
#15 | |
|
SitePoint Zealot
![]() ![]() Join Date: Jul 2005
Location: Venlo, the Netherlands
Posts: 143
|
Quote:
I know it's hard to cover a subject like this, but the amount of missers in this one make this article a 'blunder' in it's own right. |
|
|
|
|
|
|
#16 | |
|
SitePoint Member
Join Date: Mar 2005
Posts: 7
|
Quote:
Shiflett has helped out by clarifying some critical points (especially in the area of input and Magic Quotes). Thanks Shiflett. Anyways... that's my two cents... -Aaron |
|
|
|
|
|
|
#17 | |
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Nov 2004
Location: Lincoln Nebraska
Posts: 1,136
|
I agree, this article is downright dangerous. This makes our job in the forums, that much harder. addslashes and magic_quotes should NEVER be recommended. They should only be mentioned as being insecure. Any time I see this sort of code published anywhere, I don't hesitate to raise some hell about it. I hate to see this kind of misinformation associated with Sitepoint. Quote:
![]() |
|
|
|
|
|
|
#18 | |
|
SitePoint Member
Join Date: Mar 2005
Posts: 7
|
I think it would be best to let PHP speak on the issue. For me, the greatest resource ever for PHP is the PHP manual.
Quote:
Compare http://us3.php.net/manual/en/securit...quotes.why.php to http://us3.php.net/manual/en/securit...tes.whynot.php Choose accordingly... |
|
|
|
|
|
|
#19 |
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2003
Location: Germany
Posts: 1,495
|
Guys, stop trying to correct their articles. SitePoint clearly doesn't give a ****
. |
|
|
|
|
|
#20 | |
|
SitePoint Addict
![]() ![]() ![]() Join Date: Oct 2004
Location: New York
Posts: 359
|
Quote:
It has been bookmarked by more than 500 people on del.icio.us: http://del.icio.us/url/6a721e590a294c9278ff8c4396ad65f8 (This is almost exactly how many people have bookmarked the PHP Security Guide.) SitePoint is ranked 681 on Alexa: http://www.alexa.com/data/details/?url=sitepoint.com/ In other words, this is a very popular and very misinformative article. This is hurting the PHP community, and I am extremely disappointed that neither the author nor SitePoint seem to care. If there was a more appropriate place for me to have directed my initial comments, please feel free to let me know. I'm very interested in getting this article corrected. |
|
|
|
|
|
|
#21 |
|
SitePoint Zealot
![]() ![]() Join Date: Jan 2005
Location: NY
Posts: 158
|
For an Administration script I wrote, I retrieve the password FIRST and then compare the md5'ed USER INPUT to the stored md5 version, which I retrieved first.
User data never touches my database, unless I trust the user or I enforce data structure limitations/format. |
|
|
|
|
|
#22 |
|
SitePoint resident know-it-all
![]() ![]() Join Date: Apr 2000
Location: Melbourne, Australia
Posts: 2,877
|
Actually, I've just updated the article to correct most of the critiques that were raised against it in this thread. If anyone is motivated to do so, please let me know if there are any significant issues I have missed.
|
|
|
|
|
|
#23 | |||||||||||
|
SitePoint Addict
![]() ![]() ![]() Join Date: Oct 2004
Location: New York
Posts: 359
|
Quote:
I'll restate the items from my original (likely incomplete) list that have not been completely addressed. Hopefully others will do the same, and I'll be happy to clarify anything that needs it. Quote:
Quote:
Quote:
Quote:
Executing code out of context is an additional and unnecessary risk. I would argue that it's safer to instruct Apache to deny access to .inc resources (in httpd.conf) and store includes outside of document root. That's Defense in Depth. Naming includes .php eliminates the potential to add this extra safeguard, plus it just exchanges one risk for another. Quote:
However, I think it's pretty important that we remind developers of the importance of character encoding consistency. I blogged about this recently, using Google's XSS vulnerability as an example: http://shiflett.org/archive/178 This shows how htmlentities() doesn't offer sufficient XSS protection without indicating the character encoding. Quote:
Quote:
Quote:
Quote:
Quote:
Thanks again for your efforts. It helps your users to know that their attempts to help out are worthwhile. :-) |
|||||||||||
|
|
|
|
|
#24 |
|
SitePoint Member
Join Date: Mar 2005
Posts: 6
|
I find it sad that even after it was 'updated', it still won't even run without produce notices. Not to mention the fact that the terribly slow regex is being used instead of is_numeric().
|
|
|
|
|
|
#25 |
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jul 2005
Location: At my computer
Posts: 2,253
|
That is a good solution but if someone has access to your .htaccess then your screwed. But if they have access to you .htaccess then they probably have access to your files to.
|
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 01:03.















Hybrid Mode
