mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-30 01:06:11 +00:00
fix(security): unify root-bound write hardening
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
} from "../infra/install-mode-options.js";
|
||||
import { installPackageDir } from "../infra/install-package-dir.js";
|
||||
import {
|
||||
assertCanonicalPathWithinBase,
|
||||
resolveSafeInstallDir,
|
||||
safeDirName,
|
||||
unscopedPackageName,
|
||||
@@ -234,6 +235,15 @@ async function installPluginFromPackageDir(params: {
|
||||
return { ok: false, error: targetDirResult.error };
|
||||
}
|
||||
const targetDir = targetDirResult.path;
|
||||
try {
|
||||
await assertCanonicalPathWithinBase({
|
||||
baseDir: extensionsDir,
|
||||
candidatePath: targetDir,
|
||||
boundaryLabel: "extensions directory",
|
||||
});
|
||||
} catch (err) {
|
||||
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
||||
}
|
||||
|
||||
if (mode === "install" && (await fileExists(targetDir))) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user