{
  "description": "Browse aymeric's, an independent, searchable archive of readable snapshots from followed feeds, preserved in Git with aggr.",
  "feed_url": "https://aggr.aymericbeaumet.com/sources/blog.ikaes.de/feed.json",
  "home_page_url": "https://aggr.aymericbeaumet.com/sources/blog.ikaes.de/",
  "items": [
    {
      "authors": [
        {
          "name": "aragonite"
        }
      ],
      "content_html": "<p>i found yet another way to invoke arbitrary functions in javascript without using parentheses</p>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://blog.ikaes.de/static/01a10710-829b-7587-9e27-10e88ffa7349.png\" alt=\"\" loading=\"eager\" decoding=\"async\" fetchpriority=\"high\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<p>this payload works by overwriting the <code>prepareStackTrace</code> function of the <code>Error</code> object to generate arbitrary functions. it is usually used <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://v8.dev/docs/stack-trace-api#customizing-stack-traces\">to format stack traces</a> and is invoked when the attribute <code>stack</code> of an error is accessed.</p>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://blog.ikaes.de/static/01a1073b-7a44-778f-96de-87762c1da0f6.png\" alt=\"\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<p>the parameters of this function are the error and &quot;<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://v8.dev/docs/stack-trace-api#customizing-stack-traces\">a structured representation of the stack</a>&quot; , which is just an array of the code positions. it has the same function signature the <code>Function constructor</code> which is used to generate javascript functions, as long as the second argument is valid javascript code.</p>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://blog.ikaes.de/static/01a1071b-7b38-72c3-b3b9-3aa2be848dcf.png\" alt=\"\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<p>if we try to invoke the function which was generated using this method, we get a syntax error. it is to be expected, because a stack trace is not a valid javascript code, but an <code>Array</code> of code positions</p>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://blog.ikaes.de/static/01a10722-3e9d-7017-bfe9-5d5984187ccf.png\" alt=\"\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<p>in order to make the payload work, we need to control the output of the <code>Array.prototype.toString()</code> function such that it returns our desired javascript payload. this can be done in two ways</p>\n<p>first we can simply overwrite it with a constant function which returns the payload</p>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://blog.ikaes.de/static/01a10724-7465-757c-add0-cc6b60390c92.png\" alt=\"\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<p>or we can use prototype pollution to sneak our payload into another function, and then overwrite the <code>Array</code> prototype. i found that we can stay in the <code>Error</code> realm and use its <code>toString</code> function which can be manipulated by polluting the <code>Object.prototype.message</code> variable. i am sure there are more ways to achieve this.</p>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://blog.ikaes.de/static/01a10726-a6f6-723f-9bb0-921d08f5d629.png\" alt=\"\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<p>now if we put everything together - the function generation using the <code>prepareStackTrace</code> function and way to convert arrays into arbitrary strings, we can generate arbitrary javascript functions</p>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://blog.ikaes.de/static/01a10728-85b1-7319-aa14-a5ffea0324a0.png\" alt=\"\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<p>last thing we have to do is to invoke our new function. luckily there are <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://stackoverflow.com/questions/35949554/how-could-it-be-possible-to-invoke-a-function-without-using-parentheses\">many ways to do so</a> and i chose the <code>valueOf</code> trick. it works by overwriting the default <code>valueOf</code> function of our object and then invoking it as a primitive. alternatively, we can use <code>toString</code> and then concatenate the object with a string.</p>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://blog.ikaes.de/static/01a1072b-aab4-74f3-89ef-968ca7f7a062.png\" alt=\"\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<p>the final payload is as follows. feel free to try it out in the browser console.</p>\n<pre><code><span class=\"code-snippet\">Object.prototype.message=&#39;alert\\x281337\\x29&#39;;Array.prototype.toString=Error.prototype.toString;Error.prepareStackTrace = Function;const x = new Error;x.valueOf=x.stack;+x;\n</span></code></pre>\n",
      "date_modified": "2026-10-13T19:25:18+00:00",
      "date_published": "2026-10-13T19:25:18+00:00",
      "external_url": "https://blog.ikaes.de/yet-another-way-to-invoke-functions-without-parentheses/",
      "id": "urn:aggr:item:7657e75ff4e1a76a0f7761788c124989e49b412e",
      "summary": "i found yet another way to invoke arbitrary functions in javascript without using parentheses this payload works by overwriting the prepareStackTrace function of the Error object to generate arbitrary functions. it is usually used to…",
      "tags": [
        "news"
      ],
      "title": "Yet another way to invoke functions without parentheses",
      "url": "https://aggr.aymericbeaumet.com/items/hnrss-org/2026-10-13-yet-another-way-to-invoke-functions-without-parentheses/"
    }
  ],
  "language": "en",
  "title": "blog.ikaes.de",
  "version": "https://jsonfeed.org/version/1.1"
}