in reply to HTML::Template - HTML_TEMPLATE_ROOT - multiple paths?

Security wise; I would never set paths from the environment because it opens an entire other box of security problems. You will have to doublecheck your code which parameters to accept/deny even more than before because your path will be chosen automatically by your program which can give quite strange results if the parameters given by the end-user are malicious ...

You could alternatively pre-define a few paths in an array or if you are -really- sure your paths won't be exploited in one or another way (to parse files which should not parsed like /etc/passwd etc..); by setting only the paths that are deemed neccesary for your program to run.

Still I think you better do this with a very small piece of (init) code instead of doing this automatically because then you know for sure which you have control over; while if-automatically you will loose that fine grain of control if you forget that one check.

Another way is chroot or a "sandbox"; where you check first if the path is part of the "sandbox" and if so; get the template, if not; deny. Like /home/users/templates/wildchild and /home/users/templates/midlifexs could have as root /home/users/templates ; this would limit any security hell to that one path /home/users/templates and not /home/users/* or others (if coded appropriate) ...

  • Comment on Re: HTML::Template - HTML_TEMPLATE_ROOT - multiple paths?

Replies are listed 'Best First'.
Re^2: HTML::Template - HTML_TEMPLATE_ROOT - multiple paths?
by MidLifeXis (Monsignor) on May 02, 2007 at 14:27 UTC

    While I understand (and agree with) the security implications in general, what are the added implications of making the variable that already exists accept multiple paths instead of just a single path.

    H::T currently looks in the single path pointed to by HTML_TEMPLATE_ROOT. I am having a hard time seeing how multiple paths (ala PATH, MANPATH, PERL5LIB, etc) in an already existing single-path variable is more of a security risk. At worst I can see a performance hit.

    I think that I may have tried to generalize my original post too much, when I should have focused it explicitly on just HTML_TEMPLATE_ROOT.

    --MidLifeXis

      There should not be added implications if everything is checked and filtered well enough and if you got a complete separate system variable reserved for it. Performance can be easy tuned if you put your main templates in the first directory in your path and work downwards like that.