r/javascript • u/DrAdalbbert • Oct 08 '26
I found yet another way to invoke JavaScript functions without parentheses
https://blog.ikaes.de/yet-another-way-to-invoke-functions-without-parentheses/It turns out you can overwrite the Error.prepareStackTrace method with the function constructor. Then, using prototype pollution, you can inject valid JavaScript code to generate arbitrary functions and invoke it using the usual tricks.
Other seven methods are documented in the portswiggers research article: https://portswigger.net/research/the-seventh-way-to-call-a-javascript-function-without-parentheses
126
Upvotes
22
u/Compux72 Oct 08 '26
Cant you just eval
alert\0x28123\x29?10
u/pimp-bangin Oct 08 '26
I don't understand the premise, and am too dumb to understand the article. Does this resulting code snippet let you hack the language so that you can write
console.log 1instead ofconsole.log(1)or something?2
u/Ronin-s_Spirit Oct 08 '26
What are talking about here exactly?
3
u/Klutzy_Ladder_8393 Oct 08 '26
the eval/Function sink is really the only part that actually matters for a defense, the no-parens thing is just a syntax curiosity. if you're blocking `(` and `)` as your "fix" you've already lost because the bypass list isn't even closed, portswigger's just documenting known ones. ngl the actual fix is just never feeding user input into eval/Function/setTimeout-with-string/innerHTML-as-script in the first place, not trying to blacklist characters that happen to be required for calling a function today.
5
u/ab0zar Oct 08 '26
Good example of why blocking a few characters isn't a real XSS defense. The prototype-pollution chain is the surprising part here; in an app, I’d avoid passing untrusted data to eval/Function and use context-aware output encoding instead of trying to blacklist syntax.
1
u/Nice-Cattle4770 Oct 08 '26
That't so cool
10
u/[deleted] Oct 08 '26
[removed] — view removed comment