If I've understood correctly, the problem is that someone could use the .. parent directory
syntax to request a file/page outside of your $docroot ?
If so, then you may want to consider checking
$path before opening the file. Use
a regex to see if it contains .. preceded
or followed by a / (there may be other
possibilities, I haven't thought about it a great deal).
If so, then deny the request.
One other security hole you should definitely close,
is to use the 3-argument open():
open (FILE, '<', "$docroot$path")
Otherwise you are open to people crafting a request
ending with | which could allow someone
to run arbitrary code on your machine.
This is just a couple of things I thought of, there
are probably other issues to be aware of as well...
s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&
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.