vercel / pkg

Package your Node.js project into an executable
https://npmjs.com/pkg
MIT License
24.28k stars 1.01k forks source link

Is this safe from code injection to steal the code? #1981

Closed damartripamungkas closed 10 months ago

damartripamungkas commented 1 year ago

What version of pkg are you using?

5.8.1

What version of Node.js are you using?

20.3.1

What operating system are you using?

macOs, Windows, Linux

What CPU architecture are you using?

x64

What Node versions, OSs and CPU architectures are you building for?

node18

Describe the Bug

no bugs just wanted to ask, questions in the description

Expected Behavior

Is this safe from code injection by running UNTRUSTED CODE? I mean code injection to steal the code, below is a simple code to run it :

// config.js
exports.addInt = (a) => {
    return Math.random() + parseInt(a)
}
// index.js
const { join } = require("node:path")
const { cwd } = require("node:process")
const props = require(join(cwd(), "config.js"))
console.log(props.addInt(123))

To Reproduce

code is in the description above