fix(core): Prevent XSS via static cache dir (#10339)

This commit is contained in:
Iván Ovejero
2024-08-09 16:40:50 +02:00
committed by GitHub
parent 1cf48cc301
commit 4f392b5e3e
4 changed files with 25 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ import {
copyInputItems,
ensureType,
getBinaryDataBuffer,
isFilePathBlocked,
parseIncomingMessage,
parseRequestObject,
proxyRequestToAxios,
@@ -34,6 +35,7 @@ import { join } from 'path';
import Container from 'typedi';
import type { Agent } from 'https';
import toPlainObject from 'lodash/toPlainObject';
import { InstanceSettings } from '@/InstanceSettings';
const temporaryDir = mkdtempSync(join(tmpdir(), 'n8n'));
@@ -663,3 +665,11 @@ describe('NodeExecuteFunctions', () => {
});
});
});
describe('isFilePathBlocked', () => {
test('should return true for static cache dir', () => {
const filePath = Container.get(InstanceSettings).staticCacheDir;
expect(isFilePathBlocked(filePath)).toBe(true);
});
});