9

我们正在为 HTML5 游戏设计一个在线街机游戏。用户可以上传包含他们游戏的 zip 文件。

上传时,服务器会解压缩 zip 文件,并循环检查每个文件的扩展名,以允许:

  • .html
  • .js
  • .png
  • .jpg
  • .appcache
  • .m4a
  • .ogg

(游戏必须在我们导出这些文件的游戏编辑器中制作)。这应该可以防止人们上传 zip、服务器端脚本文件等。

然后将游戏移至我们的静态无 cookie 域 (scirra.net)。当在我们的 scirra.com 页面上玩游戏时,游戏会显示在指向 scirra.net 域的 iframe 中。这应该可以防止恶意 JS 访问 scirra.com cookie。

这种 iframe 技术和白名单是否足够全面,可以防止任何恶意行为?请注意,我们无法真正筛选每个 JS 文件,因此我们应该假设人们会尝试上传恶意 JS。

4

3 回答 3

4

iframe的源继承规则将防止 scirra.net iframe 干扰 scirra.com。

然而,这并不能阻止所有攻击。实际上,您正在引入一个存储的 XSS 漏洞。XSS 可用于引入基于浏览器的攻击,例如利用 ActiveX 组件中的缓冲区溢出。利用 Flash、Adobe reader 或 Microsoft Office 中的漏洞。

您应该考虑在 scirra.net 内容上运行防病毒软件。尽管这并不能阻止所有攻击。iframe 页面可以重定向或引入另一个包含恶意内容的 iframe。

正如 Cheeksoft 指出的那样。应用程序将能够通过 XSS 相互影响。恶意应用程序可以访问另一个应用程序的离线存储或获取嵌入在另一个应用程序中的其他数据。强制每个应用程序都有其子域将缓解此问题。您可以设置 DNS 记录以将 *.scirra.net 指向您的服务器,并在您的 Web 应用程序中处理域名。

于 2011-11-22T15:30:01.640 回答
1

在您提供的游戏编辑器中加入一些筛选功能怎么样?屏蔽对外部 URL 的引用、执行代码验证、检查编码等。

您必须锁定 zip 文件以防止篡改,但无论如何这可能是个好主意。

于 2011-11-22T18:20:06.537 回答
0

For anyone else reading this, there is an experimental/beta iFrame sandbox attribute:

http://www.whatwg.org/specs/web-apps/current-work/multipage/the-iframe-element.html#attr-iframe-sandbox

Note it only currently works on Chrome and Opera. This allows you to specify some restricting features.

However in the case of our question we've scrapped the idea and have decided that because we are in the advantageous position of having a game creator program we can simply get the user to upload the Json data which is guaranteed to be safe with the core engine features being hosted by us.

Any plugins we can manually review and approve for use which is a much smaller job than manually approving every game.

于 2011-11-22T18:46:21.603 回答