The ipTIME A604M is a Korean SOHO router that most home installs put in a double-NAT topology: a fiber ONU upstream doing NAT, then ipTIME doing its own NAT, then the LAN. When a LAN client opens a UPnP port mapping, uTorrent at startup, an IPTV box, a NAS, ipTIME has to delegate the mapping up to whatever IGD is sitting on its WAN. So libcgi.so multicasts SSDP M-SEARCH out the WAN interface. The protocol designed for trusted LAN discovery runs on the side of the box that faces a shared segment the box does not own. Whoever answers first becomes ipTIME's upstream IGD. CVE-2025-55423 is what libcgi.so does with that answer, and the answer reaches system() through strstr(line, "http") on the stdout of ipTIME's own bundled /sbin/upnpc.
CVE-2025-55423: ipTIME's libcgi Reads upnpc's Stdout as a Wire Format. The WAN Writes the Stdout.
patterns
cve
proof of concept
The trust boundary is a strstr in libcgi.so
When ipTIME wants to find its upstream IGD, libcgi.so's discover_upper_upnp_igd does this:
snprintf(cmd, 0x100, "/sbin/upnpc -m %s -P", ip);
fs = popen(cmd, "r");
...
do {
idx = fgets(fs_buf, 4000, fs);
if (idx == NULL) { success = 0xffffffff; goto cleanup; }
iVar1 = strncmp(fs_buf, "Found valid IGD", 0xf);
} while (iVar1 != 0);
idx = strstr(fs_buf, "http");
if (idx != NULL) {
snprintf(igd_url, 0x100, "%s", idx);
istatus_set_value_direct(&igd, igd_url);
}The function execs the firmware's bundled /sbin/upnpc binary, pipes its stdout back, scans the output line by line, looks for the first line that begins with the literal string Found valid IGD, finds the first occurrence of the substring http on that line, and snprintfs from there to the end of the line into a 256-byte slot called igd_url. That value is stored via istatus_set_value_direct so any other libcgi handler can read it back.
This is libcgi's protocol for "who is my upstream IGD." The protocol is "the substring of /sbin/upnpc's stdout that begins at the first http of the first line starting with Found valid IGD." There is no schema. There is no length validation. There is no character-class restriction. The grammar is documentation by example, and the example is the happy path.
The stored igd_url is read back here, in upnp_relay:
istatus_get_value_direct(&igd, buf);
...
snprintf(bufCopied, 0x100, "-u %s", buf);
...
system2("/sbin/upnpc %s -m %s -d %s %s", bufCopied, wanip, port, proto);buf is the stored igd_url. It is formatted into -u <igd_url> and passed as the first variadic argument to system2. system2 is libcgi's shell-out helper:
void system2(char *fmt, ...) {
vsnprintf(scratch, 0x3ef, fmt, args);
strcat(scratch, " >/dev/null 2>&1");
system(scratch);
}vsnprintf substitutes bufCopied into the format. strcat appends >/dev/null 2>&1. system() hands the whole string to /bin/sh -c. The shell metacharacters in igd_url are unescaped because nothing in this chain ever thought of igd_url as an attacker-controlled string. The function that wrote igd_url read it from /sbin/upnpc's stdout, and to libcgi.so, its own bundled helper binary's stdout is private IPC.
/sbin/upnpc's stdout is in fact what the WAN said
/sbin/upnpc is ipTIME's vendored copy of miniupnpc's example client. The -m <ip> flag binds SSDP multicast to that interface IP; the -P flag asks the discovered IGD for its presentation URL. Both flags happen to drive a full IGD-discovery sequence inside UPNP_GetValidIGD before anything is printed.
The sequence reads in five steps. Every value on the path is supplied by whoever answered the M-SEARCH:
ssdpDiscoverDevicesmulticastsM-SEARCH * HTTP/1.1and reads back replies withparseMSEARCHReply, which lifts theLOCATION:,ST:, andUSN:header values out of each response. Each reply becomes aUPNPDevnode in adevlist.- For each device in the list,
miniwget_getaddrperforms an HTTP GET on the URL that arrived inLOCATION:. The response body is treated as the device description XML. parserootdescparses that XML and populatesdata->first.controlurlwith the value of the first<controlURL>element.UPNPIGD_IsConnectedPOSTs aGetStatusInfoSOAP call todata->first.controlurland reads the response'sNewConnectionStatus. If the value isUporConnected, the device is accepted as a live IGD.UPNP_GetExternalIPAddressPOSTsGetExternalIPAddressand checks that the returned IP is not in a reserved range.
On success, upnpc prints to its own stdout:
printf("Found valid IGD : %s\n", urls.controlURL);The PoC's attacker.xml sets the first <controlURL> to /87895a19/upnp/control/WANIPConn1;PWNED. The PoC's http_server.py returns <NewConnectionStatus>Up</NewConnectionStatus> to GetStatusInfo and <NewExternalIPAddress>8.8.8.8</NewExternalIPAddress> to GetExternalIPAddress. upnpc runs the full IGD-validation flow against the attacker's listener, decides the listener is a live IGD with a non-reserved external IP, and prints:
Found valid IGD : http://10.0.11.234:8080/87895a19/upnp/control/WANIPConn1;PWNEDThat line is what libcgi's discover_upper_upnp_igd is waiting for. The strncmp(fs_buf, "Found valid IGD", 0xf) matches. The strstr(fs_buf, "http") finds the substring. The snprintf copies from there. igd_url is now http://10.0.11.234:8080/87895a19/upnp/control/WANIPConn1;PWNED. The semicolon is the shell separator.
The next time a LAN client triggers upnp_relay, system() receives a command line the PoC captured at the entry to system with gdb on a MIPS user-mode harness:
A0 = '/sbin/upnpc -u http://1.2.3.4/x;echo hello world > /tmp/pwn;# -m 1.2.3.4 -d 8080 tcp >/dev/null 2>&1'
system+24 beqz $a0, system+48By the MIPS calling convention, A0 is system's first argument. /bin/sh -c parses that string as two statements separated by the semicolon: /sbin/upnpc -u http://1.2.3.4/x and echo hello world > /tmp/pwn. The # after the second statement comments out the rest of the command (-m 1.2.3.4 -d 8080 tcp >/dev/null 2>&1) that libcgi itself appended via system2. The attacker writes the payload, the shell parses it, the # cleans up after libcgi's own variadic continuation.
The protocol is a substring of a printf
This is content-is-command with three process boundaries between the content channel and the interpreter. The content channel is the <controlURL> element of an SSDP description XML returned to a WAN-side responder. The interpreter is /bin/sh -c. The bridge between them runs across three programs, gets re-encoded twice, and passes through one global key-value store, and the value at the end is byte-identical to the value at the start.
The boundaries the bytes cross:
- The attacker's TCP listener returns the XML.
parserootdescinside/sbin/upnpcreads the first<controlURL>intodata->first.controlurl. GetUPNPUrlsresolves it intourls.controlURLas an absolute URL.printf("Found valid IGD : %s\n", urls.controlURL)writes it onto/sbin/upnpc's stdout. The format specifier is%s. No encoding.popenin libcgi pipes that stdout.fgetsreads a line.strstr(line, "http")finds the substring.snprintf(igd_url, 0x100, "%s", idx)copies it. The format specifier is again%s.istatus_set_value_direct(&igd, igd_url)writes the value into the libcgi-wide key-value store.istatus_get_value_direct(&igd, buf)reads it back.snprintf(bufCopied, 0x100, "-u %s", buf)wraps it.system2'svsnprintfsubstitutes it.system()hands it to/bin/sh.
Each layer treats its input as authoritative output from the layer above. The XML parser was answered by an upstream router. The upstream router was discovered by SSDP. The SSDP discovery was launched by libcgi. libcgi is reading its own bundled helper binary's stdout. The kernel-level view of the trust boundary, where the file descriptor was created, who is the writing process, agrees with that chain at every layer. The protocol-level view, who controls the bytes, disagrees with it at the top.
/sbin/upnpc's stdout is libcgi's internal-only-by-convention channel. The framework treats the popen pipe as internal IPC because it forked the child. The convention says "only my own helper binary writes to this stdout." The convention is true about the writer and false about the bytes. Every previous exhibit of this pattern has been an HTTP header or a query parameter the framework wrote to itself, like Next.js's x-middleware-subrequest or Zimbra's javax.servlet.include.servlet_path. The shape generalizes below HTTP: a Unix pipe from popen to fgets is the same trust shape with a different transport. The framework's internal channel reads attacker input every time the helper binary it wraps reads from the network.
The WAN-side M-SEARCH is the design
The thing that makes this CVE specifically ipTIME's bug and not generic miniupnpc behavior is the decision to send the discovery M-SEARCH out the WAN interface in the first place. UPnP was designed for LAN-side discovery between trusted devices on the same broadcast domain. The protocol's threat model is "anyone who can hear my multicast can claim to be a printer." That model is acceptable on a LAN because the LAN is by assumption owned by one party. ipTIME's double-NAT delegation pattern reuses the same primitive on a WAN segment whose ownership boundary the protocol does not address. In a typical Korean fiber-to-the-home installation, the ipTIME's WAN sits on an ONU's downstream LAN that is shared with ISP management equipment and, in apartment deployments, with adjacent units' ONUs. The WAN-side broadcast domain is not assumed-trusted by anything except libcgi.
The trigger from the LAN side is a UPnP port-mapping request. uTorrent at startup is the documented example. Once the LAN client requests a mapping, upnp_relay runs, discover_upper_upnp_igd runs if igd_url is unset, the M-SEARCH goes out the WAN, the first WAN-side responder wins. The PoC's docs/02-attack-scenario.md walks the broader MITM steps that get the attacker to the responder seat (ARP spoofing the upstream router, hijacking the T1 DHCP renewal to plant an attacker-controlled gateway, dropping IP-forwarding to induce a LAN-side reboot so uTorrent re-requests its port mapping). The PoC deliberately does not implement those steps because they are generic MITM, not properties of this CVE. The CVE is what happens after the attacker has won the SSDP race. Everything from there is strstr(line, "http") and snprintf.
Why the structural shape exists
The developer wrote no escape because the developer's mental model of the data path is "I am reading my own helper binary's stdout." The model is correct at the kernel level and wrong at the protocol level, and the gap between those two correctnesses is where bugs of this class live.
libcgi.so is a SOHO-router shared library that absorbs HTTP parsing, UPnP handling, web-UI dispatch, CGI parameter extraction, and several daemons' command logic into one .so. The codebase is glued together with popen and system. The same upnp_relay function calls system("/sbin/iptables -P INPUT ACCEPT") and system("/sbin/iptables -P INPUT DROP") to bracket its own work. system2 exists specifically because most of what libcgi does is vsnprintf a command, append >/dev/null 2>&1, and shell out. In a codebase where /bin/sh is the universal IPC mechanism, the boundary between attacker-controlled and trusted bytes has to live in the developers' heads, because neither the language nor the helper libraries provide help with it. When the developer writes popen("/sbin/upnpc ..."), they are thinking about which line of the output they need, not about who controls the bytes upnpc will print.
The deeper move is the repurposing of debug output as a wire format. miniupnpc's printf("Found valid IGD : %s\n", urls.controlURL) was a human-readable status line, meant for an operator running upnpc by hand to introspect their LAN. ipTIME repurposed it as a programmatic IGD-discovery channel by scraping its output. The text-after-the-colon-on-the-line-starting-with-"Found valid IGD" is the protocol ipTIME invented. That protocol carries urls.controlURL verbatim because miniupnpc's format string is %s and controlURL is the field the WAN responder controls. Every embedded codebase that scrapes the stdout of another binary has the same boundary problem; this one happens to terminate the scrape in system().
The patched advisory does not say "stdout"
The CVE record will name this as a command injection in upnp_relay. That is true at the line where the bug fires, system2(..., bufCopied, ...), and it is also where a defender reading the advisory will stop looking. The injection sink is in upnp_relay. The injection source is the line of /sbin/upnpc stdout that begins Found valid IGD : . The validator that would have stopped the chain has to live in discover_upper_upnp_igd, where the line is read, not in upnp_relay, where it is used. A patch in upnp_relay that escapes igd_url before snprintf-ing it would close this CVE and leave the boundary unchanged. Any other libcgi handler that reads igd via istatus_get_value_direct and shells out with the value would still inherit a shell-controllable string.
The bug is not a missing escape. The bug is that /sbin/upnpc's stdout is treated as a trusted oracle for what the upstream router's controlURL is, when in fact /sbin/upnpc's stdout is the most recent thing a WAN-side SSDP responder caused it to print.
The interpreter at the bottom is /bin/sh. The interpreter in the middle is strstr(line, "http").