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 Justin Koivisto on 11/17/63 11:39

Skeets wrote:
> i'm passing session and hidden variables between pages. not to mention
> post values.
>
> i'm a little concerned that someone with sufficient knowledge could
> spoof these vlaues and manipulate the program.
>
> is this a valid concern? i'm thinking i can check the submitting page
> setting up something around the following the following code...
>
> $base_name = basename($_SERVER['PHP_SELF']);
>
> is this a good bet? is there a better way?

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. 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.

As always: untested, YMMV

--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com

 

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

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