Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
HOw to protect yourself against malicious php code
Old 08-12-2009, 12:10 AM HOw to protect yourself against malicious php code
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
This is a simple question, and I'm sure I could figure it out myself, but I wanted some of your ideas. How would you protect users from uploading malicious code through forms. For example. Say I wanted to cause harm to this forum and decided I hated the php forum so I wanted to just delete the directory. My first plan would be to post the following code in one of my threads

PHP Code:
<?php
rmdir
('php-forum');
?>
Of course, I would do this without the code tags around it. How could you protect your forms from code like this. I believe this forum converts symbols like < to &lt; and I think this is a simple security feature they use to protect there forums, and I know how to do this with php, but are there better more advanced ways of protecting yourself?

Thanks
__________________
Alex
konetch is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-12-2009, 01:18 AM Re: HOw to protect yourself against malicious php code
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
As long as you don't do anything like:

PHP Code:
eval($_POST['formdata']); 
This shouldn't be a problem. Code submitted via a form is never evaluated as PHP code unless the coder does so explicitly. So without any validation or character conversion, form data is still safe from what I suppose you would call a PHP injection.

By the way, the code you posted most likely would just generate a warning. I really doubt there is a physical directly on this server called php-forum. The illusion of a directory structure is generated through htaccess.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 08-12-2009, 03:40 AM Re: HOw to protect yourself against malicious php code
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
The key thing is to ensure that the file is never on the server in an executable format or, as Matt said, executed directly. To ensure this (as well as conserve space), I zip the files upon upload.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to HOw to protect yourself against malicious php code
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.46132 seconds with 12 queries