2

我刚刚在我的项目中实现了 uploadify,我注意到上传过程中似乎存在一个重要的安全问题:

应该上传文件的文件夹作为 javascript 参数提供,因此是客户端。如果用户更改脚本并填写不同的文件夹(即“/”)进行上传,则文件将上传到不同的文件夹。

配置中有一个选项来过滤文件类型,但它再次在客户端提供(“fileExt”)。

那么我认为这可能导致可能的黑客攻击是错误的吗?在 Web Root 的任何位置上传 php 文件并执行它似乎很容易。

  • 这是期望的行为吗?
  • 我应该交叉检查uploadify.php 文件中的上传文件夹吗?
  • 我应该向uploadify 制造商发送通知吗?

我敢肯定我不是第一个考虑这个问题的人。哦,其他配置参数也是如此,例如sizeLimitqueueSizeLimit

4

5 回答 5

4

Just looked at the code (haven't installed it anywhere), and it certainly looks like this is a security problem. Looking at uploadify.php, I see this:

$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';

Which means that passing "/" would put the file in the document root (i.e. the home directory of your website). Of course, the user could easily (for example) pass in a folder parameter like '../../etc' and a file named 'passwd'. Or, more trivially, he could upload a "logo.jpg" to the document root and, hey, now you've got porn for a site logo!

Of course, even if you sandbox the users, there are still lots of potential problems with allowing a user to arbitrarily upload a file to your server. What if they upload a .php file, then go to that file with their browser? They suddenly have the ability to execute arbitrary code on your server!

If you want to do this, you should force the user's uploads into a restricted directory (the realpath function will sanitize the path, in case the user created crazy paths with "../.." or whatever), and you should restrict the types of files allowed (i.e. to only ".jpg", ".gif", ".png" or whatever). Even then, a malicious user could DOS you by filling up your disk quota.

于 2009-10-20T21:32:10.910 回答
2

我只是想就你的帖子发表我的看法。你在分析中忘记了一件重要的事情。开发人员必须检查服务器端脚本中的变量。如果您使用 javascript(如 uploadify,或您自己的脚本)或者您不使用 javascript(只是 html 中的一个简单 FORM),您必须检查服务器端脚本中的数据。因此,无论您是否使用 uploadify 以确保您的安全。不要忘记构建 HTTP 请求并将其发送到服务器很容易。因此,Web 应用程序的安全性不取决于客户端

感谢您的关注

桂桂

于 2009-10-21T10:07:15.183 回答
1

您可以使用服务器端脚本和配置自由地将文件放在任何地方。我从不将他们的 javascript 配置用于此类事情。

于 2009-12-18T09:56:48.740 回答
1

这确实是一个安全问题,路径遍历。你应该给他们发电子邮件并要求他们修复它。

于 2009-10-21T00:32:52.430 回答
0

我知道这是一个有点老的话题,但这是插件开发人员的注释:

鉴于脚本语言种类繁多,服务器端验证取决于用户进行编码。我们正在开发插件,让那些知道自己在做什么的人可以在前端和后端使用他们想要的任何语言。并且创建新的脚本来检索信息使得其他用户实现起来有点困难,例如那些使用 aspx、java、codeigniter 等的用户需要重写插件的主要部分。

你可以在这里阅读全文。

请记住,服务器验证是必须的!你永远不能忽视它。这是我在阅读 SO 和 PHP 手册时学到的。

于 2010-08-22T11:20:12.497 回答