mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 21:58:26 +00:00
fix(security): restrict skill download target paths
This commit is contained in:
@@ -5,6 +5,7 @@ import path from "node:path";
|
||||
import { Readable, Transform } from "node:stream";
|
||||
import { pipeline } from "node:stream/promises";
|
||||
import * as tar from "tar";
|
||||
import { resolveSafeBaseDir } from "./path-safety.js";
|
||||
|
||||
export type ArchiveKind = "tar" | "zip";
|
||||
|
||||
@@ -101,11 +102,6 @@ export async function withTimeout<T>(
|
||||
}
|
||||
}
|
||||
|
||||
function resolveSafeBaseDir(destDir: string): string {
|
||||
const resolved = path.resolve(destDir);
|
||||
return resolved.endsWith(path.sep) ? resolved : `${resolved}${path.sep}`;
|
||||
}
|
||||
|
||||
// Path hygiene.
|
||||
function normalizeArchivePath(raw: string): string {
|
||||
// Archives may contain Windows separators; treat them as separators.
|
||||
|
||||
Reference in New Issue
Block a user