xss - 什么是跨站脚本包含 (XSSI)?

标签 xss security

我最近在多个页面上看到了 XSSI,例如Web Application Exploits and Defenses :

Browsers prevent pages of one domain from reading pages in other domains. But they do not prevent pages of a domain from referencing resources in other domains. In particular, they allow images to be rendered from other domains and scripts to be executed from other domains. An included script doesn't have its own security context. It runs in the security context of the page that included it. For example, if www.evil.example.com includes a script hosted on www.google.com then that script runs in the evil context not in the google context. So any user data in that script will "leak."



我看不出这在实践中会产生什么样的安全问题。我了解 XSS 和 XSRF,但 XSSI 对我来说有点神秘。

任何人都可以绘制基于 XSSI 的漏洞利用程序吗?

谢谢

最佳答案

如果您使用 JSONP 传输数据,这通常是一个问题。考虑一个包含从域 B 加载数据的域 A 的网站。用户必须通过站点 A 和 B 的身份验证,并且因为同源策略阻止旧浏览器直接与不同于当前页面的域 (B) 通信(A)、开发者决定使用JSONP。所以站点 A 包含一个指向 http://B/userdata.js 的脚本这类似于:

displayMySecretData({"secret":"this is very secret", ...})

所以 A 定义了一个名为 displayMySecretData 的函数,并且当服务器 B 中包含的脚本运行时,它会调用该函数并向用户显示 secret 数据。

现在邪恶的服务器 E 出现了。它看到 A 正在使用 JSONP 包含来自 B 的数据。所以服务器 E 包含相同的脚本,但定义了自己的 displayMySecretData而是窃取数据。
然后攻击者诱骗用户访问他的网站。当用户去那里并登录到 B 时,浏览器会自动发送 B 的身份验证 cookie 以及从 B 获取脚本的请求。B 看到经过身份验证的用户,因此按预期返回脚本。 E获取数据,并预...

因此,使用 JSONP 以这种方式从不同域加载 secret 数据确实不安全,但人们仍在使用它。馊主意!

关于xss - 什么是跨站脚本包含 (XSSI)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8028511/

相关文章:

mysql - PostgreSQL 和 MySQL 权限管理等 CouchDB 数据库是否有访问控制?

c# - Request.PathInfo 问题和 XSS 攻击

node.js - MEAN.JS : Server username security

c# - 我的 .net 应用程序在本地计算机上运行,​​但在从网络位置使用时失败

security - 隐藏特定用户组的表单选项卡

security - 使用 Symfony2 的 AccessDeniedHandlerInterface

javascript - 默认情况下,Vue 是否为 XSS 提供安全性或防止 XSS?

javascript - 同源策略和外部脚本

javascript - 防止更改 HTML 表单操作

php - 文本输入卫生和安全