mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 13:44:58 +00:00
fix(sandbox): block @-prefixed workspace path bypass
This commit is contained in:
@@ -227,7 +227,13 @@ function isPathInsidePosix(root: string, target: string): boolean {
|
||||
|
||||
function isPathInsideHost(root: string, target: string): boolean {
|
||||
const canonicalRoot = resolveSandboxHostPathViaExistingAncestor(path.resolve(root));
|
||||
const canonicalTarget = resolveSandboxHostPathViaExistingAncestor(path.resolve(target));
|
||||
const resolvedTarget = path.resolve(target);
|
||||
// Preserve the final path segment so pre-existing symlink leaves are validated
|
||||
// by the dedicated symlink guard later in the bridge flow.
|
||||
const canonicalTargetParent = resolveSandboxHostPathViaExistingAncestor(
|
||||
path.dirname(resolvedTarget),
|
||||
);
|
||||
const canonicalTarget = path.resolve(canonicalTargetParent, path.basename(resolvedTarget));
|
||||
const rel = path.relative(canonicalRoot, canonicalTarget);
|
||||
if (!rel) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user