You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] npx@7 regression: command injection / impossible to pass a bactick as argument #3306
Let’s say you have a create-blog-post CLI installed globally. You run it like so:
create-blog-post --title 'Cool `ls` tricks'
One day you install create-blog-postlocally instead. Then how do you run it? Well, you could just slap npx at the start, right? Wrong! The following does not do what you expect:
npx create-blog-post --title 'Cool `ls` tricks'
Let me show why. I’m using node -p 'process.argv[2]' -- instead of create-blog-post to show that the implementation of that tool wouldn’t matter:
The worst thing is that I don’t even know how to workaround this issue in npx@7. Trying to add backslashes does not help. I just can’t figure out a way to pass literal backticks as an argument.
Steps To Reproduce
macOS or Linux (Windows have different issues)
With this config...
Run npx node -p 'process.argv[1]' '`' (tested in sh, bash, zsh, fish)
See error: sh: -c: line 0: unexpected EOF while looking for matching ``'
I’m posting an issue here as well so the PR has something to close 😄 And also to help people who have encountered the same problem can more easily find this.
Activity
balazs4 commentedon Dec 26, 2021
another usecase, same problem
antonmedv/fx#176
I'm looking forward to npm/exec#2
ruyadorno commentedon Mar 2, 2022
cc @nlf who has been following up with npm/run-script#31
nlf commentedon May 5, 2022
I'm unable to reproduce this in npm@8.9.0. I'm going to close this issue, but please do open a new one if you see this happen again.
lydell commentedon May 5, 2022
@nlf Can you reopen this one, please? This is still an issue in 8.9.0.
And when you do fix it, please link the commit that fixes it. Bonus points for a regression test!
Edit: Opened a new issue.