Besides variables coming from query strings ($_GET), posted form data ($_POST), and cookies ($_COOKIE) you should treat session variables as tainted too if your site is on a shared host.
If you have used Perl you probably have heard of tainted variables - they are variables that come from user input and as such shouldn't be trusted. The only way to untaint a variable in Perl is to use a regular expression to extract a value out of it.
It doesn't matter what language you are using to build your scripts you should never trust user input.
If your site is on a shared hosting service that probably means that other people may have the ability to open your files and get sensitive data out of there.
What's more if other sites on the host share the same domain - your site is reachable under a directory which is different from the root, cookies shouldn't be trusted. Not that it is a good idea to trust cookies but other people on the hosting service may generate sessions that will be valid for your site.
$_GET$_POST$_COOKIE$_SESSIONThe superglobal arrays $_GET... are available since PHP 4.1.0,
for previous versions of PHP the equivalents are the $HTTP_*_VARS.
I didn't mention the case when you're using register_globals = on,
because that implies that you don't care about security at all.
Comments
so... ???
OOpss!! You forgot to write the solution for this problem !??
The solution is to always check important session data.
In my PHP login script there is an example which shows how you can check session data.
It does not show all available methods but just a few to get you started.
Security Implications on Shared Hosts
well basic things need to be done
well thats my 2 cents on protecting forms.:)
On JavaScript
The strange thing about JavaScript is that more and more people disable it according to statistics. In other words the JavaScript visitors are less than those who use browsers which support JavaScript - this should make you think about it before doing something client-side only.
RE: On Javascript
"other words the JavaScript visitors are less than those who use browsers which support JavaScript"
Really? Which crack-pot website did you get that data from?
Last I checked, a whole 3 months ago which was after the date of your post, the stats showed only 6% of users disabled javascript and a further 1% used browsers that didn't support it at all.
7% is a far cry from 51% or more.
javascript
Using javascript is ok, but it is by no means a method to rely on. And yes, some users have javascript disabled, especially panicked IE users maybe, hehe.
Server-side validation using regExps , intval, stripping html and SQL comments is the best way I know, although it takes the workload to the server.