Dear Monks,
I'm in the process of recoding my entire site to be more efficient (at least as best possible for my skill level) as well as more secure.

I'm working on a new script that will allow users to modify data of HTML files (vs. storing it in a DB). While attempting to open a file in the code:

open (FILE,"../$directory/html/$file.html"); while (<FILE>) { $content .= $_; } close(FILE);

I'm getting the following error:
"Insecure dependency in open while running with -T switch at filname.cgi line 116."

The values in $directory & $file are fetched from the URL that calls the script.

From some reading I've done so far tonight, I've come to understand (at least I think I have) that this is due to a vulnerability where the user could pontentially modify the values of $directory and/or $file & potentially modify or files on the server. Which is of course not something I'd like them to be able to do ;-)

What are my options to resolve this issue?
Is there a module to "untaint" the data, and allow the -T switch to know it's been untainted... or anything of that sort?

The sharing of your wisdom would be greatly appreciated!


Stenyj

In reply to -T switch & untaint - how to resolve errors? by Stenyj

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.