SirChick Posted November 6, 2007 Share Posted November 6, 2007 I was wondering what php permissions is all about? Been trying to get my security more tight but don't know how or where to begin i was told about permissions but I don't really understand them... =/ Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2007 Share Posted November 6, 2007 What exactly do you mean... php permissions? Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 6, 2007 Author Share Posted November 6, 2007 Well i asked a while back to a friend about security and he said to put the php files into directories so attacks couldn't guess where the php files were, I then later asked on a number of forums to see what the general opinion was about this idea and in short most said it made no difference so it wasn't worth my effort to put my php files into folders etc. But some people mentioned that php permissions will help with my security.. I had never really heard about it and that was the only info I had... so I don't know what php permissions are exactly but if it helps security I am needing to learn it. Becuase im at the security stage development of my site you see. Quote Link to comment Share on other sites More sharing options...
revraz Posted November 6, 2007 Share Posted November 6, 2007 I think you mean directory permissions. Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 6, 2007 Author Share Posted November 6, 2007 well possibly... all my files are in one place which is "htdocs" folder.. so i guess i would only need to set one permission on that folder or something ? =/ I'm not 100 % sure on what he meant anyway but im going to assume directory permissions is what he meant. Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2007 Share Posted November 6, 2007 What exactly are you trying to achieve? If you change the permissions on the directory your php files are in so they become un-executable, then, they will be un-executable. Meaning they will not work. They way I have my framework setup, the only php script within the web doc root is the front controller. Every other file is outside. This stops people from being able to access the files directly but even so... The best way to secure your php files is to make sure you check any data that is sent to them properly. eg; If you have a php script that expects values passed to it via a form, make sure you check the form sent the variables and that they are valid prior to th script executing. You don't want (for instance) a script attempting to insert data to a database unless it has that data available to it. Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 6, 2007 Author Share Posted November 6, 2007 They way I have my framework setup, the only php script within the web doc root is the front controller. Every other file is outside. This stops people from being able to access the files directly but even so... not sure what you mean by "outside" is the front controller like the front login page? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 6, 2007 Share Posted November 6, 2007 Sounds like he uses Objects and keeps his main object available via the web root and the rest are behind that so you can't even navigate to them if you tried. Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 6, 2007 Author Share Posted November 6, 2007 so like the connect script would be outside then have the login pages in a folder like "login" so that u cant access and files in "login" unless you are already logged in to the site? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 6, 2007 Share Posted November 6, 2007 More like this is your host's Webroot structure: /users/b1234/domain/htdocs and htdocs is your folder that holds pages that load if you went to www.domain.com. But from his access, he can put folders and files back one hive and set them in /users/b1234/domain and use absolute paths to get to them, but from a webuser's standpoint, there is no way to navigate before the htdocs folder. Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 6, 2007 Author Share Posted November 6, 2007 oh ok so i just make a directory and put htdocs in at the end of the directory.. so just one question if thers only one folder why have a directory at all :S? why not just have it as : /htdocs ? Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2007 Share Posted November 6, 2007 You can't move your web document root unless your using a vps or dedicated server. This is usually controlled via your host. I'll ask again in a different way. What benifits do you hope to achieve by having your php files out of reach? Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2007 Share Posted November 6, 2007 ps: Most websites will not work with there files outside the web root dir, because clients can no longer reach them. I use a framework which has one access point to the entire process. Thus I have the ability to call scripts from outside of the doc root. Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 6, 2007 Author Share Posted November 6, 2007 well security increased basically... and to stop people guessing php file names to avoid them running a script which could cause problems to the game. I was told if they are easy to guess the where abouts of the php file and its name then attacks can get at them ? Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2007 Share Posted November 6, 2007 I was told if they are easy to guess the where abouts of the php file and its name then attacks can get at them ? This really depends on what the scripts do, but like I said, If you check your scripts are recieveing the data they expect from where they expect to recieve it you shouldn't have any issues. Moving files outside your docroot is not the solution, but part of a bigger one. Always check your request data. Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 6, 2007 Author Share Posted November 6, 2007 how can u test to see where they receive it from ? I can do the the receiving data checks there pretty straight forward.. if == '' header the page etc.. but how can you check where it comes from ? Would that require sessions again ? Or do $_POST carry some unique ID tag to them so you know what forms they come from ? Quote Link to comment Share on other sites More sharing options...
marcus Posted November 6, 2007 Share Posted November 6, 2007 $_SERVER['HTTP_REFERRER']; The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted. Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 6, 2007 Author Share Posted November 6, 2007 doesnt sound great with the end comment about it being trusted... so i had : form page .php (form goes to process.php) process .php which one needs to have $_SERVER['HTTP_REFERRER']; both or just process .php ? Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2007 Share Posted November 6, 2007 I usually set a $_SESSION var in my forms, then check for that in the processing script. Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 6, 2007 Author Share Posted November 6, 2007 good idea... ill have to recode my pages now before i have to thousands of them Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.