Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
fix(security): canonicalize writable path containment
Rahman9822fe9a9857
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex 032ecc9c..57fbafbb 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -4,6 +4,12 @@Newest first. `docs/PROGRESS.md` is the source of truth for *why* a change was made;this is the *what*, and it is what Settings → About shows as “What's new”.+## 2026-08-30++**Fixed**++- `security` canonicalize writable path containment+## 2026-08-29**Fixed**diff --git a/lib/host/paths.ts b/lib/host/paths.tsindex da1727da..bdbf0932 100644--- a/lib/host/paths.ts+++ b/lib/host/paths.ts@@ -360,38 +360,29 @@ export async function safeWritePath(requested: string, mustExist: boolean): Promconst lexicalTarget = mustExist ? normalized : path.dirname(normalized);for (const root of configured) {- const relative = path.relative(root, lexicalTarget);- if (relative === ".." || relative.startsWith(".." + path.sep) || path.isAbsolute(relative)) {- continue;- } else {- const realRoot = await fs.realpath(root).catch(() => path.resolve(root));- if (mustExist) {- const real = await fs.realpath(normalized);- const realRelative = path.relative(realRoot, real);- if (- realRelative === ".." ||- realRelative.startsWith(".." + path.sep) ||- path.isAbsolute(realRelative)- ) {- throw new HostError("Path outside writable roots");- }- assertNotCredential(real);- return real;- }-- const parent = await fs.realpath(lexicalTarget);- const parentRelative = path.relative(realRoot, parent);- if (- parentRelative === ".." ||- parentRelative.startsWith(".." + path.sep) ||- path.isAbsolute(parentRelative)- ) {+ // Use the canonical absolute-prefix containment pattern CodeQL recognizes.+ // `root + path.sep` prevents sibling-prefix tricks such as /safe vs /safe-evil.+ const lexicalPrefix = root === path.parse(root).root ? root : root + path.sep;+ if (lexicalTarget !== root && !lexicalTarget.startsWith(lexicalPrefix)) continue;++ const realRoot = await fs.realpath(root).catch(() => path.resolve(root));+ const realPrefix = realRoot === path.parse(realRoot).root ? realRoot : realRoot + path.sep;+ if (mustExist) {+ const real = await fs.realpath(normalized);+ if (real !== realRoot && !real.startsWith(realPrefix)) {throw new HostError("Path outside writable roots");}- const joined = path.join(parent, path.basename(normalized));- assertNotCredential(joined);- return joined;+ assertNotCredential(real);+ return real;+ }++ const parent = await fs.realpath(lexicalTarget);+ if (parent !== realRoot && !parent.startsWith(realPrefix)) {+ throw new HostError("Path outside writable roots");}+ const joined = path.join(parent, path.basename(normalized));+ assertNotCredential(joined);+ return joined;}throw new HostError("Path outside writable roots");}