mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-30 02:22:25 +00:00
fix(security): bind system.run approvals to argv identity
This commit is contained in:
@@ -8,6 +8,7 @@ import { callGatewayTool } from "./tools/gateway.js";
|
||||
export type RequestExecApprovalDecisionParams = {
|
||||
id: string;
|
||||
command: string;
|
||||
commandArgv?: string[];
|
||||
cwd: string;
|
||||
nodeId?: string;
|
||||
host: "gateway" | "node";
|
||||
@@ -62,6 +63,7 @@ export async function registerExecApprovalRequest(
|
||||
{
|
||||
id: params.id,
|
||||
command: params.command,
|
||||
commandArgv: params.commandArgv,
|
||||
cwd: params.cwd,
|
||||
nodeId: params.nodeId,
|
||||
host: params.host,
|
||||
@@ -116,6 +118,7 @@ export async function requestExecApprovalDecision(
|
||||
export async function requestExecApprovalDecisionForHost(params: {
|
||||
approvalId: string;
|
||||
command: string;
|
||||
commandArgv?: string[];
|
||||
workdir: string;
|
||||
host: "gateway" | "node";
|
||||
nodeId?: string;
|
||||
@@ -128,6 +131,7 @@ export async function requestExecApprovalDecisionForHost(params: {
|
||||
return await requestExecApprovalDecision({
|
||||
id: params.approvalId,
|
||||
command: params.command,
|
||||
commandArgv: params.commandArgv,
|
||||
cwd: params.workdir,
|
||||
nodeId: params.nodeId,
|
||||
host: params.host,
|
||||
@@ -142,6 +146,7 @@ export async function requestExecApprovalDecisionForHost(params: {
|
||||
export async function registerExecApprovalRequestForHost(params: {
|
||||
approvalId: string;
|
||||
command: string;
|
||||
commandArgv?: string[];
|
||||
workdir: string;
|
||||
host: "gateway" | "node";
|
||||
nodeId?: string;
|
||||
@@ -154,6 +159,7 @@ export async function registerExecApprovalRequestForHost(params: {
|
||||
return await registerExecApprovalRequest({
|
||||
id: params.approvalId,
|
||||
command: params.command,
|
||||
commandArgv: params.commandArgv,
|
||||
cwd: params.workdir,
|
||||
nodeId: params.nodeId,
|
||||
host: params.host,
|
||||
|
||||
@@ -194,6 +194,7 @@ export async function executeNodeHostCommand(
|
||||
const registration = await registerExecApprovalRequestForHost({
|
||||
approvalId,
|
||||
command: params.command,
|
||||
commandArgv: argv,
|
||||
workdir: params.workdir,
|
||||
host: "node",
|
||||
nodeId,
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
} from "../../cli/nodes-screen.js";
|
||||
import { parseDurationMs } from "../../cli/parse-duration.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { formatExecCommand } from "../../infra/system-run-command.js";
|
||||
import { imageMimeFromFormat } from "../../media/mime.js";
|
||||
import { resolveSessionAgentId } from "../agent-scope.js";
|
||||
import { resolveImageSanitizationLimits } from "../image-sanitization.js";
|
||||
@@ -473,7 +474,7 @@ export function createNodesTool(options?: {
|
||||
// Node requires approval – create a pending approval request on
|
||||
// the gateway and wait for the user to approve/deny via the UI.
|
||||
const APPROVAL_TIMEOUT_MS = 120_000;
|
||||
const cmdText = command.join(" ");
|
||||
const cmdText = formatExecCommand(command);
|
||||
const approvalId = crypto.randomUUID();
|
||||
const approvalResult = await callGatewayTool(
|
||||
"exec.approval.request",
|
||||
@@ -481,6 +482,7 @@ export function createNodesTool(options?: {
|
||||
{
|
||||
id: approvalId,
|
||||
command: cmdText,
|
||||
commandArgv: command,
|
||||
cwd,
|
||||
nodeId,
|
||||
host: "node",
|
||||
|
||||
Reference in New Issue
Block a user