Skip to content
RCE Write-up Advanced

Understanding the vulnerability

The HTTP server on the TP-Link TL-R600VPN router incorrectly parses the file extension of requests to the /fs/ directory, causing a stack-based buffer overflow. An authenticated attacker can exploit this to execute arbitrary code on the device.

blog.talosintelligence.com

Published on blog.talosintelligence.com

TP-Link recently patched three vulnerabilities in their TL-R600VPN gigabit broadband VPN router, firmware version 1.3.0. Cisco Talos publicly disclosed these issues after working with TP-Link to ensure that a patch was available.

The author, on blog.talosintelligence.com

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 write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The function httpGetMimeTypeByFileName uses strlen() to find the end of the requested page name and then reads backwards until a period is found, without checking the buffer length, leading to a stack-based buffer overflow.

Impact

An authenticated attacker could execute arbitrary code on the device with the privileges of the HTTPD process, potentially leading to full control of the router.

What the attacker needed

Authentication as admin; network access to the router

How it was found

  1. Send an HTTP request to one of the vulnerable pages under /fs/ (e.g., /fs/help) with a long header value.
  2. The server parses the URI, fails to find a period, and reads backwards into the header data, copying characters to a stack buffer.
  3. The toUpper() function converts lowercase characters to uppercase, limiting usable bytes.
  4. The overflow overwrites the saved return address and registers on the stack.
  5. Use return-oriented programming gadgets from uClibc to call memcpy() and copy the original header data to the stack.
  6. Execute the copied shellcode to spawn a shell or connect back to the attacker.

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 write-up has not been written yet. The Original tab links to the source.

The router's web server has a bug in how it reads the file extension from a web address. When someone requests certain pages, the server keeps reading backwards in memory until it finds a dot, which can overwrite a fixed-size buffer on the stack. This lets an attacker who is already logged in run their own commands on the router.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.