DEV Community

Discussion on: Executing Shell Scripts with NodeJS

Collapse
 
antongolub profile image
Anton Golub

Ok, here's a RCE example)

const arg = '"hello" && echo "rm -rf ./ may be here"'
const cmd = `echo ${arg}`
Enter fullscreen mode Exit fullscreen mode

Key tip: you need to understand the boundaries of the arguments and escape the characters that can violate them.

Thread Thread
 
aabhassao profile image
Aabhas Sao

Thanks now I get it. Passing user input in such commands can be dangerous. Similar to the way SQL injection attacks happen by I'll formatted arguments.

Thread Thread
 
aabhassao profile image
Aabhas Sao

I would surely put some disclaimer on that.