본 사이트는 여러분의 사용자 경험을 개선하기 위해 유지 보수를 진행하는 동안 기능이 제한됩니다. 도움말로 문제가 해결되지 않고 질문을 하고 싶다면 Twitter의 @FirefoxSupport 및 Reddit의 /r/firefox 채널을 활용하세요.

Mozilla 도움말 검색

고객 지원 사기를 피하세요. 저희는 여러분께 절대로 전화를 걸거나 문자를 보내거나 개인 정보를 공유하도록 요청하지 않습니다. "악용 사례 신고"옵션을 사용하여 의심스러운 활동을 신고해 주세요.

자세히 살펴보기

Why does Firefox execute Javascript in the referring window's/tab's context when target="_blank" is used with a data:uri?

more options

I set a link's target to _blank. With the href attribute set to a data-uri with a script tag, and the previous window's context executes the javascript. Does this happen with using window.open()? This would allow an attacker with XSS to steal localStorage data, and there is apparently no way for a developer to isolate a window's execution context. My question is, why does a data:uri execute script in the previous window's (i.e the window with the target="_blank" attribute set) context even though it opens in a new tab? And, how is a developer supposed to isolate a window's Javascript context, since _blank doesn't do it?

I set a link's target to _blank. With the href attribute set to a data-uri with a script tag, and the previous window's context executes the javascript. Does this happen with using window.open()? This would allow an attacker with XSS to steal localStorage data, and there is apparently no way for a developer to isolate a window's execution context. My question is, why does a data:uri execute script in the previous window's (i.e the window with the target="_blank" attribute set) context even though it opens in a new tab? And, how is a developer supposed to isolate a window's Javascript context, since _blank doesn't do it?

선택된 해결법

JavaScript allows some access between windows (e.g., using the window.opener property from the "child" window).

What is the attack you want to guard against?

문맥에 따라 이 답변을 읽어주세요 👍 0

모든 댓글 (3)

more options

I don't use data URIs, so this may be a dumb question: is Firefox processing your data URI differently than the way it would execute the same code in an onclick handler in the same link?

more options

I think it would be processing it the same way as onclick. The inconsistency here is, a _blank or a _new window implies a new context, but the Javascript runs in the same context that it came from. Is there a secure way to isolate the two windows? (one with the link, and one that just opened by clicking the link)

more options

선택된 해결법

JavaScript allows some access between windows (e.g., using the window.opener property from the "child" window).

What is the attack you want to guard against?