惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Blog — PlanetScale
Blog — PlanetScale
小众软件
小众软件
F
Fortinet All Blogs
博客园 - 叶小钗
博客园_首页
D
DataBreaches.Net
Apple Machine Learning Research
Apple Machine Learning Research
U
Unit 42
爱范儿
爱范儿
aimingoo的专栏
aimingoo的专栏
博客园 - Franky
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
The Cloudflare Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
IT之家
IT之家
M
MIT News - Artificial intelligence
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(security): block npm_execpath injection from workspac...
pgondhi987 · 2026-04-28 · via Recent Commits to openclaw:main

@@ -105,18 +105,24 @@ afterEach(() => {

105105

});

106106107107

describe("resolveBundledRuntimeDepsNpmRunner", () => {

108-

it("uses npm_execpath through node on Windows when available", () => {

108+

it("ignores npm_execpath and uses the Node-adjacent npm CLI on Windows", () => {

109+

const execPath = "C:\\Program Files\\nodejs\\node.exe";

110+

const npmCliPath = path.win32.resolve(

111+

path.win32.dirname(execPath),

112+

"node_modules/npm/bin/npm-cli.js",

113+

);

109114

const runner = resolveBundledRuntimeDepsNpmRunner({

110-

env: { npm_execpath: "C:\\node\\node_modules\\npm\\bin\\npm-cli.js" },

111-

execPath: "C:\\Program Files\\nodejs\\node.exe",

112-

existsSync: (candidate) => candidate === "C:\\node\\node_modules\\npm\\bin\\npm-cli.js",

115+

env: { npm_execpath: "C:\\repo\\evil\\npm-cli.js" },

116+

execPath,

117+

existsSync: (candidate) =>

118+

candidate === "C:\\repo\\evil\\npm-cli.js" || candidate === npmCliPath,

113119

npmArgs: ["install", "acpx@0.5.3"],

114120

platform: "win32",

115121

});

116122117123

expect(runner).toEqual({

118-

command: "C:\\Program Files\\nodejs\\node.exe",

119-

args: ["C:\\node\\node_modules\\npm\\bin\\npm-cli.js", "install", "acpx@0.5.3"],

124+

command: execPath,

125+

args: [npmCliPath, "install", "acpx@0.5.3"],

120126

});

121127

});

122128

@@ -139,6 +145,8 @@ describe("resolveBundledRuntimeDepsNpmRunner", () => {

139145

npm_config_global: "true",

140146

npm_config_location: "global",

141147

npm_config_prefix: "/opt/homebrew",

148+

npm_execpath: "/repo/evil/npm-cli.js",

149+

NPM_EXECPATH: "/repo/evil-uppercase/npm-cli.js",

142150

},

143151

{ cacheDir: "/opt/openclaw/runtime-cache" },

144152

),

@@ -175,15 +183,16 @@ describe("resolveBundledRuntimeDepsNpmRunner", () => {

175183

});

176184

});

177185178-

it("ignores pnpm npm_execpath and falls back to npm", () => {

186+

it("ignores npm_execpath and falls back to Node-adjacent npm", () => {

179187

const execPath = "/opt/node/bin/node";

180188

const npmCliPath = "/opt/node/lib/node_modules/npm/bin/npm-cli.js";

181189

const runner = resolveBundledRuntimeDepsNpmRunner({

182190

env: {

183-

npm_execpath: "/home/runner/setup-pnpm/node_modules/.bin/pnpm.cjs",

191+

npm_execpath: "/home/runner/repo/evil/npm-cli.js",

184192

},

185193

execPath,

186-

existsSync: (candidate) => candidate === npmCliPath,

194+

existsSync: (candidate) =>

195+

candidate === "/home/runner/repo/evil/npm-cli.js" || candidate === npmCliPath,

187196

npmArgs: ["install", "acpx@0.5.3"],

188197

platform: "linux",

189198

});

@@ -206,24 +215,18 @@ describe("resolveBundledRuntimeDepsNpmRunner", () => {

206215

).toThrow("Unable to resolve a safe npm executable on Windows");

207216

});

208217209-

it("prefixes PATH with the active Node directory on POSIX", () => {

210-

const runner = resolveBundledRuntimeDepsNpmRunner({

211-

env: {

212-

PATH: "/usr/bin:/bin",

213-

},

214-

execPath: "/opt/node/bin/node",

215-

existsSync: () => false,

216-

npmArgs: ["install", "acpx@0.5.3"],

217-

platform: "linux",

218-

});

219-220-

expect(runner).toEqual({

221-

command: "npm",

222-

args: ["install", "acpx@0.5.3"],

223-

env: {

224-

PATH: `/opt/node/bin${path.delimiter}/usr/bin:/bin`,

225-

},

226-

});

218+

it("refuses POSIX npm shim fallback when npm-cli.js is unavailable", () => {

219+

expect(() =>

220+

resolveBundledRuntimeDepsNpmRunner({

221+

env: {

222+

PATH: "/repo/evil/bin:/usr/bin:/bin",

223+

},

224+

execPath: "/opt/node/bin/node",

225+

existsSync: (candidate) => candidate === "/opt/node/bin/npm",

226+

npmArgs: ["install"],

227+

platform: "linux",

228+

}),

229+

).toThrow("Unable to resolve a safe npm executable");

227230

});

228231

});

229232

@@ -287,11 +290,16 @@ describe("installBundledRuntimeDeps", () => {

287290

);

288291

});

289292290-

it("uses the npm cmd shim on Windows", () => {

293+

it("ignores npm_execpath during Windows installs", () => {

291294

const installRoot = makeTempDir();

292295

vi.spyOn(process, "platform", "get").mockReturnValue("win32");

296+

const safeNpmCliPath = path.win32.resolve(

297+

path.win32.dirname(process.execPath),

298+

"node_modules/npm/bin/npm-cli.js",

299+

);

300+

const attackerNpmCliPath = "C:\\repo\\evil\\npm-cli.js";

293301

vi.spyOn(fs, "existsSync").mockImplementation(

294-

(candidate) => candidate === "C:\\node\\node_modules\\npm\\bin\\npm-cli.js",

302+

(candidate) => candidate === attackerNpmCliPath || candidate === safeNpmCliPath,

295303

);

296304

spawnSyncMock.mockImplementation((_command, _args, options) => {

297305

writeInstalledPackage(String(options?.cwd ?? ""), "acpx", "0.5.3");

@@ -311,13 +319,13 @@ describe("installBundledRuntimeDeps", () => {

311319

env: {

312320

npm_config_prefix: "C:\\prefix",

313321

PATH: "C:\\node",

314-

npm_execpath: "C:\\node\\node_modules\\npm\\bin\\npm-cli.js",

322+

npm_execpath: attackerNpmCliPath,

315323

},

316324

});

317325318326

expect(spawnSyncMock).toHaveBeenCalledWith(

319327

expect.any(String),

320-

["C:\\node\\node_modules\\npm\\bin\\npm-cli.js", "install", "--ignore-scripts", "acpx@0.5.3"],

328+

[safeNpmCliPath, "install", "--ignore-scripts", "acpx@0.5.3"],

321329

expect.objectContaining({

322330

cwd: installRoot,

323331

windowsHide: true,

@@ -338,6 +346,15 @@ describe("installBundledRuntimeDeps", () => {

338346

}),

339347

}),

340348

);

349+

expect(spawnSyncMock).toHaveBeenCalledWith(

350+

expect.any(String),

351+

expect.any(Array),

352+

expect.objectContaining({

353+

env: expect.not.objectContaining({

354+

npm_execpath: expect.any(String),

355+

}),

356+

}),

357+

);

341358

});

342359343360

it("hides async npm child windows for startup repair installs", async () => {