Skip to content

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

address review: sanitize audioFilePath at the queue→gen boundary

Adam Eivye4d2ed00be79
diff --git a/server/routes/videoGen.test.js b/server/routes/videoGen.test.js
index f44f5b9733..4a90e24125 100644
--- a/server/routes/videoGen.test.js
+++ b/server/routes/videoGen.test.js
@@ -86,6 +86,9 @@ describe('videoGen routes', () => {
app.use(express.json());
app.use('/api/video-gen', videoGenRoutes);
vi.clearAllMocks();
+ // Reset the upload holder so a test that set a pending upload but
+ // bailed before the route consumed it can't leak into the next test.
+ pendingUpload.current = null;
});
describe('GET /status', () => {
diff --git a/server/services/mediaJobQueue/index.js b/server/services/mediaJobQueue/index.js
index 1bc56f9089..d79e73934f 100644
--- a/server/services/mediaJobQueue/index.js
+++ b/server/services/mediaJobQueue/index.js
@@ -518,6 +518,14 @@ async function runJob(job) {
console.log(`⚠️ media-job [${job.id.slice(0, 8)}] uploadedTempPath outside PATHS.uploads — nulled before gen invoke: ${safeParams.uploadedTempPath}`);
safeParams.uploadedTempPath = null;
}
+ // a2v: audioFilePath is fed straight to the python helper as --audio, so
+ // a corrupted/hand-edited persisted job that points it at /etc/secrets
+ // could make the worker open arbitrary local files. Same constraint as
+ // uploadedTempPath — null it if it doesn't resolve under PATHS.uploads.
+ if (safeParams.audioFilePath && (typeof safeParams.audioFilePath !== 'string' || !isUnderUploadsRoot(safeParams.audioFilePath))) {
+ console.log(`⚠️ media-job [${job.id.slice(0, 8)}] audioFilePath outside PATHS.uploads — nulled before gen invoke: ${safeParams.audioFilePath}`);
+ safeParams.audioFilePath = null;
+ }
if (Array.isArray(safeParams.uploadedTempPaths)) {
const filtered = safeParams.uploadedTempPaths.filter((p) => {
if (typeof p === 'string' && isUnderUploadsRoot(p)) return true;
diff --git a/server/services/mediaJobQueue/index.test.js b/server/services/mediaJobQueue/index.test.js
index 2982294d27..67eb743680 100644
--- a/server/services/mediaJobQueue/index.test.js
+++ b/server/services/mediaJobQueue/index.test.js
@@ -255,6 +255,23 @@ describe('mediaJobQueue', () => {
await waitFor(() => mediaJobQueue.getJob(job.jobId).status === 'completed');
});
+ it('pre-gen sanitizer nulls audioFilePath that resolves outside PATHS.uploads', async () => {
+ // a2v: audioFilePath flows directly into the python helper as --audio.
+ // A hand-edited persisted job pointing it at /etc/secrets would otherwise
+ // make the worker open arbitrary local files; the same uploads-root
+ // guard applied to uploadedTempPath must apply here too.
+ const job = mediaJobQueue.enqueueJob({
+ kind: 'video',
+ params: { prompt: 'beats', mode: 'a2v', audioFilePath: '/etc/passwd' },
+ });
+ await waitFor(() => stubs.generateVideo.mock.calls.length === 1);
+ const callArgs = stubs.generateVideo.mock.calls[0][0];
+ expect(callArgs.audioFilePath).toBeNull();
+
+ videoGenEvents.emit('completed', { generationId: job.jobId, filename: `${job.jobId}.mp4` });
+ await waitFor(() => mediaJobQueue.getJob(job.jobId).status === 'completed');
+ });
+
it('watchdog fires and marks the job failed when gen never emits a terminal event', async () => {
// Use a very short watchdog for this test by overriding the env var before
// the module is loaded. Re-import the module with MEDIA_JOB_WATCHDOG_VIDEO_MS=50.