AgentM,
Thanks for the reply. Point by Point:
...I'm wondering what all the hubbub is about.
During a chatterBox discussion the same day, merlyn very clearly mentioned security risks associated with the original design. (See Understanding Secure File Organization for a diagram.) This made me nervous, since I was trying to retrofit the sample to be more secure, a process I am still learning.
I originally thought, as you point out, that setting permissions was adequate. The warning, along with some of the follow-up commentary suggested that it wasn't. So, I searched PM for security and found several different discussions about various risks but fewer discussions concerning solutions.
Thus, I'm trying to collect ways to solve potential security risks, as well as write perl applications that are easier to maintain and move. (Thank you for noticing, BTW).
I have read the FAQ's, several books, and many, many links. Little appears to discuss architecture, that is, layout out an application with an eye for security.
One comment that stuck, though, was that one way to reduce the information that can be potentially exploited is to reduce the amount of information publicly available. My theory, then, is that by compartmentalizing code into specific "need to know" areas, I can reduce the number of visible holes.
I hope this isn't security through obscurity, as that appears to be a Bad Thing, along the lines of Cargo Cult Programming and other things to avoid. My request for wisdom is to make sure I'm on the right track.
...if you configure Apache correctly, the directories make no difference.
Would you mind expanding on this a bit? What are some things to look for? I presume it's more than:
- Avoiding symbolic links
- Ensuring IncludesNOEXEC is active for the httpd\ directory
- Making sure that ScriptAlias points to a directory *outside* of httpd\.
- Setting permissions of CGI scripts to 755.
Again, I'm trying to a) learn and b) start a discussion that documents the security practices of other Monks, especially the ones with the most experience (pun, intended).
...making more directories does not improve your security without obscuring it (permission bit mask confusion!)
Permission bit mask confusion?
...I'm a bit scared of your /lib directory. Are these modules or libraries specific to the app? Do you only use them in this app?
Again, just application libraries and personal toolkit libraries that aren't yet in a state to be shared. The toolkit stuff will (I hope) eventually get to the point where they're be shared across multiple applications, but until they're at that point, I confess I am duplicating a few functions here and there. By design It's a way for me to experiment with making what I think will be common routines, while buying me a little bit of time to a) make sure I'm not reinventing the wheel and b) making sure that they really should be toolkit routines.
...I notice that you are organizing well, but wonder why. Few programmers are truly gifted in the sense of organization and I'm sure that future program maintainers will thank you for the easy job of being able to know what's going on in your code.
In part because I have, over the course of my career, inherited too many poorly organized applications. I don't expect to spend my entire career with this employer, so I would like my stuff to be easily--and, perhaps more importantly--quickly understood by the poor sap who has to maintain my legacy code. Also, it's a sanity check for when *I* have to maintain the system in a few months/weeks/years/etc.
...just block it out with an Order deny,allow for everything except .html, .shtml, .cgi and anything else you are serving.
Hm. I hadn't thought of that. *ponder*
How does this strike you? Use (and allow) .cgi for the scripts called by the HTML forms, but use (and deny) .pl for the "kit" code. Is that an effective measure? Or have I forgotten something or inadvertently stumbled on another obscurity or cargo cult meme?