First of all, I would like to thank those who assisted me with this problem a few days ago in the CB. I am posting here to get a wider range of opinions on what to do.

I have a CGI form that asks the user for their username and inserts it into a database. I then retrieve it from the database and display it on the web page. I use placeholders when inserting into the database, so that takes care of that. To solve the latter issue, I am currently using the HTML::Entities module: $username = encode_entities($q->param('name')) which seems to work fine. Of course, I am not competently educated in website vulnerabilities , so I do not know if that small piece of code will protect me.

Is there something more I can do or will that line of code take care of the problem?


Update: Just thought of another question (and feel like an idiot by not knowing the answer :[). In the CGI script, I have the credentials to connect to a mysql database. Is there anyway for someone to inspect the CGI script itself, bypassing the HTML it generates?

Update2: Taint-mode has been brought to my attention. It seems like an excellent way to secure user input. Should it be used in conjunction with the other methods suggested in this node (and comments), or is it good enough by itself?

I'm so adjective, I verb nouns!

chomp; # nom nom nom


In reply to Removing malicious HTML entities (now with more questions!) by Lawliet

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.