Facebook 代理加载程序安全性

发布于 2024-11-08 13:47:48 字数 817 浏览 0 评论 0原文

我正在使用 PHP 代理脚本将图像从 Facebook 加载到 Flash 中,而没有任何沙箱违规。它取自此处的指南:http://www.permadi.com/blog/2010/12/loading-facebook-profile-picture-into-flash-swf-using-open-graph-api/ 。相关的 PHP 代码是:

<?php
    $path=$_GET['path'];
    if (stristr($path, "fbcdn.")==FALSE && stristr($path, "facebook.")==FALSE)
    {
        echo "ERROR";
        exit;
    }
    header("Content-Description: Facebook Proxied File");
    header("Content-Type: image");
    header("Content-Disposition: attachment; filename=".$path);
    @readfile($path);
?>

该指南提到,建议针对实际应用程序采取额外的安全措施。对此将采取哪些额外措施?也许某种密钥从 Flash 传递到 PHP?

我意识到我无法完全保护Flash不被反编译,但是我可以防止脚本被恶意使用吗?

I'm using a PHP proxy script to load images from Facebook into Flash without any sandbox violations. It is taken from the guide here: http://www.permadi.com/blog/2010/12/loading-facebook-profile-picture-into-flash-swf-using-open-graph-api/. The relevant PHP code is:

<?php
    $path=$_GET['path'];
    if (stristr($path, "fbcdn.")==FALSE && stristr($path, "facebook.")==FALSE)
    {
        echo "ERROR";
        exit;
    }
    header("Content-Description: Facebook Proxied File");
    header("Content-Type: image");
    header("Content-Disposition: attachment; filename=".$path);
    @readfile($path);
?>

The guide mentions that additional security measures are recommended for a real world application. What additional measures would be applicable to this? Maybe some kind of key passed from Flash to PHP?

I realise that there's nothing I can do to completely protect the Flash from being decompiled, but can I prevent the script from being used maliciously?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妳是的陽光 2024-11-15 13:47:48

您应该限制代理从 Facebook 获取图像文件。您当前的“保护”将允许例如以下 URL:http://virus.provider.com/fbcdn./virus.exe

  • 更好地检查域 bname,可能使用 parse_url 函数。
  • 检查您是否确实只提供图像。确保文件名以图像扩展名结尾(这对 Windows 客户端有很大帮助),但也要考虑对实际文件内容进行更彻底的检查。
  • 考虑添加对 $_SERVER['HTTP_REFERER'] 的检查,以降低使用脚本进行热链接的动机。如果 HTTP_REFERER 不为空,请检查其中是否确实是您的网站。这将在很大程度上保护您免受带宽窃贼的侵害。
  • 确保它实际上是远程路径。您当前的脚本可能会被诱骗发送未解析的 PHP 文件,包括密码和其他机密!
  • Content-Disposition 标头中的文件名应设置为文件名,而不是整个路径。

还可以考虑在代理服务器上缓存文件数据,以加快对同一文件的多次调用。

这些是一些需要记住的事情。如果你花点心思,你可能会透露更多。

You should restrict the proxy to fetching image files from Facebook. You current "protection" will allow for example this URL: http://virus.provider.com/fbcdn./virus.exe

  • Make better checks of the domain bname, maybe using the parse_url function.
  • Check that you are indeed serving only images. Make sure the filename is ending in a image extension (this helps a lot for Windows clients), but also consider doing more thorough checks of the actual file content.
  • Consider adding a check of the $_SERVER['HTTP_REFERER'] to lower the incentives to use your script for hotlinking. If the HTTP_REFERER is non-empty, check that it's actually your site in there. This will mostly protect you from bandwidth thieves.
  • Make sure it's actually a remote path. Your current script can be tricked to sending for example your PHP files unparsed, including passwords and other secrets!
  • The filname in the Content-Disposition header should be set to a filename, not to the entire path.

Also consider caching the file data on your proxy server to speed up multiple calls to the same file.

These are a few of the things to keep in mind. You may reveal more if you put some thought into it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文