Skip to content

fix(node): avoid PATH-dependent shell execution in musl probe#11

Open
NeerajCodz wants to merge 1 commit into
mainfrom
codex/fix-command-execution-vulnerability-in-node-loader
Open

fix(node): avoid PATH-dependent shell execution in musl probe#11
NeerajCodz wants to merge 1 commit into
mainfrom
codex/fix-command-execution-vulnerability-in-node-loader

Conversation

@NeerajCodz

Copy link
Copy Markdown
Contributor

Motivation

  • The Node loader's fallback in isMusl() used child_process.execSync('which ldd'), which invokes a shell and resolves which through PATH, enabling local PATH-poisoning to execute attacker-controlled binaries during module import on older Node runtimes.
  • The musl probe is invoked during Linux native binding selection, so importing the generated N-API loader could trigger this command execution.

Description

  • Replace the PATH-dependent execSync('which ldd') probe with a safe fixed-path check that inspects /usr/bin/ldd and /bin/ldd using existsSync and readFileSync in bindings/node/index.js.
  • Preserve the existing fallback behavior by returning true on probe errors and leave the remaining loader selection logic unchanged.

Testing

  • Ran node --check bindings/node/index.js to validate the modified file is syntactically valid, and it succeeded.
  • No other automated tests were modified or required for this change.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant