- Affected Firmware: TOTOLINK_C8160R-1C_N600R_IP04291_8196D_SPI_4M32M_V4.3.0cu.7647_B20210106_ALL
- CVE-ID: CVE-2025-22903
- Root Cause: By analyzing the cstecgi.cgi file in the cgi-bin directory, I found that the function at address 0x41CAF4 contains a stack overflow vulnerability.
- Impact: Remote unauthenticated attackers can execute arbitrary commands as root.
- Vendor Website: https://www.totolink.net
- Affected Firmware Download: website
During my internship at Qi An Xin Tiangong Lab, I discovered a StackOverflow vulnerability in the TOTOLINK-N600R router.
By analyzing the cstecgi.cgi file in the cgi-bin directory, I found that the function at address 0x41CAF4 contains a stack overflow vulnerability.
The stack overflow can be triggered by the pin key value, which leads to a sprintf overflow.
Use the following command to simulate with qemu.
sudo chroot . ./qemu-mips-static -E CONTENT_LENGTH=300 -E QUERY_STRING="action=no" -L /lib ./web_cste/cgi-bin/cstecgi_patch.cgi < ./poc.jsonThe content of the poc.json file is as follows:
{"topicurl":"setWiFiWpsConfig","wscMode":"1","wscPinMode":"1","pin":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}You can see that the stack length is only 0xD0, but we overflowed to 0xE8. If needed, we can overflow more. This overflow does not have a length limit. When using a longer overflow, you only need to modify the pin key value and the CONTENT_LENGTH size.


