Skip to content

Commit 9fbe838

Browse files
Revert "fix(secrets): trust node plugin provider command"
This reverts commit 2e3af824b7a9379a9b952ebc69528b1fac7a6419.
1 parent 5f73ded commit 9fbe838

2 files changed

Lines changed: 8 additions & 22 deletions

File tree

‎src/secrets/provider-integrations.test.ts‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ afterEach(() => {
6767
describe("secret provider integration presets", () => {
6868
it("materializes plugin manifest exec providers without provider-specific core code", () => {
6969
const rootDir = makeTempDir();
70-
const nodePath = fs.realpathSync(process.execPath);
7170
fs.writeFileSync(path.join(rootDir, "index.ts"), "export default {};\n", "utf8");
7271
makeSecureDir(path.join(rootDir, "bin"));
7372
writeSecureFile(path.join(rootDir, "bin", "resolve.mjs"), "process.stdin.resume();\n");
@@ -128,7 +127,7 @@ describe("secret provider integration presets", () => {
128127
ok: true,
129128
providerConfig: {
130129
source: "exec",
131-
command: nodePath,
130+
command: process.execPath,
132131
args: [fs.realpathSync(path.join(rootDir, "bin", "resolve.mjs")), "--profile", "work"],
133132
timeoutMs: 3000,
134133
noOutputTimeoutMs: 3000,
@@ -137,16 +136,14 @@ describe("secret provider integration presets", () => {
137136
env: {
138137
ACME_PROFILE: "work",
139138
},
140-
trustedDirs: [path.dirname(nodePath), rootDir],
141-
allowInsecurePath: true,
139+
trustedDirs: [path.dirname(process.execPath), rootDir],
142140
jsonOnly: false,
143141
},
144142
});
145143
});
146144

147145
it("normalizes manifest exec provider options to SecretRef provider schema limits", () => {
148146
const rootDir = makeTempDir();
149-
const nodePath = fs.realpathSync(process.execPath);
150147
fs.writeFileSync(path.join(rootDir, "index.ts"), "export default {};\n", "utf8");
151148
writeSecureFile(path.join(rootDir, "resolve.mjs"), "process.stdin.resume();\n");
152149
fs.writeFileSync(
@@ -196,11 +193,10 @@ describe("secret provider integration presets", () => {
196193
ok: true,
197194
providerConfig: {
198195
source: "exec",
199-
command: nodePath,
196+
command: process.execPath,
200197
args: [fs.realpathSync(path.join(rootDir, "resolve.mjs")), "ok"],
201-
trustedDirs: [path.dirname(nodePath), rootDir],
198+
trustedDirs: [path.dirname(process.execPath), rootDir],
202199
passEnv: ["GOOD_ENV"],
203-
allowInsecurePath: true,
204200
},
205201
});
206202
});
@@ -569,7 +565,6 @@ describe("secret provider integration presets", () => {
569565
"});",
570566
].join("\n"),
571567
);
572-
fs.chmodSync(resolverPath, 0o600);
573568
fs.writeFileSync(
574569
path.join(rootDir, "openclaw.plugin.json"),
575570
JSON.stringify({

‎src/secrets/provider-integrations.ts‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,11 @@ function resolveArg(arg: string, pluginRoot: string): string | undefined {
6262
return resolvePluginRelativePath(arg, pluginRoot);
6363
}
6464

65-
function withNodeCommandTrustedDir(
66-
command: string,
67-
pluginRoot: string,
68-
nodeCommand: string,
69-
): string[] {
65+
function withNodeCommandTrustedDir(command: string, pluginRoot: string): string[] {
7066
// The ${node} placeholder executes the current Node binary with a plugin-owned entrypoint.
7167
// Trust both the Node binary dir and plugin root so resolver path checks accept that shape.
7268
return command === NODE_COMMAND_PLACEHOLDER
73-
? [...new Set([path.dirname(nodeCommand), pluginRoot])]
69+
? [...new Set([path.dirname(process.execPath), pluginRoot])]
7470
: [pluginRoot];
7571
}
7672

@@ -235,11 +231,10 @@ function materializeExecProviderConfig(
235231
if (integration.args && args?.length !== integration.args.length) {
236232
return undefined;
237233
}
238-
const nodeCommand = fs.realpathSync(process.execPath);
239-
const trustedDirs = withNodeCommandTrustedDir(integration.command, pluginRoot, nodeCommand);
234+
const trustedDirs = withNodeCommandTrustedDir(integration.command, pluginRoot);
240235
return {
241236
source: "exec",
242-
command: nodeCommand,
237+
command: process.execPath,
243238
...(args ? { args } : {}),
244239
...(integration.timeoutMs !== undefined ? { timeoutMs: integration.timeoutMs } : {}),
245240
...(integration.noOutputTimeoutMs !== undefined
@@ -251,10 +246,6 @@ function materializeExecProviderConfig(
251246
...(integration.jsonOnly === false ? { jsonOnly: false } : {}),
252247
...(integration.env ? { env: integration.env } : {}),
253248
...(integration.passEnv ? { passEnv: integration.passEnv } : {}),
254-
// `${node}` is the current trusted runtime plus a separately validated plugin entrypoint.
255-
// Hosted toolchains can have group-writable Node installs, so the command path itself
256-
// cannot satisfy the generic user-owned executable policy.
257-
allowInsecurePath: true,
258249
trustedDirs,
259250
};
260251
}

0 commit comments

Comments
 (0)