doc_root already limits apache/php script folder locations.
open_basedir is better used to restrict script access to folders
which do NOT contain scripts. Can be a sub-folder of doc_root as in php doc example doc_root/tmp, but better yet in a separate folder tree, like ~user/open_basedir_root/. Harmful scripts could modify other scripts if doc_root (or include_path) and open_basedir overlap.
If apache/php can't browse scripts in open_basedir, even if malicious scripts uploaded more bad scripts there, they won't be browse-able (executable).
One should also note that the many shell execute functions are effectively a way to bypass open_basedir limits, and such functions should be disabled if security demands strict folder access control. Harmful scripts can do the unix/windows version of "delete */*/*/*" if allowed to execute native os shell commands via those functions. OS Shell commands could similarly bypass redirect restrictions and upload file restrictions by just brute force copying files into the doc_root tree. It would be nice if they could be disabled as a group or class of functions, but it is still possible to disable them one by one if needed for security.
PS. currently there is a bug whereby the documented setting of open_basedir to docroot/tmp will not work if any include or require statements are done. Right now include will fail if the included php file is not in BOTH the open_basedir tree and the doc_root+include_path trees. Which is the opposite of safe.
This means by any included php file must be in open_basedir, so is vulnerable to harmful scripts and php viruses like Injektor.Инсталиран како Apache модул
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Инсталиран како Apache модул
Референца за `security.apache.php` со подобрена типографија и навигација.
Инсталиран како Apache модул
Кога PHP се користи како Apache модул, ги наследува дозволите на корисникот на Apache (обично на корисникот "nobody"). Ова има неколку влијанија врз безбедноста и овластувањето. На пример, ако користите PHP за пристап до база на податоци, освен ако таа база на податоци нема вградена контрола на пристап, ќе мора да ја направите базата на податоци достапна за корисникот "nobody". Ова значи дека злонамерен скрипт може да пристапи и да ја измени базата на податоци, дури и без корисничко име и лозинка. Сосема е можно веб-пајак да наиде на веб-страница на администратор на базата на податоци и да ги избрише сите ваши бази на податоци. Можете да се заштитите од ова со Apache овластување, или можете да дизајнирате сопствен модел на пристап користејќи LDAP, .htaccess датотеки, итн. и да го вклучите тој код како дел од вашиот PHP scripts.
Често, откако безбедноста е воспоставена до тој степен што PHP корисникот (во овој случај, корисникот на apache) има многу мал ризик поврзан со него, се открива дека PHP сега е спречен да пишува какви било датотеки во корисничките директориуми. Или можеби е спречен да пристапува или менува бази на податоци. Исто така е обезбеден од пишување добри и лоши датотеки, или внесување добри и лоши трансакции во базата на податоци.
Честа безбедносна грешка направена во овој момент е да се дозволат root дозволи на apache, или некако да се ескалираат способностите на apache.
Ескалирањето на дозволите на корисникот на Apache до root е исклучително опасно и може да го компромитира целиот систем, така што sudo'ing, chroot'ing, или на друг начин работење како root не треба да го разгледуваат оние кои не се безбедносни професионалци.
Постојат некои поедноставни решенија. Со користење на open_basedir можете да контролирате и ограничите кои директориуми се дозволени да се користат за PHP. Можете исто така да поставите области само за apache, за да ја ограничите целата веб-активност на не-кориснички или не-системски датотеки.
Белешки од корисници 3 белешки
There is a better solution than starting every virtual host in a seperate instance, which is wasting ressources.
You can set open_basedir dynamically for every virtual host you have, so every PHP script on a virtual host is jailed to its document root.
Example:
<VirtualHost www.example.com>
ServerName www.example.com
DocumentRoot /www-home/example.com
[...]
<Location />
php_admin_value open_basedir \ "/www-home/example.com/:/usr/lib/php/"
</Location>
</VirtualHost>
If you set safe_mode on, then the script can only use binaries in given directories (make a special dir only with the binaries your customers may use).
Now no user of a virtual host can read/write/modify the data of another user on your machine.
WindseekerIt is not useful for ordinary users to have a debate about the lack of security in using PHP without clearly listing step by step methods of resolving the issue. Such methods should be authoritatively provided by PHP and not as a user's opinion, later debated by another user.
It is not that I am opposed to debate. This is how we learn as an open-source community. However, us mere mortals need the gods of PHP to come to conclusions and give us best practices.