Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

node_modules parent climbing is a security risk #8830

Closed
@ivan

Description

@ivan

node climbs up to find modules, even in places like /home/node_modules, /node_modules, or C:\node_modules on Windows. The Windows case is particularly problematic because any user can create a directory in C:\.

This has been brought up before:
https://groups.google.com/forum/#!searchin/nodejs/node_modules$20security/nodejs/5BGr5dliUIk/abJEH3sPymcJ

Whether you like the behavior or not, node is compromising the security of multi-user servers and desktops. A shared hosting provider shouldn't need to know that they need to blacklist a "node_modules" username, and developers on Windows shouldn't need to create and secure a C:\node_modules directory before developing or running node.js software.

Here's a straw man proposal: by default, blacklist certain paths: /node_modules and C:\node_modules. If running inside $HOME, don't climb up outside $HOME (this effectively blacklists /home/node_modules and C:\Users\node_modules). Also, avoid loading from directories that appear to allow anyone to write to them. For the few exotic deployments out there, expose node's original search behavior behind an argument.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions