Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
harden sprite asset-delete guards to compare the confined canonical path
[._.]/ Adam Eivy7a4b4e0d0cc1
diff --git a/server/services/sprites/assets.js b/server/services/sprites/assets.jsindex a73e1d6727..9d2ed70ec0 100644--- a/server/services/sprites/assets.js+++ b/server/services/sprites/assets.js@@ -19,7 +19,7 @@* with an in-flight compile/approve that reads the same version tree.*/-import { join, dirname } from 'path';+import { join, dirname, relative, sep } from 'path';import { rm } from 'fs/promises';import { readJSONFile } from '../../lib/fileUtils.js';import { ServerError } from '../../lib/errorHandler.js';@@ -51,7 +51,12 @@ async function deleteSpriteAssetImpl(recordId, relPath) {if (abs === dir) {throw new ServerError('Refusing to delete the record directory', { status: 400, code: 'INVALID_ASSET_PATH' });}- const normalized = relPath.replace(/\\/g, '/').replace(/^\/+|\/+$/g, '');+ // Derive the record-relative form from the CONFINED absolute path, not by+ // munging the raw input — so the protected-file / live-atlas guards below+ // compare the exact canonical path that will actually be removed. A raw+ // `./runtime/current.json` or `runtime//current.json` resolves to the+ // protected file but wouldn't string-match the guard list otherwise.+ const normalized = relative(dir, abs).split(sep).join('/');if (PROTECTED_STATE.has(normalized)) {throw new ServerError(diff --git a/server/services/sprites/assets.test.js b/server/services/sprites/assets.test.jsindex 1a7a062306..103461bdad 100644--- a/server/services/sprites/assets.test.js+++ b/server/services/sprites/assets.test.js@@ -97,6 +97,12 @@ describe('deleteSpriteAsset', () => {await expect(deleteSpriteAsset(id, rel)).rejects.toMatchObject({ code: 'PROTECTED_STATE_FILE', status: 409 });}+ // Non-canonical spellings that resolve to the same protected file must be+ // refused too — the guard compares the confined path, not the raw input.+ for (const rel of ['./runtime/current.json', 'runtime//current.json']) {+ await expect(deleteSpriteAsset(id, rel))+ .rejects.toMatchObject({ code: 'PROTECTED_STATE_FILE', status: 409 });+ }expect(await exists(join(recDir(id), 'runtime/current.json'))).toBe(true);});