为什么 Electron 会杀死 Windows 个有冒号参数的进程?
Why does Electron kill Windows processes that have arguments with colons?
如果我启动一个带有冒号参数的 Electron 程序,程序会立即退出。
Process process = new Process();
process.StartInfo.FileName = "C:\Program Files (x86)\SomeElectronApp.exe";
process.StartInfo.Arguments = "ab:c d";
process.Start();
process.WaitForExit();
Console.WriteLine(1); // break point here
但是,如果我交换参数,使带冒号的参数始终排在最后,那么程序将成功启动。
这里提到here:
[This] is a security mitigation against an age old windows flaw
有没有人知道这个缺陷是什么?
更新:
找到源代码here:
函数CheckCommandLineArguments
具有逻辑:
else if (IsUrlArg(argv[i])) {
block_args = true;
}
IsUrlArg
的作用:
// colon indicates that the argument starts with a URI scheme
if (c == ':') {
// it could also be a Windows filesystem path
if (p == arg + 1)
break;
return true;
}
“缺陷”很可能是包含空格的未加引号的文件名。
考虑
> "C:\Program Files (x86)\SomeElectronApp.exe" "C:\Program Files (x86)\SomeElectronFile.dat"
对
> "C:\Program Files (x86)\SomeElectronApp.exe" C:\Program Files (x86)\SomeElectronFile.dat
或
> C:\Program Files (x86)\SomeElectronApp.exe C:\Program Files (x86)\SomeElectronFile.dat
如果您错误地将文件关联设置为
path\to\exe %1
而不是
path\to\exe "%1"
那么每个使用 ShellExecute
函数的程序都会向您传递一个不带引号的文件名,即使它包含空格。
使它成为“windows”缺陷的是,在 Windows 上,单个命令行字符串被传递给生成的程序,该程序负责将其分解为argv
数组。相比之下,大多数其他操作系统都传递一个参数数组,因此启动程序必须努力将文件名分成多个单词。
通过查看提交找到答案。
已修复远程代码执行漏洞 (CVE-2018-1000006)。 Source:
Affected versions of electron may be susceptible to a remote code execution flaw when certain conditions are met:
- The electron application is running on Windows.
- The electron application registers as the default handler for a protocol, such as nodeapp://.
This vulnerability is caused by a failure to sanitize additional arguments to chromium in the command line handler for Electron.
如果我启动一个带有冒号参数的 Electron 程序,程序会立即退出。
Process process = new Process();
process.StartInfo.FileName = "C:\Program Files (x86)\SomeElectronApp.exe";
process.StartInfo.Arguments = "ab:c d";
process.Start();
process.WaitForExit();
Console.WriteLine(1); // break point here
但是,如果我交换参数,使带冒号的参数始终排在最后,那么程序将成功启动。
这里提到here:
[This] is a security mitigation against an age old windows flaw
有没有人知道这个缺陷是什么?
更新:
找到源代码here:
函数CheckCommandLineArguments
具有逻辑:
else if (IsUrlArg(argv[i])) {
block_args = true;
}
IsUrlArg
的作用:
// colon indicates that the argument starts with a URI scheme
if (c == ':') {
// it could also be a Windows filesystem path
if (p == arg + 1)
break;
return true;
}
“缺陷”很可能是包含空格的未加引号的文件名。
考虑
> "C:\Program Files (x86)\SomeElectronApp.exe" "C:\Program Files (x86)\SomeElectronFile.dat"
对
> "C:\Program Files (x86)\SomeElectronApp.exe" C:\Program Files (x86)\SomeElectronFile.dat
或
> C:\Program Files (x86)\SomeElectronApp.exe C:\Program Files (x86)\SomeElectronFile.dat
如果您错误地将文件关联设置为
path\to\exe %1
而不是
path\to\exe "%1"
那么每个使用 ShellExecute
函数的程序都会向您传递一个不带引号的文件名,即使它包含空格。
使它成为“windows”缺陷的是,在 Windows 上,单个命令行字符串被传递给生成的程序,该程序负责将其分解为argv
数组。相比之下,大多数其他操作系统都传递一个参数数组,因此启动程序必须努力将文件名分成多个单词。
通过查看提交找到答案。
已修复远程代码执行漏洞 (CVE-2018-1000006)。 Source:
Affected versions of electron may be susceptible to a remote code execution flaw when certain conditions are met:
- The electron application is running on Windows.
- The electron application registers as the default handler for a protocol, such as nodeapp://.
This vulnerability is caused by a failure to sanitize additional arguments to chromium in the command line handler for Electron.