The Lizard Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsCommunityThe Lizard Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 15th, 2003, 06:58 AM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via Yahoo to fakker
client side Vs server side validation....

Just wanted to know peoples opinions on client side versus server side validation for forms etc...

I personally use client side all the time for simple things like checking for input etc.... it saves time for the user and resources on the server.....

the reason I ask, is some of my mates prefer server side... so they allow the user to submit the details, then send them back saying "sorry, you must complete X, Y and Z".... I hate that....

What does everyone else use??
__________________
Matt 'Fakker' Facer

mattfacer.com

Reply With Quote
  #2  
Old April 15th, 2003, 07:49 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
If you're talking about web applications, then client-side provides no security. If you want to use client side validation, that's kewl (i use it for checking form completeness, email validation, and some other simple things), but you then have to do it again on the server side.

The reason is because there is nothing stopping someone re-creating a form from your site, removing the validation, then posting it to your post-back script. Attempting to verify where the form is being posted from doesn't help either, cos it's easily spoofed.

Reply With Quote
  #3  
Old April 16th, 2003, 04:25 AM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via Yahoo to fakker
hmm.... I never really thought of that. Yeah, I meant validation in web applications. I never thought of someone simply re creating the form to get in the DB..... this is actually a problem for me, which I need to go and address right away!!


Cheers for the advice! oh god, I'm scared now........

Reply With Quote
  #4  
Old April 18th, 2003, 01:47 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
stumpy,

i'm curious as to the legalities of that... i read articles on how apparently some shopping cart applications are still using a simple GET method when submitting forms, obviously making it easy for any user to manipulate the send string and change any data they want... the article also mentioned that the certain site in question sent the price (determined by a hidden field in the html form) as a part of the GET string... obviously a super-poor method of operating a shopping cart... [i'm starting to ramble]

anyways, apparently the legalities come down to the fact that its up to the company to confirm the order... and if you don't validate on the server side and simply confirm the order you could run into some major problems...

uh, i guess my point was... ALWAYS server side validate... and it is a great idea to client-side validate as well, to cut back the load on the server [less bounce backs]

Reply With Quote
  #5  
Old April 18th, 2003, 02:07 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Hmm - yeah, the legalities of sending out a product where the prices have been altered by the consumer... interesting.

Something kinda similar happened recently on Amazon where a worker there accidently entered a wrong price for an IPAQ (i think it was something like $20AU) - apparently a contract is in place and finalised once the consumer has the product in their hands... so, unless the vendor manually checks the price, there mightn't be much they can do....

the amazon gaffe: http://www.theregister.co.uk/content/54/29828.html
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #6  
Old April 23rd, 2003, 11:36 PM
bo0 bo0 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 10 bo0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to bo0
yea client side validate for form completion and the like

but when actually doing something functional and important.. do it in both places... so you know there is no messups

Reply With Quote
  #7  
Old April 24th, 2003, 07:49 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
One thing that hasn't been mentioned, although it's obvious, is the fact that many people disable Javascript... So if you're only doing client-side validation, good luck!

Your best bet is to do both CS and SS, although I prefer Server Side.
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #8  
Old April 26th, 2003, 12:20 PM
bo0 bo0 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 10 bo0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to bo0
now that should be a poll topic.. kinda like how many people have the flash plugin.. how many people have javascript turned off...

Reply With Quote
  #9  
Old May 4th, 2003, 02:23 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Quote:
Originally posted by bo0
now that should be a poll topic.. kinda like how many people have the flash plugin.. how many people have javascript turned off...


Are you volunteering boo?

Reply With Quote
  #10  
Old May 9th, 2003, 11:04 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I use both CS and SS checking, as people have already mentioned js can be turned off, etc. CS serves as an early warning mechinism for the user. I then also check SS, I also ensure that the previous page was the form, using the referer variable in php.

Also as a security tip, you should always use switches as much as possible instead of if() and else

as you can catch anything thats wrong, more easily (well i do atleast)

