//nefariousplan

CVE-2026-38426: Tasmota's Scripter Calls strlcpy Fifty-Seven Times. The Line That Read From The Network Used strcpy.

pattern

cve

proof of concept

tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino is a single file with 57 calls to strlcpy and 29 calls to strcpy. The author reached for the bounded copy fifty-seven times. CVE-2026-38426 is the line where they reached for strcpy instead, on a 40-byte destination buffer adjacent to two C++ network objects, with the source supplied by an HTTP server reachable across the wire.

The bug is one line. The patch is the same line.

fetch_jpg() is the function the scripter calls when a user script invokes jpg(0, "host/stream", x, y, scale) to pull an MJPEG feed onto a display. Selector 0 opens the connection. The first thing it does after the GET is read back the server's Content-Type header to learn the multipart boundary:

// tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino, fetch_jpg() case 0
String boundary = glob_script_mem.jpg_task.http.header(headerKeys[0]);
char *cp = strchr(boundary.c_str(), '=');
if (cp) {
  strcpy(glob_script_mem.jpg_task.boundary, cp + 1);  // pre-patch
}

headerKeys[0] is "Content-Type". The server sends, for example, multipart/x-mixed-replace; boundary=frame. strchr finds the =. Everything after it goes into glob_script_mem.jpg_task.boundary, declared as:

struct JPG_TASK {
  char boundary[40];
  bool draw;
  uint8_t scale;
  uint16_t xp;
  uint16_t yp;
  WiFiClient stream;
  HTTPClient http;
} jpg_task;

Forty bytes for the boundary, with the live WiFiClient and HTTPClient instances seven bytes downstream after struct alignment. strcpy does not know any of this. It copies until it hits a NUL.

The patch, May 16 2026, commit 5009bea:

-          strcpy(glob_script_mem.jpg_task.boundary,cp + 1);
+          strlcpy(glob_script_mem.jpg_task.boundary, cp + 1, sizeof(glob_script_mem.jpg_task.boundary));

One line. The fix is correct. There is nothing more to say about the line.

The struct after the buffer is the exploit primitive

WiFiClient and HTTPClient are Arduino classes; their instances carry vtable pointers as their first machine word. The vtable pointer of glob_script_mem.jpg_task.stream sits in the same global SCRIPT_MEM block, past boundary, past draw, past scale, past xp, past yp. The overflow path crosses that distance with attacker-supplied bytes.

What makes the bytes attacker-supplied: the entire suffix of Content-Type after = is taken verbatim. The HTTP server controls header values. There is no length cap on Content-Type at the HTTPClient layer. The boundary value can be a kilobyte; strcpy will copy a kilobyte.

What makes the overwrite reachable: after fetch_jpg(0, ...) returns, the script keeps the connection open and calls back into fetch_jpg() with selector 2 to pull each frame. Selector 2 invokes glob_script_mem.jpg_task.http.connected(), then reads from glob_script_mem.jpg_task.stream repeatedly. Both calls dispatch through the vtable pointers the overflow just rewrote. The first virtual call after the corrupted return from selector 0 is the call into attacker-controlled bytes interpreted as a function pointer.

The PoC's --mode rce writes 0x41414141 into that slot. That is not RCE; it is a controlled fault address on ESP32. The vector lands, the device reboots with Guru Meditation Error, and the attacker has demonstrated reach. Closing the gap to actual code execution requires picking real Xtensa addresses for a target firmware build and threading the vtable to land in attacker-staged bytes elsewhere in memory. The PoC's README claims CVSS 9.8 Critical and labels its crash and info modes as RCE primitives. NVD assigned 7.3 with L/L/L impact and is more honest about what the artifact actually demonstrates.

The same commit fixed two things. The message named one.

The patch commit's title is Fix scripter buffer overflow, singular. The diff has two hunks:

