审计工具可安装并随后执行缺失的 npm 依赖
原文依据:4 处当 HyperFrames 包无法解析时,加载器会确认后调用 npm 安装,并动态导入解析到的模块。即使安装禁用了生命周期脚本,导入依赖仍会执行其顶层 JavaScript。
受损、被劫持或错误版本的依赖可在运行审计工具的用户权限下读取可访问文件、使用环境凭据或修改文件。
这是实际加载路径:缺少包时会校验规格、请求确认并调用 npm 引导安装;随后解析到的模块通过动态 import 加载。禁用安装脚本只能阻止 npm 生命周期钩子,不能阻止被导入包的顶层 JavaScript。风险仅在依赖缺失且用户确认或启用显式自动确认时出现。用户可限制网络、预装并锁定已审查版本,或要求作者公布完整引导实现。
if (missing.length > 0 && !process.env[BOOTSTRAP_ENV]) { const npmPackages = options.npmPackages ?? missing; assertPinnedPackageSpecs(npmPackages); await confirmBootstrap(npmPackages); bootstrapWithNpmInstall(npmPackages); }查看另外 3 个位置
const modules = {}; for (const [packageName, entry] of entries) { modules[packageName] = await import(pathToFileURL(entry).href); } return modules;const packages = await importPackagesOrBootstrap( ["@hyperframes/producer", "@hyperframes/core", "@hyperframes/core/compiler"], { npmPackages: [ hyperframesPackageSpec("@hyperframes/producer"), hyperframesPackageSpec("@hyperframes/core"), ], },);const { createFileServer, createCaptureSession, closeCaptureSession, getCompositionDuration } =// • specs are version-pinned (assertPinnedPackageSpecs) — no floating "latest"// • install runs `npm install --ignore-scripts` — package lifecycle scripts// never execute// • `--no-save` into a throwaway tmp dir — the host project is left untouched// • requires an interactive y/N (or an explicit $HYPERFRAMES_SKILL_BOOTSTRAP_DEPS=1)// • npm is spawned with an argv array (no shell) — never a built command string// The `installLine` strings below are DISPLAY ONLY (shown in the prompt / error