TCL LinkHub Mesh Wifi GetValue buffer overflow vulnerability
The GetValue function in TCL LinkHub Mesh Wi-Fi copies configuration values from flash into caller-provided buffers without checking their size, causing stack-based buffer overflows. An attacker who can modify a configuration value, such as sys.app.lang, can overwrite return addresses and achieve arbitrary code execution.
A buffer overflow vulnerability exists in the GetValue functionality of TCL LinkHub Mesh Wi-Fi MS1G0001.0014. A specially-crafted configuration value can lead to a buffer overflow.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the GetValue function lacks a destination buffer size parameter, so it uses strncpy with a maximum length of 0x5dc regardless of the actual buffer size at the call site.
Impact
An attacker could overwrite the return address and achieve arbitrary code execution on the device.
What the attacker needed
Ability to send protobuf messages to the device; or access to the cfm command-line utility
The fix
The GetValue prototype should be fixed to include the buffer size, or all destination buffers should be at least 0x5dc bytes.
How it was found
- Send a protobuf message to set the sys.app.lang configuration value to a long string.
- The confctl_set_app_language function copies the lang string into a stack buffer with strcpy, causing an overflow.
- The set_if_changed function calls GetValue to retrieve the old value into a small stack buffer.
- GetValue calls cfms_mib_proc_handle, which sends a request to cfmd and receives a response containing the long value.
- The response is copied into the small stack buffer via strncpy with a length based on strlen, overflowing the buffer and overwriting the return address.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A buffer overflow happens when a program copies more data into a fixed-size memory area than it can hold, so the extra data spills over and can overwrite important control information. Here, the router's GetValue function reads a setting from storage and copies it into a small buffer without checking the length, so a long setting value can overwrite the return address and let an attacker run their own code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.