@@ -2770,7 +2770,7 @@ int32_t fetch_jpg(uint32_t sel, char *url, uint32_t xp, uint32_t yp, uint32_t sc
         String boundary = glob_script_mem.jpg_task.http.header(headerKeys[0]);
         char *cp = strchr(boundary.c_str(), '=');
         if (cp) {
-          strcpy(glob_script_mem.jpg_task.boundary,cp + 1);
+          strlcpy(glob_script_mem.jpg_task.boundary, cp + 1, sizeof(glob_script_mem.jpg_task.boundary));
         }
@@ -2806,7 +2806,7 @@ int32_t fetch_jpg(uint32_t sel, char *url, uint32_t xp, uint32_t yp, uint32_t sc
           glob_script_mem.jpg_task.stream.readBytesUntil('\n', inbuff, sizeof(inbuff));
           //AddLog(LOG_LEVEL_INFO, PSTR("size = %s"), inbuff);
           char *cp = strchr(inbuff, ':');
-          uint16_t size = 0;
+          uint32_t size = 0;
           if (cp) {
             size = atoi(cp + 1);

The first hunk is CVE-2026-38426. The second hunk is the per-frame Content-Length parser in selector 2. Pre-patch, size is uint16_t and atoi returns int. An attacker MJPEG server stating Content-Length: -1 produces atoi(cp+1) == -1, an implicit conversion that lands 65535 in the uint16_t. The next lines:

if (size > 0) {
  uint8_t *buff = (uint8_t *)special_malloc(size);
  if (buff) {
    glob_script_mem.jpg_task.stream.readBytes(buff, size);
  }
  ...
}

special_malloc(65535) on a busy ESP32 may succeed or may fail; if it succeeds, the device blocks reading 65535 bytes from an attacker connection. Post-patch, the same -1 produces 0xFFFFFFFF in uint32_t, special_malloc(4294967295) returns NULL, the if (buff) gate catches it, and the malformed Content-Length becomes a no-op. This change has its own threat model and its own pre-patch behavior. It is not in the CVE record.

The commit message names one fix. The diff ships two. The maintainer saw the second issue while patching the first and addressed it in the same change without renaming the commit. The function had two undertested size-handling sites; one had its CVE, one did not.

The author knew strlcpy. The file proves it.

This file is 14,000+ lines of scripter implementation, parser, web UI handlers, MQTT command dispatch, MJPEG stream handler, embedded HTTP server, mDNS announcer, and forty other features compiled in or out by macro. The author calls strlcpy 57 times. They know the bounded copy primitive exists and they use it as their default for copying strings into stack and struct buffers. Twenty-seven of the 57 sites pass sizeof(dst) as the size argument; the rest pass a named constant or a tracked variable.

The same file calls raw strcpy 29 times. Each site picks strcpy over strlcpy for one of two reasons: the destination is alleged to be large enough by some unrelated bound, or the author was not thinking about it. Three of those 29 sites:

// line 873, inside the numeric formatter
strcat(cpbuf,nbuff);
strcpy(nbuff,cpbuf);

// line 2974, inside a string-variable sort
strcpy(temp, s1);
strcpy(s1, s2);
strcpy(s2, temp);

// line 6865, inside the UDP send command
char payload[SCRIPT_MAX_SBSIZE * 3];
char part1[SCRIPT_MAX_SBSIZE];
lp = GetStringArgument(lp, OPER_EQU, part1, 0);
strcpy(payload, part1);

The numeric-formatter one is bounded by the format width. The sort-swap one trusts that all string variables share the same max_ssize. The UDP-send one allocates payload at three times the part size, which means three sequential strcat calls following are within bounds. Each of these is defensible by reading the surrounding code carefully. None of them have been audited by a CVE; CVE-2026-38426 is the only one that has. The next one will be the next site where an strcpy destination is sized for a polite caller and the actual caller is the network.

The threat model is not "an exposed Tasmota"

Reaching fetch_jpg() requires the Tasmota device to run a script containing jpg(0, "host/stream", ...). Scripts are loaded through HandleScriptConfiguration, which calls HttpCheckPriviledgedAccess() before doing anything. An unauthenticated remote attacker cannot push a script. The CVE's CVSS vector says PR:N; the privilege required to write the script is real.

What an unauthenticated attacker can do is be on the other side of the URL the admin already wrote. The documented use case for jpg(0, ...) is pulling an MJPEG stream from a network IP camera, the kind of camera the Tasmota device is supposed to display on its attached screen. The relevant population is Tasmota devices already scripted to fetch from cam.local/stream or cam.lan:8080, where the LAN camera is the kind of consumer device that has its own CVE catalog three rows deep.

When the camera is compromised, the camera's HTTP responses are attacker-chosen. When the LAN's DNS is hijacked, the URL resolves to attacker infrastructure. When the upstream feed is an internet-reachable MJPEG aggregator, the aggregator chooses the boundary. None of these require the attacker to touch the Tasmota at all. The exploit primitive is held by whoever holds the upstream HTTP endpoint. CVE-2026-38426 turns "your IP camera got popped" into "your Tasmota got popped seven seconds later."

The line was wrong. The file is still next to it.

The patch closes the one strcpy whose destination was forty bytes and whose source was the network. The commit message names that one. The same commit silently tightens a sibling issue in the same function. The other 28 strcpy calls remain. Each of them is bounded by an argument the surrounding code chose; the choosing was done by the same author who chose strlcpy 57 times.

Audit the 29 by the rule the author followed twice in this commit: where the source can be supplied by something other than the script's own parser, the destination needs strlcpy(dst, src, sizeof(dst)). The script's UDP send writes attacker-controllable strings. The web-page handlers write user-supplied form data. The MQTT command dispatch writes broker-supplied topics. Each one is a future CVE shaped like this one, with a different entry path and the same primitive at the destination. The scripter is a design-debt driver, and the choice between strlcpy and strcpy at each new site is the substrate that keeps producing the class.

PoC: sermikr0/CVE-2026-38426.

The author who wrote strlcpy fifty-seven times wrote strcpy on the line that read from the network. The patch fixes that line. The file is still next to it.