Webmaster Forum

Sponsored Reviews   Keyword Research Tool   V7N Directory
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Reply
 
LinkBack Thread Tools Display Modes
Old 09-07-2007, 02:36 PM   #1 (permalink)
Inactive
 
nster's Avatar
 
Join Date: 11-06-06
Posts: 16
iTrader: 0 / 0%
Latest Blog:
None

nster is liked by many
Question How to secure this PHP e-shop script ???

Hello guys,
i need your help, especially i 'll appreciate it most from the many experience users that i see that exist over here !

I want to make a simple online-shop (eshop) using PHP & Mysql . After lot of time searching on the web, finally i found this very good tutorial => http://www.thewatchmakerproject.com/...-shopping-cart that makes it real

But, but.. i read the code and comments and finally use it in my local apache server and it worked allright ..BUT, when i when up to the browser 's toolbar and i tried to change this : http://localhost/cart/cart-demo/cart...ction=add&id=1

to this
http://localhost/cart/cart-demo/cart...tion=add&id=-1

it started to add values, books for the instace even that am giving a negative number..

the worst ?

when i tried to change this :
http://localhost/cart/cart-demo/cart...ction=add&id=1

with this one :
http://localhost/cart/cart-demo/cart.php?action=add&id='1
or with this one :
http://localhost/cart/cart-demo/cart.php?action=add&id='

the whole system of this e-shop script "collapsed" ..i mean it started to give me ERRORS and book added without i to choose them..

From my medium knowlege on these issues i understand, this is a security issue.. i cant imagine what can hapenned if i use it on my web site as it is now..

My question is about to help,
help me please to firstly, understand the problem , secondly teach me how to fix it, so that i can learn the vunerabilities of this script and finally build up a secure as it is possibe e-shop with this script

I want to learn !
plz be kind

am waiting for your answers with huge interest !

Thanks in advance !


* ..you can download the code from the tutorial web site that provides this script the .zip file in the end of page so that you can test it your self and see what i mean !

Last edited by nster : 09-07-2007 at 02:43 PM.
nster is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 09-08-2007, 02:02 AM   #2 (permalink)
Inactive
 
Join Date: 09-08-07
Location: Jeddah, Saudi Arabia
Posts: 2
iTrader: 0 / 0%
Latest Blog:
None

AYYASH is liked by many
Send a message via MSN to AYYASH Send a message via Skype™ to AYYASH
The basic security rule is "every information that comes in or out your application is not allowed except what you permit".
You need to check your code and find what parts that handels query string values. Add more strict filters to define if the values you're getting through query string are true compared to what is in the data base (or any other source) or not. If every thing is true then implemnt the rest of the code. If not, stop the code and switch the user to the error page.
AYYASH is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-08-2007, 11:18 AM   #3 (permalink)
Contributing Member
 
Join Date: 02-10-07
Posts: 326
iTrader: 1 / 100%
Latest Blog:
None

ScriptMan is just really niceScriptMan is just really niceScriptMan is just really niceScriptMan is just really niceScriptMan is just really niceScriptMan is just really niceScriptMan is just really niceScriptMan is just really niceScriptMan is just really niceScriptMan is just really niceScriptMan is just really nice
If I understood what you asked, the reason your program crashed is BECAUSE you used the '. The single and double quote characters are reserved and serve definate functions within php. Yo can not use them in this manner.

A well writen script will have traps built in the disallow or parse out the reserved characters.
__________________
ScriptMan
Gardening?
ScriptMan is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-08-2007, 12:48 PM   #4 (permalink)
v7n Mentor
 
TheFriend's Avatar
 
Join Date: 08-31-07
Location: Germany (chatrooms/ forums)
Posts: 3,647
iTrader: 0 / 0%
Latest Blog:
None

TheFriend is a glorious beacon of lightTheFriend is a glorious beacon of lightTheFriend is a glorious beacon of lightTheFriend is a glorious beacon of lightTheFriend is a glorious beacon of lightTheFriend is a glorious beacon of lightTheFriend is a glorious beacon of lightTheFriend is a glorious beacon of lightTheFriend is a glorious beacon of lightTheFriend is a glorious beacon of lightTheFriend is a glorious beacon of light
Send a message via MSN to TheFriend
http://www.php-resource.de/scripte/b.../E-Commerce/1/
http://hilfe-center.1und1.de/ipaymen...payment/1.html
That's everything for help.....
TheFriend is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-08-2007, 03:07 PM   #5 (permalink)
Contributing Member
 
Join Date: 06-11-07
Posts: 136
iTrader: 0 / 0%
Latest Blog:
None

Capo64 is on the right pathCapo64 is on the right path
make a function that returns whether or not an item exists depending on its ID and make your cart code look something like this:

Code:
case 'add': if (itemExists($_GET['id'])) { //itemExists would be your func that returns true if an item exists in the db //rest of your code here } break;
Capo64 is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-10-2007, 09:40 AM   #6 (permalink)
Contributing Member
 
Join Date: 09-03-07
Location: England
Posts: 358
iTrader: 0 / 0%
Latest Blog:
None

Boogle is liked by somebodyBoogle is liked by somebodyBoogle is liked by somebodyBoogle is liked by somebodyBoogle is liked by somebody
Your main problem seems to be validation here; good client-side validation will stop this being a major problem,

Always validate as much as possible before sending anything to the server!
__________________
Price is what you pay... Value is what you get.
Boogle is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
The most secure Open Souce blog script? sitelake Blogging Forum 3 05-20-2006 08:46 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 01:42 AM.
© Copyright 2008 V7 Inc


Search Engine Optimization by vBSEO 3.1.0 ©2007, Crawlability, Inc.