in reply to functions for passing variables through multiple CGI forms
Then, it can be a trivial matter for someone to adjust the price value. Needless to say, if you have other data in those fields that you cannot afford to have altered, this can be a big problem. Try using Digest::MD5 or Digest::SHA1 (SHA1 takes longer, but it's more secure). Here's some sample code:<input type=hidden name="price" value="42.95">
That should print something like "BS1+1ySMDuN+fqp7hnMRYw".#!/usr/bin/perl -w use strict; use Digest::MD5 qw ( md5_base64 ); my $rand = 'yed*73=1/+#@%d'; my $price = '40.95'; my @data = ($rand, $price); my $base64_digest = md5_base64( @data ); print $base64_digest;
Take the digest value and embed that in the form. When the values are returned, recompute the digest with the same $rand. If the values don't match, your hidden values have been tampered with. Needless to say, you want $rand to be as secure as possible!
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just go the the link and check out our stats.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
MD5 should be run twice
by markjugg (Curate) on Oct 16, 2000 at 20:12 UTC |