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
fix(security): refuse playlist uploads at video generation staging
Adam Eivy10bdbd07bc6f
diff --git a/server/routes/videoGen.test.js b/server/routes/videoGen.test.jsindex 9db88cb6c7..8b12f8c565 100644--- a/server/routes/videoGen.test.js+++ b/server/routes/videoGen.test.js@@ -278,6 +278,7 @@ vi.mock('../lib/fileUtils.js', () => ({assertSafeFilename: vi.fn(),copyFileGuarded: fsMock.copyFile,unlinkGuarded: fsMock.unlink,+ assertFileNotMediaManifest: vi.fn(async () => {}),// The route resolves user-supplied basenames through this helper before// handing them to the renderer. Mirror the real helper's basename-strip// + dot-segment rejection so the "strips path-traversal" test belowdiff --git a/server/services/videoGen/prepareParams.js b/server/services/videoGen/prepareParams.jsindex d6e1d53c71..7769a413ce 100644--- a/server/services/videoGen/prepareParams.js+++ b/server/services/videoGen/prepareParams.js@@ -30,7 +30,7 @@ import { existsSync } from 'fs';import { randomUUID } from 'crypto';import { join, extname } from 'path';import { ServerError } from '../../lib/errorHandler.js';-import { PATHS, ensureDir, resolveGalleryImage, copyFileGuarded, unlinkGuarded } from '../../lib/fileUtils.js';+import { PATHS, ensureDir, resolveGalleryImage, copyFileGuarded, unlinkGuarded, assertFileNotMediaManifest } from '../../lib/fileUtils.js';import { probeVideoDuration, safeUnder } from '../../lib/ffmpeg.js';import { RENDER_TARGET } from '../../lib/renderTargets.js';import {@@ -631,6 +631,12 @@ async function resolvePreparedParams({// ServerError on copy failure (and cleans up every staged file + multipart// temp upload so a mid-flight failure doesn't leak under /tmp + data/uploads).const stageUploadDurable = async (file, kind) => {+ // ffmpeg opens a staged file by its bytes, so a playlist posing as audio+ // or an image never reaches the duration probe or the render.+ await assertFileNotMediaManifest(file.path).catch(async (err) => {+ await cleanupStaged();+ throw err;+ });const ext = extname(file.originalname || file.path) || '.bin';const durablePath = join(PATHS.uploads, `video-${kind}-${randomUUID()}${ext}`);try {diff --git a/server/services/videoGen/prepareParams.test.js b/server/services/videoGen/prepareParams.test.jsindex 7b92999de4..154ecfaa25 100644--- a/server/services/videoGen/prepareParams.test.js+++ b/server/services/videoGen/prepareParams.test.js@@ -29,9 +29,10 @@ vi.mock('./local.js', () => ({DEFAULT_NUM_FRAMES: 121,}));-const { unlinkMock, copyFileMock } = vi.hoisted(() => ({+const { unlinkMock, copyFileMock, assertManifestMock } = vi.hoisted(() => ({unlinkMock: vi.fn(async () => {}),copyFileMock: vi.fn(async () => {}),+ assertManifestMock: vi.fn(async () => {}),}));vi.mock('../../lib/fileUtils.js', () => ({@@ -52,6 +53,7 @@ vi.mock('../../lib/fileUtils.js', () => ({}),unlinkGuarded: unlinkMock,copyFileGuarded: copyFileMock,+ assertFileNotMediaManifest: assertManifestMock,}));vi.mock('fs', () => ({ existsSync: vi.fn(() => true) }));@@ -213,6 +215,24 @@ describe('prepareVideoGenParams', () => {expect(posix(prepared.audioFilePath)).toMatch(/^\/mock\/uploads\/video-audio-.*\.wav$/);});+ // The a2v duration probe would otherwise open a playlist posing as audio.+ it('refuses a staged upload whose bytes are a media playlist before copying or probing it', async () => {+ const ltx25 = {+ id: 'ltx25_mlx_q8', name: 'LTX-2.5 MLX Q8', runtime: 'ltx25',+ supportedModes: ['a2v'], audioDurationDriven: true, frameStride: 8, maxNumFrames: 1017,+ };+ listVideoModels.mockReturnValue([ltx25]);+ assertManifestMock.mockRejectedValueOnce(Object.assign(new Error('File content is a hls playlist'), { status: 400, code: 'INVALID_FILE_TYPE' }));++ await expect(prepare(+ { modelId: ltx25.id, mode: 'a2v', fps: 24, numFrames: 121 },+ { audioFile: upload('audioFile', 'song.wav') },+ )).rejects.toMatchObject({ status: 400, code: 'INVALID_FILE_TYPE' });+ expect(assertManifestMock).toHaveBeenCalledWith('/tmp/multipart-audioFile-song.wav');+ expect(copyFileMock).not.toHaveBeenCalledWith('/tmp/multipart-audioFile-song.wav', expect.anything());+ expect(probeVideoDuration).not.toHaveBeenCalled();+ });+it('rejects and cleans up LTX-2.5 audio beyond the single-pass boundary', async () => {const ltx25 = {id: 'ltx25_mlx_q8',