iframe parent 是否可以访问 child cookie-based 身份验证令牌?
Does iframe parent have access to child cookie-based authentication token?
我有一个产品需要 sign-in 身份验证。我使用 jwt 但将其存储在 cookie 中(我知道一旦存在 xss 漏洞,这可能会成为问题)。
该产品还提供给一些通过 iframe
嵌入它的“其他域”。
我很好奇在这种情况下是否存在我没有考虑到的任何安全风险。
例如parent,“其他域”是否可以访问我的身份验证令牌,因为我使用 cookie 来存储我的 JWT 令牌?如果 parent 有 xss 漏洞,那么这对我来说也自动意味着一个漏洞?
I have a product that requires sign-in authentication. I use jwt but store that inside cookie (which I know could be a problem once there is an XSS vulnerability)
存储在 Cookie 中不是问题现在通过使用一些 headers 像 sameSite 和 CSP 更难利用 XSS 他们可以 Pop-up 警告框但他们不能窃取 cookie 虽然它给你使用它的信心实际上取决于您如何编写功能代码。如果您使用的是 frameWorks(如 Jinja、Vue、angular、ejs..etc),攻击者注入代码的可能性非常低。
This product is also given to some "other domains" that embed it through an iframe
如果 parent 域有 XSS。那么可能iFrame也影响了To XSS。他们可以看到内容并将其发送到域或有一个名为 xsshunter.io 的工具,您可以通过在开发服务器上测试 IT 来检查。但是,如果您使用 CSP 和 Same-site: Lax 那么这不是问题,除了白名单域之外,不会与外部域进行通信。
如果它是垂直权限从 child 到 parent 那么你有一个很棒的功能叫做 iframe 中的沙箱。
(no value) Applies all restrictions
allow-forms Allows form submission
allow-modals Allows to open modal windows
allow-orientation-lock Allows to lock the screen orientation
allow-pointer-lock Allows to use the Pointer Lock API
allow-popups Allows popups
allow-popups-to-escape-sandbox Allows popups to open new windows without inheriting the sandboxing
allow-presentation Allows to start a presentation session
allow-same-origin Allows the iframe content to be treated as being from the same origin
allow-scripts Allows to run scripts
allow-top-navigation Allows the iframe content to navigate its top-level browsing context
allow-top-navigation-by-user-activation Allows the iframe content to navigate its top-level browsing context, but only if initiated by the user
在 headers 中使用 JWT 是一种很好的做法,但是在 cookie 中使用它完全没有问题但是在 headers 中使用 JWt 更安全。
希望这对你有帮助!
我有一个产品需要 sign-in 身份验证。我使用 jwt 但将其存储在 cookie 中(我知道一旦存在 xss 漏洞,这可能会成为问题)。
该产品还提供给一些通过 iframe
嵌入它的“其他域”。
我很好奇在这种情况下是否存在我没有考虑到的任何安全风险。
例如parent,“其他域”是否可以访问我的身份验证令牌,因为我使用 cookie 来存储我的 JWT 令牌?如果 parent 有 xss 漏洞,那么这对我来说也自动意味着一个漏洞?
I have a product that requires sign-in authentication. I use jwt but store that inside cookie (which I know could be a problem once there is an XSS vulnerability)
存储在 Cookie 中不是问题现在通过使用一些 headers 像 sameSite 和 CSP 更难利用 XSS 他们可以 Pop-up 警告框但他们不能窃取 cookie 虽然它给你使用它的信心实际上取决于您如何编写功能代码。如果您使用的是 frameWorks(如 Jinja、Vue、angular、ejs..etc),攻击者注入代码的可能性非常低。
This product is also given to some "other domains" that embed it through an iframe
如果 parent 域有 XSS。那么可能iFrame也影响了To XSS。他们可以看到内容并将其发送到域或有一个名为 xsshunter.io 的工具,您可以通过在开发服务器上测试 IT 来检查。但是,如果您使用 CSP 和 Same-site: Lax 那么这不是问题,除了白名单域之外,不会与外部域进行通信。 如果它是垂直权限从 child 到 parent 那么你有一个很棒的功能叫做 iframe 中的沙箱。
(no value) Applies all restrictions allow-forms Allows form submission allow-modals Allows to open modal windows allow-orientation-lock Allows to lock the screen orientation allow-pointer-lock Allows to use the Pointer Lock API allow-popups Allows popups allow-popups-to-escape-sandbox Allows popups to open new windows without inheriting the sandboxing allow-presentation Allows to start a presentation session allow-same-origin Allows the iframe content to be treated as being from the same origin allow-scripts Allows to run scripts allow-top-navigation Allows the iframe content to navigate its top-level browsing context allow-top-navigation-by-user-activation Allows the iframe content to navigate its top-level browsing context, but only if initiated by the user
在 headers 中使用 JWT 是一种很好的做法,但是在 cookie 中使用它完全没有问题但是在 headers 中使用 JWt 更安全。 希望这对你有帮助!