-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
Description
What is the problem this feature will solve?
eval() and Function() in Node.js allow executing arbitrary code at runtime. While powerful, they are a common vector for security vulnerabilities and accidental code injection. Currently, eval() is enabled by default, which means that even minor mistakes or untrusted dependencies can execute code dynamically, increasing security risks.
By disabling eval() by default, Node.js can provide a safer runtime out of the box. This change encourages developers to use safer alternatives such as vm or strict sandboxing, reducing potential attack surfaces in Node.js applications.
As you can see in this commit, you can somehow insert arbitrary code on a commit and not even notice.
This video (in spanish, by @midudev), explains how they attacked him through this method. Is crazy
What is the feature you are proposing to solve the problem?
Introduce a new opt-in flag --enable-eval in Node.js.
-
Default behavior: eval() and Function() are disabled in the runtime. Any attempt to use them without the flag will throw an error.
-
Opt-in: Users can explicitly enable eval() for legacy applications or specific use cases by passing
node --enable-eval index.js -
Benefits:
-
- Improves default security for Node.js applications.
-
- Prevents accidental dynamic code execution in production.
-
- Allows developers to consciously decide when they need eval().
Metadata
Metadata
Assignees
Labels
Type
Projects
Status