PHP MVC 沙箱
我正在构建一个系统,不同的用户可以上传他们的自定义 php 模块。该系统基于用 PHP 编写并部署在 Linux 上的自定义 MVC 框架。 当用户登录时,他的模块将由系统核心加载。系统核心由所有模块共享。
我的问题是,如何限制用户模块干扰核心。例如。取消链接文件等。我可以通过文件权限阻止他们这样做吗?
I'm building a system where different users can upload their custom php modules. The system is based on a custom MVC framework written in PHP and deployed on Linux.
When a user logges in, his modules will be loaded by the system core. The system core is shared between all modules.
My problem is, how to restrict USER modules from messing with the core. Eg. unlinking files, and similar. Can I prevent them from doing that with file permissions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
希望系统的每个用户在服务器上都有不同的用户帐户。如果他们不这样做,就很难阻止他们删除彼此的数据。
我假设您正在开发某种风格的 UNIX 服务器。
mvc-admin
。g-mvc-access
。chmod -R g+rw /path/to/mvc-system-root
。现在该组可以读取 MVC 系统根目录下的所有文件,但不能写入。g-mvc-access
中。Hopefully, each user of your system will have a different user account on your server. If they don't, it will be terribly hard to keep them from deleting each others data.
I'll assume you're working on some flavour of unix server.
mvc-admin
.g-mvc-access
in this answer.chown -R mvc-admin:g-mvc-access /path/to/mvc-system-root
. Now the files are all owned by the admin user, and in the access groupchmod -R g+r-w /path/to/mvc-system-root
. Now the group can read, but not write, all the files under the MVC system root.g-mvc-access
.您可以将脚本上传到运行“安全”php 的第二个服务器。
然后只需通过 disable_functions 指令禁用危险功能:
http://www.webhostgear。 com/319.html
you can upload the scripts to a second server which runs a "secured" php.
Then just disable dangerous functions by the disable_functions directive:
http://www.webhostgear.com/319.html
让用户上传脚本并执行这些脚本是极其危险的。即使您使用
disable_function
、Suhosin 和朋友来保护系统,你可能会打开很大的安全漏洞。我建议您允许用户上传由专用模板语言组成的模板,而不是让用户上传 PHP 脚本。此类语言通常根本无法访问诸如取消链接文件之类的功能。然后你可以通过白名单来开放模板语言,这是一种更安全的方法。
Zeta Componets 模板引擎 具有很强的可扩展性,而且 PHP 开发人员可以直观地编写模板。也许这对你来说是一个选择?
Heaving users upload scripts and execute these is extremely dangerous. Even if you secure your system using
disable_function
, Suhosin and friends, you might open large security holes.Instead of letting users upload PHP scripts, I'd suggest that you allow them to upload templates, which consist of a dedicated template language. Such languages typically don't have access to functionality like unlinking files at all. Then you can open up the template language by white-listing, which is a much more secure approach.
The Zeta Componets Template engine is very extensible and templates are intuitive to write for PHP developers. Maybe this is an option for you?