I assume that you are using some form of database. In the DBI docs somewhere, it states that you should use placeholders for your data. For example:

# $dbh contains your database handle my $sth = $dbh->prepare( "SELECT * FROM foo WHERE id = ? AND bar = ?" +) or die( "Could not prepare statement: ".$dbh->errstr() ); #of cours +e you will have a more elegant error handling method than just die $sth->execute( $value_for_id, $value_for_bar ); #and then just fetch the data like you would normally.

Placeholders also have the added advantage of reusing your queries. For example:

#Take the same $sth from the previous example my @data_to_query = ( #You would probably get this from somewhere else { id => 763, bar => "baz" }, { id => 923, bar => "qux" }, #...and so forth ); foreach( @data_to_query ) { $sth->execute( $_->{id}, $_->{bar} ); #do something with that dataset }

The advantage of that is not only performance(only need to compile SQL statement once), but the placeholders are replaced with safe data that can be used in the database. Of course, I left out several things like error handling for incorrect or malformed queries, but it is implied that you should have that.


In terms of other security, make sure you use common sense. Hash your passwords and add a salt, ensure that nobody should see data they're not supposed to see, and all other typical web security tips.
Use common sense(and common::sense) and all will be well.

~Thomas~
confess( "I offer no guarantees on my code." );

In reply to Re: How to secure a perl script from attacks by thomas895
in thread How to secure a perl script from attacks by romy_mathew

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.