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
address review (ollama): reject literal '..' the asset-charset anchor admitted
[._.]/ Adam Eivy0b9b7f04af5f
diff --git a/server/services/chatgptImport.js b/server/services/chatgptImport.jsindex 934e1453a6..f05cf430a6 100644--- a/server/services/chatgptImport.js+++ b/server/services/chatgptImport.js@@ -337,12 +337,14 @@ export const extractAssetFileNames = (content) => {while ((m = re.exec(content)) !== null) {const name = m[1].replace(/[).,]+$/, '');// Served asset names are `<assetId><ext>` (see chatgptZipImport.js) and are- // flat in practice. This regex is the actual safety boundary regardless of- // how the producer names files: a strict superset of the path-traversal- // guard, it rejects `/`, `\`, `..`, null bytes, and stray- // query-string/punctuation tails that can never name a real on-disk asset —- // so a crafted link can't produce a name we'd hand to unlink().- if (/^[a-zA-Z0-9._-]+$/.test(name)) {+ // flat in practice. These guards are the actual safety boundary regardless+ // of how the producer names files: the charset anchor rejects `/`, `\`,+ // null bytes, and stray query-string/punctuation tails, and the explicit+ // `..` reject keeps it a strict superset of the prior path-traversal guard+ // (the charset alone would admit a literal `..`, which `join` resolves to+ // the parent dir). Together a crafted link can't produce a name we'd hand+ // to unlink() that escapes — or names — the assets dir.+ if (/^[a-zA-Z0-9._-]+$/.test(name) && !name.includes('..')) {names.add(name);}}diff --git a/server/services/chatgptImport.test.js b/server/services/chatgptImport.test.jsindex cdd329150e..8d3af8e150 100644--- a/server/services/chatgptImport.test.js+++ b/server/services/chatgptImport.test.js@@ -310,6 +310,18 @@ describe('chatgptImport service', () => {expect([...extractAssetFileNames(content)]).toEqual(['file-ok2.png']);});+ it('rejects a literal `..` name the charset alone would admit (join → parent dir)', () => {+ // The flat charset includes `.`, so `..` / `a..b` match it — but `..`+ // resolves to the parent dir under join(). The explicit `..` reject keeps+ // the guard a true superset of the prior path-traversal check.+ const content = [+ '',+ '',+ '',+ ].join('\n');+ expect([...extractAssetFileNames(content)]).toEqual(['file-ok3.png']);+ });+it('returns an empty set for non-string / asset-free content', () => {expect(extractAssetFileNames(null).size).toBe(0);expect(extractAssetFileNames('plain memory text').size).toBe(0);