Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed window references bypass extension #651

Open
NDevTK opened this issue Apr 16, 2023 · 3 comments
Open

Closed window references bypass extension #651

NDevTK opened this issue Apr 16, 2023 · 3 comments
Labels

Comments

@NDevTK
Copy link

NDevTK commented Apr 16, 2023

frame = document.createElement('iframe');
document.body.appendChild(frame);
ref = frame.contentWindow;
document.body.removeChild(frame);

setTimeout(() => {
    console.log('Real: ', ref.navigator.userAgent);
}, 1000)

console.log('Fake: ', navigator.userAgent);
@kkapsner
Copy link
Owner

This is a bad one... not sure if I can do anything about that. The underlying window object seems to get deleted and the recreated:
image

@kkapsner kkapsner added the bug label Apr 19, 2023
@NDevTK
Copy link
Author

NDevTK commented Apr 19, 2023

If document.createElement was proxied it could be that after the element is deleted calls to .contentWindow would just fail.
Yeah sandboxing JS is hard there's a project https://github.com/lavamoat/snow just for this purpose but even that's got bypasses.

@kkapsner
Copy link
Owner

.contentWindow is already protected and the protection works if the timeout is called earlier:

var frame = document.createElement('iframe');
document.body.appendChild(frame);
var ref = frame.contentWindow;
document.body.removeChild(frame);

[0, 1, 10, 100, 1000].forEach(function(timeout){
    setTimeout(() => {
        console.log('timeout', timeout, ":", ref.navigator.userAgent);
    }, timeout)
});

console.log('directly: ', ref.navigator.userAgent);

image

I even saw the timeout 10 to still be protected.

So it's something that is happening in the background.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants