允许 Flash 影片与包含窗口通信而不暴露完整的外部接口?

发布于 2024-12-10 09:57:27 字数 630 浏览 0 评论 0原文

我正在开发一个允许管理员上传任意 SWF 并将其嵌入页面的网站。理论上,管理员是值得信任的,但我仍然希望防止潜在的恶意管理员或受误导的管理员损害网站。

该站点的部分功能是 SWF 可以在完成后与包含的浏览器页面进行通信并让页面做出反应。

现在,我可以想到两种方法来执行此操作:

  • 使用 ExternalInterface.addCallback 创建一个名为 isComplete 之类的全局回调,该回调执行逻辑并返回 true 或 false,具体取决于是否Flash 应用程序处于完成状态。然后,只需执行类似 setTimeout 的操作即可重复调用该函数。我认为这不需要我打开电影的 allowscriptaccess
  • 使用 allowscriptaccess 嵌入影片,并让影片在完成时调用类似 ExternalInterface.call('done') 的内容。此选项似乎需要我打开 allowscriptaccess,这是一个潜在的威胁,因为我无法控制嵌入该指令的 SWF。

我是否缺少一个不涉及无限循环并且不需要我公开安全风险的解决方案?

I'm working on a site that allows administrators to upload arbitrary SWFs and embed them on the page. Administrators are in theory trusted, but I still want to protect against potentially malicious administrators or misguided administrators from harming the site.

A part of the functionality of the site is that the SWFs can communicate to the containing browser page when it's finished and for the page to react.

Now, I can think of two ways to do this:

  • Use ExternalInterface.addCallback to create a global callback named something like isComplete that does logic and returns true or false depending on whether the Flash app is in a completed state. Then, just do something like setTimeout to just call that function repeatedly. I don't think this would require me to open up allowscriptaccess to the movie.
  • Embed the movie with allowscriptaccess and have the movie call something like ExternalInterface.call('done') when it's finished. This option seems like it requires me to open up allowscriptaccess, which is a potential threat since I can't control the SWFs that would be embedded with this directive.

Is there a solution I'm missing that doesn't involve doing the infinite loop and also doesn't require me to open up a security risk?

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

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

发布评论

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

评论(1

探春 2024-12-17 09:57:27

不要将 SWF 直接嵌入到主页中,而是将它们嵌入到托管在子域(或某些其他域)上的单独页面中。然后,通过主页中的 显示该子页面。这样,您将拥有一个跨域。继续并授予 SWF allowscriptaccess 权限。然后,通过 postMessage(或跨浏览器模拟脚本)与 iframe 进行通信。这样,SWF 就可以对页面做任何他们想做的事情,但到主页只有一个受控的“隧道”。

Instead of embedding your SWFs directly in the main page, embed them in a separate page that's hosted on a subdomain (or some other domain). Then, display that subpage via an <iframe> in your main page. This way, you'll have a cross-domain <iframe>. Go ahead and give the SWF allowscriptaccess permissions. Then, communicate via postMessage (or a cross-browser simulation script) with the iframe. This way, the SWF can do anything they want to the page, but there's only one controlled "tunnel" to the main page.

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