Yet another way to invoke functions without parentheses
Source Entity
Hacker News

A researcher has discovered a novel JavaScript technique to invoke functions without parentheses by exploiting the Error object's prepareStackTrace method. This method leverages the Function constructor signature to generate arbitrary code execution patterns, highlighting potential security vulnerabilities in sandboxed environments.
Uncovering Novel JavaScript Function Invocation Vectors
A researcher has recently documented a sophisticated method for invoking arbitrary functions in JavaScript without the standard use of parentheses. By manipulating the prepareStackTrace function of the global Error object, this technique bypasses conventional syntax expectations, posing interesting questions about the inner workings of the V8 engine and similar JavaScript runtime environments.
The Mechanism: Exploiting prepareStackTrace
The core of this vulnerability lies in the behavior of Error.prepareStackTrace. In standard JavaScript execution, this function is automatically invoked when a developer accesses the .stack property of an error object, typically used for debugging and formatting stack traces. By overwriting this hook, an attacker can intercept the process and inject custom logic. Because the signature of this function mirrors that of the Function constructor, it can be coerced into generating functions that execute arbitrary code.
Implications for JavaScript Security
This discovery is significant for security researchers who focus on sandbox escapes and filter bypasses. Many security systems and web application firewalls (WAFs) rely on pattern matching to detect malicious payloads, often specifically looking for parentheses () as a primary indicator of function invocation. By finding ways to trigger execution without these characters, researchers can create obfuscated payloads that evade legacy signature-based detection systems.
Historical Context of Function Obfuscation
JavaScript has a long history of creative function invocation techniques. From the early days of using eval() to more modern exploits involving tagged template literals or specific prototype chain manipulations, the language's flexibility often works against its security posture. The ability to invoke code without standard syntax is a recurring theme in CTF (Capture The Flag) challenges and browser exploitation research, demonstrating that the language's design favors expressiveness over restrictive security boundaries.
Technical Limitations and Real-World Application
It is important to note that the provided method does not come without hurdles. The author of the research acknowledges that attempting to invoke the generated function directly often results in a syntax error. While this limits the immediate "weaponization" of the exploit in production environments, it serves as a proof-of-concept for how runtime hooks can be subverted. Developers should remain aware that relying on simple string-based filtering to secure JavaScript execution environments is insufficient.
Conclusion: Moving Toward Robust Sandboxing
As JavaScript continues to evolve, the attack surface for runtime environments grows. This research serves as a reminder that the internal mechanisms of the engine, such as stack trace generation, are not immune to manipulation. Future security trends will likely shift toward more robust Content Security Policy (CSP) headers and hardened runtime environments that do not allow for the arbitrary modification of intrinsic error-handling objects, effectively neutralizing these types of sophisticated invocation vectors.