使用execFile用于Bash脚本的安全性如何? [英] How Secure is using execFile for Bash Scripts?

查看:79
本文介绍了使用execFile用于Bash脚本的安全性如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个node.js应用程序,它使用child_process.execFile命令运行命令行实用程序。

I have a node.js app which is using the child_process.execFile command to run a command-line utility.

我担心用户可能会在本地运行命令(想到一个 rm / -rf 恐怖场景)。

I'm worried that it would be possible for a user to run commands locally (a rm / -rf horror scenario comes to mind).

使用execFile用于Bash脚本的安全性如何?要确保传递给execFile的标志被托管服务器的unix框转义的任何提示?

How secure is using execFile for Bash scripts? Any tips to ensure that flags I pass to execFile are escaped by the unix box hosting the server?

更准确地说,我是m进一步想知道发送到文件的参数是否可以解释为命令并执行。

To be more precise, I'm more wondering if the arguments being sent to the file could be interpreted as a command and executed.

另一个关注点是在bash脚本本身内部,从技术上讲不在此问题范围内。

The other concern is inside the bash script itself, which is technically outside the scope of this question.

推荐答案

单独使用 child_process.execFile 绝对安全

它不会在shell中运行命令(例如 child_process.exec 确实),因此无需转义任何内容。

It does not run the command in a shell (like child_process.exec does), so there is no need to escape anything.

这篇关于使用execFile用于Bash脚本的安全性如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