ajt has asked for the wisdom of the Perl Monks concerning the following question:
I'm working within a secured intranet, so I don't expect many hacking attempts, but you can never tell, plus I can't be sure that someone else won't use the script within the company in a less secure environment - who ever reads warning and comments when you are in a hurry?
The problem lies around the way that the script works out which directory tree to map. Here is a summary of how it works:
The obvious problem with this is that if you pass by hand a path such as /allowed/../../notallowed, where the approved path is /allowed/, then this gets through, and then File::Find then traverses a space it's not supposed to (directory permissions aside).
I've done the obvious of obliterating any "..", but I know that there are many more ways to bypass this. Taint and detainting won't help directly either.
CHROOT isn't an option on my NT box, and annoyingly NT permissions don't prevent much either - as currently set. On a Linux box (next phase) I should be able to use CHROOT and file permissions to control the script a bit better, but I'd like the script to be more robust by default.
QUESTION: How do I take in a path from the outside, and verify that it's safe to pass to File::Find?
As ever, humble thanks in advance.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Controlling Inputted Paths in a CGI Script
by hatter (Pilgrim) on Oct 31, 2001 at 19:10 UTC | |
Re: Controlling Inputted Paths in a CGI Script
by monkfish (Pilgrim) on Oct 31, 2001 at 18:50 UTC | |
Re: Controlling Inputted Paths in a CGI Script
by dmmiller2k (Chaplain) on Oct 31, 2001 at 21:00 UTC | |
Re: Controlling Inputted Paths in a CGI Script
by tfrayner (Curate) on Oct 31, 2001 at 22:40 UTC | |
by Fastolfe (Vicar) on Nov 01, 2001 at 05:13 UTC |