CVE-2024-39288
A buffer overflow vulnerability exists in the internet.cgi set_add_routing() functionality of Wavlink AC3000 M33A8.V5030.210505. A specially crafted HTTP request can lead to stack-based buffer overflow. An attacker can make an authenticated HTTP request to trigger this vulnerability.
The versions below were either tested or verified to be vulnerable by Talos or confirmed to be vulnerable by the vendor.
Wavlink AC3000 M33A8.V5030.210505
Wavlink AC3000 - https://www.wavlink.com/en_us/product/WL-WN533A8.html
9.1 - CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H
CWE-120 - Buffer Copy without Checking Size of Input (‘Classic Buffer Overflow’)
The Wavlink AC3000 wireless router is predominately one of the most popular gigabit routers in the US, in part due to both its potential wireless and wired speed capabilities and extremely low price point (costing at the time of this writing ~$60 USD). Among the configuration options, it’s also able to act as a standalone wireless gateway, a basic network router, or a wireless repeater.
When interacting with and configuring the Wavlink AC3000 wifi router, as is typical of most wifi routers, an administrator logs in via some web portal and configures appropriate options via the HTTP interface. In the case of this particular router, and in another somewhat common execution pattern, these HTML pages can invoke .cgi binaries due to how the lighttpd server is configured. Since all of these .shtml and .cgi files are located in the web root, anyone with network access to the device doesn’t actually need to log in to the device to interact with these .cgi files, and it usually is the responsibility of the .cgi binary to check if the authentication is completed successfully. On this device, one will see a check_valid_user()
function in each individual .cgi binary which will check the session
cookie of the HTTP request to see if it’s coming from a validly logged in user.
Assuming that we’ve passed this check in the internet.cgi
binary, we then run into a set of functions that we can call based off of what we pass for the page=
parameter in our HTTP POST request. Of the available commands, we focus on the following:
00401a18 else if (strcmp(page_get, "addrouting") == 0)
00401ae4 set_add_routing(malloc_contlen)
If we provide page=addrouting
, we enter the set_wzdrepeater
function and our provided POST data is further parsed therein:
00402f78 int32_t set_add_routing(int32_t arg1)
00402fc0 char buff_0x100_1[0x100]
00402fc0 memset(&buff_0x100_1, 0, 0x100)
00402fdc char buff_0x100_2[0x100]
00402fdc memset(&buff_0x100_2, 0, 0x100)
00402ff4 web_debug_header()
00403028 int32_t dest_1 = strdup(web_get("dest", arg1, 1)) // [1]
// [...]
004031ac if (sx.d(*dest) != 0)
00403228 void* cmd_buff = &buff_0x100_1[strlen(&buff_0x100_1)]
00403238 *(cmd_buff + 3) = 'ut'
00403248 *(cmd_buff - 1) = 'ro'
0040324c *(cmd_buff + 7) = 'ad'
00403254 *(cmd_buff + 3) = 'e '
00403258 *(cmd_buff + 9) = ' '
00403264 *(cmd_buff + 8) = 'd'
00403268 *(cmd_buff + 0xa) = 0
00403284 char* $a0_10 = &buff_0x100_1
00403280 if (strcmp(hostnet, "net") == 0)
004035a4 __builtin_strncpy(dest: &buff_0x100_1[strlen($a0_10)], src: "-net ", n: 6)
00403280 else
004032b8 __builtin_strncpy(dest: &buff_0x100_1[strlen($a0_10)], src: "-host ", n: 7)
004032d0 strcat(&buff_0x100_1, dest) // [2]
Among the different POST parameters that this function can read in, we see most importantly that the dest
field is read in to the heap without length checking at [1], and then read into the stack with strcat
at [2]. Since our input dest
field can easily reach 0x528 bytes (the stack offset of the buff_0x100_1
buffer), we can overflow and overwrite the return address of the function, resulting in arbitrary code execution.
Thread 2.1 "internet.cgi" hit Breakpoint 3, 0x00402f9c in set_add_routing ()
(gdb) b *0x4032d0
Breakpoint 4 at 0x4032d0
(gdb) c
Continuing.
Thread 2.1 "internet.cgi" hit Breakpoint 4, 0x004032d0 in set_add_routing ()
(gdb) x/1s $a0
0x736f682d: <error: Cannot access memory at address 0x736f682d>
(gdb) x/1s $a1
0x55f550: 'A' <repeats 200 times>...
(gdb) c
Continuing.
[Detaching after fork from child process 31553]
Thread 2.1 "internet.cgi" received signal SIGSEGV, Segmentation fault.
0x41414141 in ?? ()
(gdb) info reg
zero at v0 v1 a0 a1 a2 a3
R0 00000000 00000000 7fd903ec 00005288 00000000 0055f550 0055fa80 0055fa90
t0 t1 t2 t3 t4 t5 t6 t7
R8 77cfd2b4 77cfc6e4 00000000 ffffffff 77e64000 f0000000 00000001 004031dc
s0 s1 s2 s3 s4 s5 s6 s7
R16 41414141 41414141 41414141 41414141 41414141 41414141 41414141 41414141
t8 t9 k0 k1 gp sp s8 ra
R24 0000004e 77d01288 00000000 00000000 77e82010 7fd90a28 41414141 41414141
status lo hi badvaddr cause pc
0100fc13 00111044 00000030 41414140 50800008 41414141
fcsr fir hi1 lo1 hi2 lo2 hi3 lo3
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
dspctl restart
00000000 00000000
2024-07-25 - Initial Vendor Contact
2024-07-29 - Requesting reply from vendor
2024-07-30 - Vendor confirms receipt
2024-07-30 - Vendor Disclosure
2024-07-30 - Vendor confirms receipt
2024-09-02 - Status update request sent
2024-10-15 - Status update request. Upcoming expiration date announced.
2024-10-22 - Vendor replies product has been discontinued, but patches are being worked on
2024-11-04 - Status update request for patch release dates
2024-11-12 TALOS advisory release date announced
2025-01-14 - Public Release
Discovered by Lilith >_> of Cisco Talos.