✨ hijack accessing window object with globalThis keyword (#1246)
This commit is contained in:
parent
5c3d278648
commit
92bddae77c
|
|
@ -71,6 +71,11 @@ test('window.self & window.window & window.top & window.parent should equals wit
|
||||||
expect(proxy.parent).toBe(proxy);
|
expect(proxy.parent).toBe(proxy);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('globalThis should equals with sandbox', () => {
|
||||||
|
const { proxy } = new ProxySandbox('globalThis');
|
||||||
|
expect(proxy.globalThis).toBe(proxy);
|
||||||
|
});
|
||||||
|
|
||||||
test('allow window.top & window.parent to escape sandbox while in iframe', () => {
|
test('allow window.top & window.parent to escape sandbox while in iframe', () => {
|
||||||
// change window.parent to cheat ProxySandbox is in iframe
|
// change window.parent to cheat ProxySandbox is in iframe
|
||||||
Object.defineProperty(window, 'parent', { value: 'parent' });
|
Object.defineProperty(window, 'parent', { value: 'parent' });
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,11 @@ export default class ProxySandbox implements SandBox {
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hijack global accessing with globalThis keyword
|
||||||
|
if (p === 'globalThis') {
|
||||||
|
return proxy;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
p === 'top' ||
|
p === 'top' ||
|
||||||
p === 'parent' ||
|
p === 'parent' ||
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user