Also as another security point, most forms should be POST and not GET, like im stating the obvious

at the very least you should always do SS, as it cant be fudged

Reply With Quote
  #11  
Old May 14th, 2003, 12:56 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Just on the POST/GET thing... there is no real difference between the two. You should never pass any sensitive data around in the client. Using POST offers no more security than GET does.

A secure site uses sessions and validates ALL data, server-side.

Reply With Quote
  #12  
Old May 14th, 2003, 06:12 AM
visualdensity visualdensity is offline
Absolut Bummer
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Jungle
Posts: 51 visualdensity User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Quote:
Originally posted by stumpy
Using POST offers no more security than GET does.

This is interesting stumpy.. can u explain a little bit more? Because I have always thought that using POST is more secure because variables could not be manipulated so easily... so.. how is it not secure? Just want to get a clearer understanding because this question has always been playing in my head.

Quote:
A secure site uses sessions and validates ALL data, server-side.


I agree with this one... I have always used SS for validation and my principle is to use minimum CS as much as possible... and most of the time I don't at all. A little bit more work.... but I could ensure that it works across a variety of browsers.
__________________


Reply With Quote
  #13  
Old May 14th, 2003, 06:17 AM
visualdensity visualdensity is offline
Absolut Bummer
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Jungle
Posts: 51 visualdensity User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Quote:
Originally posted by Ben Rowe
I then also check SS, I also ensure that the previous page was the form, using the referer variable in php.


That's a great method for security check... but recently, I was browsing through the PHP manual and here's what it says:

Quote:
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.


What does that mean exactly? When it says 'User Agent', does it mean the user's browser or something that is set on our side? How could we make sure that this is works well ?

Thanks!

Reply With Quote
  #14  
Old May 14th, 2003, 06:43 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
A 'user agent' is the browser (or whatever ever the user is using to view your site).

Re: security - post vs. get - basically there's no difference in security in using either method. Anyone can see the values you submit in your form (view source!). Point is, never pass sensitive info in forms - it should all be handled server-side.

Checking for referrer URL is not secure (tho people use it in situations where security isn't an issue). This is easily spoofed. Run a packet sniffer on your modem and look @ what actually occurs when you request and receive a web page. You will notice the first few packets which establish the HTTP connection to the site are all in plain text. All these values can be created manually by the user if they wish (thru socket programming).

Reply With Quote
  #15  
Old February 12th, 2004, 04:20 PM
jonny_Q jonny_Q is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 5 jonny_Q User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to jonny_Q Send a message via AIM to jonny_Q
I'm not an expert on form security, but I do use them at my job - I do the client side, someone else does the server side.

Client side validation - good to make sure form is filled out correctly before submitting - i.e. <form... onSubmit="validate(); return false;">. People can turn JavaScript off to get around this. People can copy your HTML (generated) source, modify it, and submit it (I've even used that technique at work to get a couple things done for customers)...

Server side- be sure safe and proper information is submitted

You can check the URL the form is being posted from for security, but that can be faked... You can create a session variable ($SESSION['form_pass'] = "845y3ngf9";// I think... in PHP... I know ASP better...) but even THAT can be faked. Person goes to your site - session variable is set, person goes to their spoofed form with no session interuption, person submits form - session variable still in tact. Even THAT can be faked.

The ABSOLUTE best way to ensure that the form is being submitted from YOUR site is to use a security image ("Type the text you see in this image... etc") as in forms located here: http://www.networksolutions.com/en_US/whois/index.jhtml And I don't know how that works...

Reply With Quote
  #16  
Old February 12th, 2004, 06:29 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Security images are quite simple to do. Simply obtain a component that can produce an image on the fly. Feed it some characters to insert into the image, and store those chars in a session.

When the form is submitted - check the user has returned those chars - match against what you have in your session.

Note that this alone does not ensure that the form is completed on the server either. Security images are only used to ensure that a human completed the form, and not a bot/script.

Reply With Quote