以root用户身份运行PHP文件是否有风险?

时间:2015-05-29 08:53:50

标签: php security command-line-interface

我需要通过CLI运行PHP文件。 此文件由非root本地用户拥有(我们将其称为" bob" => bob:bob)。 bob有uid = 1000,gid = 1000

文件如下:

ls -l => -rw-RW-R--。 1 bob bob 173 29 may 10:46 file.php

我只能使用以下命令以root身份运行此脚本:

php -d open_basedir="/home/bob" -f /home/bob/file.php

cli的php.ini文件包含有关禁用功能的限制,包括:

apache_child_terminate,apache_setenv,curl_exec,curl_multi_exec,define_syslog_variables,dl,escapeshellarg,escapeshellcmd,eval,exec,fp,fput,ftp_connect,ftp_exec,ftp_get,ftp_login,ftp_nb_fput,ftp_put,ftp_raw,ftp_rawlist,highlight_file,ini_alter,ini_get_all,ini_restore,inject_code,leak,mysql_pconnect,openlog,passthru,pclose,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,pfsockopen,phpAds_XmlRpc,phpAds_remoteInfo,phpAds_xmlrpcDecode,phpAds_xmlrpcEncode,php_uname,popen,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell,shell_exec,symlink,syslog,system,xmlrpc_entity_decode

现在,最大的问题是:

  

使用root用户调用文件是否危险?

我在getmyuid()中使用getmygid()get_current_user()file.php进行了测试,从root用户调用它时,数据正确1000,{{1} }和" 1000"。

我会说这很安全,但我并不是百分百肯定!

感谢您的帮助。

(注意:我无法通过bob运行它,因为用户是动态创建的)

0 个答案:

没有答案
相关问题