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

fix: refuse a symlinked MTPLX models or Pixie Forge loras directory (#10134)

Adam Eivy7889c1f4393d
diff --git a/server/routes/imageVideoModels.store.test.js b/server/routes/imageVideoModels.store.test.js
index e0aac1bb79..74315dab60 100644
--- a/server/routes/imageVideoModels.store.test.js
+++ b/server/routes/imageVideoModels.store.test.js
@@ -92,6 +92,16 @@ describe('file-system model stores', () => {
expect(await exists(join(outside, 'precious.bin'))).toBe(true);
});
+ it('ignores a models directory that is a symlink out of the store', async () => {
+ const outside = join(root, 'outside');
+ await fill(join(outside, 'org--external', 'w.bin'), 10);
+ await mkdir(join(root, 'mtplx'), { recursive: true });
+ await symlink(outside, join(root, 'mtplx', 'models'));
+ expect((await listModelStore('mtplx')).items).toEqual([]);
+ expect((await request(app).delete('/api/image-video/models/store/mtplx/org--external')).status).toBe(404);
+ expect(await exists(join(outside, 'org--external'))).toBe(true);
+ });
+
it('clears xet chunk caches and only logs older than 7 days', async () => {
await fill(join(root, 'xet', 'abc', 'chunk_cache', 'c.bin'), 100);
await fill(join(root, 'xet', 'logs', 'old.log'), 40);
diff --git a/server/services/modelStoreStorage.js b/server/services/modelStoreStorage.js
index ee5006af1a..e37bc92810 100644
--- a/server/services/modelStoreStorage.js
+++ b/server/services/modelStoreStorage.js
@@ -66,7 +66,7 @@ async function scanMtplx() {
const root = getMtplxRoot();
const modelsDir = join(root, 'models');
const items = [];
- for (const dirName of await subdirs(modelsDir)) {
+ for (const dirName of await isRealDirectory(modelsDir) ? await subdirs(modelsDir) : []) {
// Checkpoints are `<org>--<name>`; the key space is shared with the session
// bank, so a directory that would collide with it is not a checkpoint.
if (dirName === SESSION_BANK) continue;
@@ -159,7 +159,7 @@ async function scanXetCache({ now = Date.now() } = {}) {
async function scanPixieForge() {
const root = join(getPixieForgeRoot(), 'loras');
const items = [];
- for (const entry of await readEntries(root)) {
+ for (const entry of await isRealDirectory(root) ? await readEntries(root) : []) {
if (!entry.isFile() || !entry.name.endsWith('.safetensors')) continue;
const path = join(root, entry.name);
items.push(item({