mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 13:44:58 +00:00
fix(security): unify root-bound write hardening
This commit is contained in:
@@ -170,6 +170,11 @@ class SandboxFsBridgeImpl implements SandboxFsBridge {
|
||||
Boolean,
|
||||
);
|
||||
const rmCommand = flags.length > 0 ? `rm ${flags.join(" ")}` : "rm";
|
||||
await this.assertPathSafety(target, {
|
||||
action: "remove files",
|
||||
requireWritable: true,
|
||||
aliasPolicy: PATH_ALIAS_POLICIES.unlinkTarget,
|
||||
});
|
||||
await this.runCommand(`set -eu; ${rmCommand} -- "$1"`, {
|
||||
args: [target.containerPath],
|
||||
signal: params.signal,
|
||||
@@ -195,6 +200,15 @@ class SandboxFsBridgeImpl implements SandboxFsBridge {
|
||||
action: "rename files",
|
||||
requireWritable: true,
|
||||
});
|
||||
await this.assertPathSafety(from, {
|
||||
action: "rename files",
|
||||
requireWritable: true,
|
||||
aliasPolicy: PATH_ALIAS_POLICIES.unlinkTarget,
|
||||
});
|
||||
await this.assertPathSafety(to, {
|
||||
action: "rename files",
|
||||
requireWritable: true,
|
||||
});
|
||||
await this.runCommand(
|
||||
'set -eu; dir=$(dirname -- "$2"); if [ "$dir" != "." ]; then mkdir -p -- "$dir"; fi; mv -- "$1" "$2"',
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user