TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-14-2008, 09:33 PM   #1 (permalink)
The Acquainted
 
drewbee's Avatar
 
Join Date: May 2008
Posts: 175
Thanks: 9
drewbee is on a distinguished road
Default Security uploading

Hey all,

I am here to try and cover all aspects of security that I can think of. The site I am currently working on will have the needed ability for users to upload a zip file, of which will be extracted to my server. They are website templates and as such an API is being used to capture screenshots. This is a very dangerous thing, and I would like to cover and protect myself as best as possible. If you have any ideas, thoughts, or suggestions on things I can do better, please let me know.


This is going to be spaghetti code, so please bare with me. Also note all of the extensions, mime types aren't listed this is just for example

validExtentions = .htm .html .gif .png .jpg .jpeg .pdf .swf .fla .doc .txt
validMime = text/html, text/gif, text/png, text/jpg, text/pdf, flash, text/doc

function mime_type
return : shell_exec : escapeshellcmd ("file -bi $temp_file")
end;

Upload Zip:
if extension is zip and mime_type is zip
allow processing
else
error: only zip files allowed


Process Zip
loop through all files in zip
if file is not valid extension or valid mime
: remove from zip
end loop;

extract remaining files to public_html/templates/$template_id directory.
notes: directory is only accesible by 1 specific external API IP (screenshot API).
My own server doesn't have rights to execute. Only write/read.
Resave zip file with invalid files ommited

capture screenshots finished, template approved- all files are removed from public directory.

----------------

So, these files are out on my server for the time it takes the user to upload the zip file and approve the template (basically).

Is there anything else I can do so that this can further be locked down? The directory will also exist at an undisclosed location. In any event that they happen to stumble acrossed it (obviously some malicious user looking for something), a 404 will simply be displayed. All IP's (unless of the API's server will find nothing but a 404).

__________________
There are No Stupid Questions. But there a LOT of Inquisitive Idiots.
Send a message via AIM to drewbee
drewbee is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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


All times are GMT. The time now is 10:40 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0