in reply to Re^3: Using relative paths with taint mode
in thread Using relative paths with taint mode
At least you need to consider what happens if someone points his browser to http://your.stuff/cgi-bin/Site/HTML.pm
I exclude access to all the subdirectories of cgi-bin with a .htaccess file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Using relative paths with taint mode
by afoken (Chancellor) on Jun 20, 2021 at 19:46 UTC | |
I exclude access to all the subdirectories of cgi-bin with a .htaccess file. Forget to create that file or forget to enable .htaccess files and you are screwed. Moving libraries (and configuration) out of the webserver's document root and outside any aliased directory not only completely avoids those errors, but is also faster. The webserver does not have to parse .htaccess files. Quoting https://httpd.apache.org/docs/current/howto/htaccess.html#when (Apache v2.4 at time of writing):
Update: I usually place only a minimal CGI below document root or in an aliased directory, and have all remaining code and configuration elsewhere, inaccessable to HTTP clients. Something like this (untested):
All remaining code is in My::App or loaded by My::App. A welcome side-effect is that almost all errors occur in modules loaded after CGI::Carp is active, and so I get reasonable error messages in the browser during development. Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-) | [reply] [d/l] |
by afoken (Chancellor) on Jun 24, 2021 at 08:40 UTC | |
Just found some numbers on .htaccess by nginx: https://www.nginx.com/resources/wiki/start/topics/examples/likeapache-htaccess/ This may look like comparing Apache vs. nginx, but it is not. It is comparing .htaccess enabled (the Apache case) vs. .htaccess disabled / not implemented (the nginx case). Apache with AllowOverride none should be the same as nginx. To explain: Each FS stat and each FS read is "expensive" and should be avoided where possible for a fast webserver. .htaccess forces more FS stats and more FS reads, and so the numbers for .htaccess enabled (the Apache case) are way higher than for .htaccess disabled / not implemented (the nginx case). Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-) | [reply] [d/l] |
by Bod (Parson) on Jun 22, 2021 at 10:44 UTC | |
In general, you should only use .htaccess files when you don't have access to the main server configuration file. This is on shared hosting so I don't have access to the server configuration file! | [reply] |
by afoken (Chancellor) on Jun 22, 2021 at 17:38 UTC | |
In general, you should only use .htaccess files when you don't have access to the main server configuration file. That's no reason to stop reading. Depending on how your shared hosting is set up, there may still be a way to place files outside the reach of the webserver. My shared hoster gives me some filespace somewhere on a unix system, and has a configuration panel that allows to assign any directory of that filespace to any domain hosted there. So I made a few subdirectories and used a subdirectory per domain. Other subdirectories are still unassigned, can not be accessed via HTTP, and thus are perfect for libraries and configuration files. Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-) | [reply] |