Most people are aware of this, but I haven't seen a formal way of taking precautions that's globally accepted.
My thought was to create a module (CGI::Taint) that when used, overloaded print to add taint checks to items sent to it - currently, print is ignored as a factor in untainting data.
I'm not 100% sure this is the best approach, but would something like the following work?
use CGI; use CGI::Taint; my $q=CGI->new(); my $tainted_var = $q->param('form_input'); # first case - dies to browser with # "attempt to print tainted var at line 10" print $q->header. "Tainted: $tainted_var"; exit(0); # second case - no error my $untainted_var = ''; $tainted_var =~ /(\w\s+)/ and $untainted_var=$1; print $q->header. "Untainted: $untainted_var"; exit(0);
So, my questions are (I guess):
If it could work, I don't think it would ba that much work, or are there other functions that would need overloading too? printf?
Hmmm. Thoughts welcomed.
cLive ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: writing a "CGI::Taint" module
by diotalevi (Canon) on Jul 12, 2003 at 21:42 UTC | |
|
Re: writing a "CGI::Taint" module
by tilly (Archbishop) on Jul 12, 2003 at 20:21 UTC | |
by cLive ;-) (Prior) on Jul 12, 2003 at 20:29 UTC | |
by diotalevi (Canon) on Jul 12, 2003 at 22:46 UTC |