An unpatched vulnerability in the TP-Link SR20 smart hub and router can be exploited to achieve arbitrary command execution, a security researcher has discovered.
Likely impacting other TP-Link devices as well, the issue was found in the “TDDP” (TP-Link Device Debug Protocol) process, which TP-Link routers frequently run as root. Version 2 of the protocol requires admin password on the router, but version 1 is unauthenticated.
What Google security researcher Matthew Garrett discovered was that the router still exposes some version 1 commands, including one for configuration validation.
“You send it a filename, a semicolon and then an argument,” the researcher explains on Twitter.
“The router then connects back to the requesting machine over TFTP, requests the filename via TFTP, imports it into a LUA interpreter and passes the argument to the config_test() function in the file it just imported,” Garrett also notes.
With config_test() being provided by the file downloaded from the remote machine, arbitrary code execution is possible in the interpreter. This also includes an os.execute method, which runs commands on the host, the researcher says.
Since the interpreter is running as root, an attacker could leverage the os.execute() method to execute arbitrary code with root privileges, the researcher says.
TDDP is listening on all interfaces but, because the default firewall rules on the SR20 routers block WAN access, the vulnerability can only be exploited via the local network, Garrett explains.
The security researcher discovered the vulnerability last year and reported it to TP-Link in December, but received no reply from the company, so he decided to make the vulnerability public. He also published proof-of-concept code exploiting the bug.
“Stop shipping debug daemons on production firmware and if you’re going to have a webform to submit security issues then have someone actually respond to it,” Garrett pointed out on Twitter.