You are here: Re: PHP Passing Variables Between Pages and Security « PHP Programming Language « IT news, forums, messages
Re: PHP Passing Variables Between Pages and Security

Posted by Gordon Burditt on 10/17/67 11:39

>OK, instead of linking to the threads from before, here is an example
>again for protecting against spoofed form submissions:
>
><?php
>session_start();
>$_SESSION['token']=md5('secret string'.time());
>?>
><form method="post" action="process.php">
> <input type="hidden" name="formToken" value="<?php echo
>$_SESSION['token'] ?>" />
>....
></form>
>
>In the process.php:
><?php
>session_start();
>if( isset($_POST['formToken'])
> && isset($_SESSION['token'])
> && $_POST['formToken']==$_SESSION['token']
> ){
> // form submission legit
>}else{
> // spoofed form submit
>}
>?>
>
>
>This allows you to be confident that the form was submitted from your
>site.

Ok, define "submitted from your site".

It is possible, and I've done this sort of thing on a site where I
had legitimate access, to fetch the form from your site, (using,
e.g. CURL) find the HTML for formToken, pick up the value, and pass
it as a parameter in the next request (again using CURL). Along
the way I can add in any other variables I want and not run any
Javascript on the page. Granted, this *does* load the form
from your site. And I'd have to be logged in to do it, if
that is needed to get to the page.

Granted, it's not something your average spambot would do, but it
can be done.

>Of course, when doing defense in depth (as you should be), you'll
>also want to filter input and escape output...
>
>Anyway, I have yet to find a way to be able to spoof around this,
>including using javascript to attempt to read the token value from a
>remote site.

Gordon L. Burditt

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация