Facebook 代理加载程序安全性
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该限制代理从 Facebook 获取图像文件。您当前的“保护”将允许例如以下 URL:
http://virus.provider.com/fbcdn./virus.exe
$_SERVER['HTTP_REFERER']
的检查,以降低使用脚本进行热链接的动机。如果 HTTP_REFERER 不为空,请检查其中是否确实是您的网站。这将在很大程度上保护您免受带宽窃贼的侵害。还可以考虑在代理服务器上缓存文件数据,以加快对同一文件的多次调用。
这些是一些需要记住的事情。如果你花点心思,你可能会透露更多。
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
$_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.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.