Skip to content

[安全风险] start.bat 中内嵌 Base64 PowerShell 代码将被企业 EDR/杀毒软件拦截 #41

@SonicBotMan

Description

@SonicBotMan

问题描述

start.bat 将一段 PowerShell 脚本用 Base64 UTF-16LE 编码后嵌入 BAT,再通过以下方式执行:

powershell -NoProfile -ExecutionPolicy Bypass -EncodedCommand %B64%

这种模式在安全领域是典型的“无文件渗透”(Fileless Attack)写法,会触发以下问题:

环境 影响
Windows Defender 可能被标记为可疑脚本
企业 EDR(CrowdStrike / SentinelOne 等) 很可能直接拦截执行
第三方杀毒软件 袋底拦截或隔离
代码审计 内嵌 Base64 不可直接审阅

而项目的目标用户正是“在公司电脑上运行” — 这类环境几乎必然部署了精层安全软件。


复现路径

在安装了 CrowdStrike Falcon 或 Windows Defender ATP 的机器上运行 start.bat,可观察到:

  • 拦截警报:Suspicious encoded PowerShell command
  • 执行被阻止,程序无法启动

修复方案

方案 A:将 PowerShell 脚本改为独立明文文件(推荐)

删除 BAT 中的 Base64 块,改为直接调用独立脚本:

rem 将下载逻辑撤出到 scripts\download-node.ps1
powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%\scripts\download-node.ps1"

scripts/download-node.ps1 为明文 PowerShell,用户可以直接查看和审计其内容。

方案 B:使用 certutilcurl 替代(更少触发)

Windows 10+ 内置 curl.exe,可直接下载:

curl -fsSL -o "%SCRIPT_DIR%\node.zip" "https://npmmirror.com/mirrors/node/v22.16.0/node-v22.16.0-win-x64.zip"
powershell -NoProfile -Command "Expand-Archive -Path '%SCRIPT_DIR%\node.zip' -DestinationPath '%SCRIPT_DIR%\node_tmp' -Force"

这种方式不使用 -EncodedCommand,触发 EDR 的概率显著降低。

方案 C:根本解(配合上面 #40 issue)

如果 Release 包中预置了 node.exe,那么这段下载逻辑就完全不需要了。这是最优解:非必要代码就不展示。


附:如何验证 Base64 内容

如果短期内无法重构,至少应在 README 中添加说明:

## 安全说明
start.bat 中包含内嵌 Base64 编码的 PowerShell 脚本用于下载 Node.js。
如需验证内容,可运行:
python3 -c "import base64; print(base64.b64decode('<B64内容>').decode('utf-16-le'))"

优先级

🔴 P0 - 直接影响项目最核心的目标用户(公司电脑)的可用性。

本 issue 由 AI 代码审阅自动生成,如有疑问欢迎讨论。

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug🐛 Bug - Something isn't workingsecurity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions