mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 19:32:15 +00:00
fix(core): Do not allow arbitrary path traversal in the credential-translation endpoint (#5522)
This commit is contained in:
committed by
GitHub
parent
26a20ed47e
commit
f0f8d59fee
@@ -57,7 +57,6 @@ import history from 'connect-history-api-fallback';
|
||||
import config from '@/config';
|
||||
import * as Queue from '@/Queue';
|
||||
import { InternalHooksManager } from '@/InternalHooksManager';
|
||||
import { getCredentialTranslationPath } from '@/TranslationHelpers';
|
||||
import { getSharedWorkflowIds } from '@/WorkflowHelpers';
|
||||
|
||||
import { nodesController } from '@/api/nodes.api';
|
||||
@@ -88,6 +87,7 @@ import {
|
||||
MeController,
|
||||
OwnerController,
|
||||
PasswordResetController,
|
||||
TranslationController,
|
||||
UsersController,
|
||||
} from '@/controllers';
|
||||
|
||||
@@ -366,6 +366,7 @@ class Server extends AbstractServer {
|
||||
new OwnerController({ config, internalHooks, repositories, logger }),
|
||||
new MeController({ externalHooks, internalHooks, repositories, logger }),
|
||||
new PasswordResetController({ config, externalHooks, internalHooks, repositories, logger }),
|
||||
new TranslationController(config, this.credentialTypes),
|
||||
new UsersController({
|
||||
config,
|
||||
mailer,
|
||||
@@ -606,48 +607,6 @@ class Server extends AbstractServer {
|
||||
),
|
||||
);
|
||||
|
||||
this.app.get(
|
||||
`/${this.restEndpoint}/credential-translation`,
|
||||
ResponseHelper.send(
|
||||
async (
|
||||
req: express.Request & { query: { credentialType: string } },
|
||||
res: express.Response,
|
||||
): Promise<object | null> => {
|
||||
const translationPath = getCredentialTranslationPath({
|
||||
locale: this.frontendSettings.defaultLocale,
|
||||
credentialType: req.query.credentialType,
|
||||
});
|
||||
|
||||
try {
|
||||
return require(translationPath);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// Returns node information based on node names and versions
|
||||
const headersPath = pathJoin(NODES_BASE_DIR, 'dist', 'nodes', 'headers');
|
||||
this.app.get(
|
||||
`/${this.restEndpoint}/node-translation-headers`,
|
||||
ResponseHelper.send(
|
||||
async (req: express.Request, res: express.Response): Promise<object | void> => {
|
||||
try {
|
||||
await fsAccess(`${headersPath}.js`);
|
||||
} catch (_) {
|
||||
return; // no headers available
|
||||
}
|
||||
|
||||
try {
|
||||
return require(headersPath);
|
||||
} catch (error) {
|
||||
res.status(500).send('Failed to load headers file');
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// ----------------------------------------
|
||||
// Node-Types
|
||||
// ----------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user