Hello all,
I have an application that accepts a lot of user data and
I want to be a safe and secure as possible. At no time does anything
supplied by the user used in any system or exec commands.
Most of the incoming data is either used for program descisions
or saved in a flat file database.
OK, now the question.
Do you consider the following code to be secure and hacker proof?
If not, why not and how can I improve it.
@special = ("body",
"subject",
"link_url",
"pid");
foreach $field (keys %form_data) {
# specific fields that can have additional characters
if($field eq "body" ||
$field eq "subject" ||
$field eq "link_url" ||
$field eq "pid") {
# were looking for specific hacker tricks here
foreach (@special) {
$form_data{$_} =~ s/system\(.+//g;
$form_data{$_} =~ s/grep//g;
$form_data{$_} =~ s/\srm\s//g;
$form_data{$_} =~ s/\srf\s//g;
$form_data{$_} =~ s/\.\.([\/\:]|$)//g;
$form_data{$_} =~ s/< *((SCRIPT)|(APPLET)|(EMBED))[^>]+>//
+ig;
}
# all other fields get sifted here
} elsif($form_data{$field} ne "") {
unless ($form_data{$field} =~ /^([-\@\w.\s]+)$/) {
# exit handler here
}
}
}
Thanks in advance
-- Brian
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.