Hi all,

I have to maintain a legacy CGI script, and recently discovered that it uses the header 'X-Forwarded-For' without validation. I would like to trace where that unvalidated data can get to.

I don't think I can turn on real taint checking; the program is too big, too old, and too crufty. I think too many things will break, and so this technical debt goes unpaid.

Is there a way to just say 'follow this value' and see where it goes? That is, if it's used as the input to a function, then start following the output of the function as well, in just the same way as real taint checking does?

I hope that by the time it gets stuck into a file or a database that it's been escaped and I'm safe from SQL injection attacks, but I'm stuck in a maze of twisty passages, all alike. I'm overwhelmed.

As I'm not sure if I can test every code path, is a static code analyzer what I need?

I've briefly looked at the Taint and Taint::Runtime man pages, but I don't know if they can help. I also looked at Tie::Watch, but it looks like I'd have to run the program, add watchpoints to new variables, run the program, add watchpoints to more new variables, etc.

Thanks!


In reply to Taint tracing a single variable? by PFudd

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.