New JavaScript trick invokes arbitrary functions without parentheses

Yet another way to invoke functions without parentheses

A new technique exploits Error.prepareStackTrace and prototype pollution to call functions without parentheses. By overwriting prepareStackTrace, the stack trace becomes a function generated by the Function constructor. Polluting Object.prototype.message and Array.prototype.toString turns the stack array into executable code, and the valueOf trick triggers the call. The final payload fits in a few lines.

i found yet another way to invoke arbitrary functions in javascript without using parentheses
  1. hans_castorp

    This reminds me of "Creators admit Unix, C hoax" (e.g. https://www.gnu.org/fun/jokes/unix-hoax.html)

    > We stopped when we got a clean compile on the following syntax:

    for(;P("\n"),R--;P("|"))for(e=C;e--;P("_"+(*u++/8)%2))P("| "+(*u/4)%2);

  2. nathell

    I love this. This is a fun hack, but the article also hearkens back to pre-LLM days when people were still interested in _code_.

  3. amelius

    I want to put the called function after the arguments:

    (((x)f)g)h

    So I can see exactly the order in which things happen, from left to right.

    As opposed to:

    f(g(h(x)))

    where I have to read backwards.

  4. MattCruikshank

    I want to write a super pedantic book showing every way I can think of to move data from here, to there. In the same program, or between programs.

    Global variable.

    Parameter to a function.

    Pass a functor/lambda, get the value.

    Environment variable.

    Registry.

    File.

    Store it in a ping response.

    VRAM texture that you write and then read.

    Database.

    REST server.

    I'm pretty sure I could come up with a thousand ways.

    But... why? Why do I want to write this book? Why has it been on my mind?

  5. sharktheone

    TC39 member here; There are a lot more ways in JS to call a function without parenthesis. The first thing to come to my mind is Symbol.isConcatSpreadable or Symbol.iterator which works in multiple places

  6. CrendKing

    Not gonna work on Firefox, since according to the doc, Error.prepareStackTrace is an optional API and only implemented by V8.

  7. pards

    Off topic: This website looks like a ransom note

  8. TheSilva

    Object.prototype.message='alert\x281337\x29';Array.prototype.toString=Error.prototype.toString;Error.prepareStackTrace = Function;const x = new Error;x.valueOf=x.stack;+x;

    Well, that's a mouthful! So many years and JavaScript still can do the most amazing, weird, awesome, scary, obscure, and sexy things in the world of coding.

More from this day

2026-10-16