Talos Vulnerability Report

TALOS-2024-2048

Wavlink AC3000 qos.cgi qos_sta_settings() buffer overflow vulnerability

January 14, 2025
CVE Number

CVE-2024-39299

SUMMARY

A buffer overflow vulnerability exists in the qos.cgi qos_sta_settings() 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.

CONFIRMED VULNERABLE VERSIONS

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

PRODUCT URLS

Wavlink AC3000 - https://www.wavlink.com/en_us/product/WL-WN533A8.html

CVSSv3 SCORE

9.1 - CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H

CWE

CWE-120 - Buffer Copy without Checking Size of Input (‘Classic Buffer Overflow’)

DETAILS

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 qos.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:

00400ce0                  int32_t $v0_9 = web_get("page", $v0_7, 0)
// [...]
00400d08                  else if (strcmp($v0_9, "qos_sta") == 0)
00400ebc                      qos_sta_settings($v0_7)

If we provide page=qos_sta, we enter the qos_sta_settings function and our provided POST data is further parsed therein:

00401508  int32_t qos_sta_settings(int32_t arg1)
0040155c      int32_t cli_list_1 = strdup(web_get("cli_list", arg1, 0))  // [1]
00401594      int32_t cli_num_1 = strdup(web_get("cli_num", arg1, 0))    // [2]
004015cc      int32_t time_control_num_1 = strdup(web_get("time_control_num", arg1, 0))
004015e8      char cmd_[0x800]
004015e8      memset(&cmd_, 0, 0x800)
00401608      sprintf(&cmd_, "/sbin/sta_qos.sh setup %s %s", cli_list_1, cli_num_1) // [3]
// [...]

Among the different POST parameters that this function can read in, we see most importantly that the cli_list and cli_num fields are read in to the heap without length checking at [1] and [2]. Since our input cli_list and cli_num fields both can easily reach 0x818 bytes, we can overflow the cmd_ buffer at [3] and overwrite the return address of the function, resulting in arbitrary code execution.

Crash Information

Thread 2.1 "qos.cgi" hit Breakpoint 3, 0x00401524 in qos_sta_settings ()
(gdb) b * 0x4017d4
cBreakpoint 4 at 0x4017d4
(gdb) c
Continuing.
[Detaching after fork from child process 15842]
[Detaching after fork from child process 16172]
[Detaching after fork from child process 16188]

Thread 2.1 "qos.cgi" hit Breakpoint 4, 0x004017d4 in qos_sta_settings ()
(gdb) bt
#0  0x004017d4 in qos_sta_settings ()
#1  0x41414141 in ?? ()
Backtrace stopped: frame did not save the PC
(gdb) info reg
          zero       at       v0       v1       a0       a1       a2       a3
 R0   00000000 00000000 7751fee8 7751fb58 007bd860 00000001 00000011 00000000
            t0       t1       t2       t3       t4       t5       t6       t7
 R8   00000000 00000000 00000000 00000000 00000001 00001f00 00001ffa 00000001
            s0       s1       s2       s3       s4       s5       s6       s7
 R16  41414141 41414141 41414141 41414141 41414141 774a8c10 0043183c ffffffff
            t8       t9       k0       k1       gp       sp       s8       ra
 R24  00000000 00000000 00000010 00000000 00425d20 7f910228 00450000 41414141
        status       lo       hi badvaddr    cause       pc
      0100fc13 00000400 00000000 007bd850 50800024 004017d4
          fcsr      fir      hi1      lo1      hi2      lo2      hi3      lo3
      00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
        dspctl  restart
      00000000 00000000
(gdb) c
Continuing.

Thread 2.1 "qos.cgi" received signal SIGSEGV, Segmentation fault.
0x41414141 in ?? ()
TIMELINE

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

Credit

Discovered by Lilith >_> of Cisco Talos.