Skip to content

Cybersecurity

UPnP at packet level - SSDP frames, SOAP requests and the configuration that closes the path

What UPnP looks like on the wire: SSDP frames, SOAP and SUBSCRIBE requests, CVE-2014-8361 and CallStranger, and router settings that close the attack path.

Józef SulwińskiJózef Sulwiński

Published 17 min read

UPnPSSDPSOAPNATnetwork securityport forwardingCallStranger
UPnP at packet level - SSDP frames, SOAP requests and the configuration that closes the path
Contents
  1. What UPnP looks like on the network
  2. Discovery - SSDP frames
  3. Device description - the XML file
  4. Control - SOAP requests
  5. Two flaws that change the threat picture
  6. What shows up in traffic and logs
  7. The configuration that closes the path
  8. Where we help
  9. Technical basis
  10. Related articles
  11. Sources

A router with UPnP (Universal Plug and Play, a protocol for automatic configuration of devices on a network) enabled lets any device open a port from the internet without a password. An infected computer, camera or printer does it with a single request. The rule goes into a separate UPnP port mapping table, not into the list of manually entered forwards, so the administrator rarely sees it.

UPnP documentation, CISA alerts and Akamai research show that:

  • the IGD (Internet Gateway Device, the part of UPnP responsible for port mapping) specification version 2 recommends that an unauthenticated computer maps only its own address and ports from 1024 up. A vendor may adopt a different policy,
  • in 2018 Akamai confirmed injected rules in 45,113 routers that exposed SMB (file sharing) service ports to the internet,
  • the CVE-2014-8361 flaw in router software is listed in the KEV catalog (the list of vulnerabilities exploited in attacks, maintained by CISA) and, according to NVD (the US vulnerability database), was exploited in attacks at least until 2023.

The frames and requests in the examples help recognise UPnP in traffic, and the settings in the last part close this path. A general overview of the protocol and campaigns is in the earlier article on UPnP threats. Addresses in the examples come from documentation and private ranges.

What UPnP looks like on the network

UPnP traffic has four stages, and each of them leaves a different trace on the network.

Stage Protocol and port What happens
Discovery SSDP (Simple Service Discovery Protocol), UDP 1900, multicast address 239.255.255.250 (IPv4) or FF02::C and FF05::C (IPv6) Devices announce themselves with a NOTIFY message, and computers search for them with an M-SEARCH message.
Description HTTP GET to the address from the LOCATION header, port chosen by the vendor The device returns an XML file with a list of services and control addresses.
Control HTTP POST with a SOAP envelope to the address from the description The computer invokes an action, for example adding a port mapping.
Eventing HTTP SUBSCRIBE and NOTIFY The device sends state changes to the address given by the subscriber.

An SSDP message to 239.255.255.250 goes to the hardware address 01:00:5e:7f:ff:fa. The specification sets a default TTL (packet hop count) of 2, and with a TTL greater than 1 multicast messages can pass through a router. If the router forwards multicast traffic, SSDP announcements reach the neighbouring segment. Description, control and eventing run over HTTP on TCP.

Discovery - SSDP frames

A computer searches for an internet gateway with this query. The MX field sets how long devices may delay their response, and ST sets the type of device being searched for.

M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 2
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
USER-AGENT: Linux/6.1 UPnP/2.0 Client/1.0
CPFN.UPNP.ORG: Test client

The gateway responds with a UDP packet sent to the address and port the query came from. The LOCATION field points to the device description.

HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1800
DATE: Fri, 20 Nov 2026 10:15:00 GMT
EXT:
LOCATION: http://192.168.1.1:5000/rootDesc.xml
SERVER: Linux/4.9 UPnP/2.0 Router/1.0
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
USN: uuid:3b1f0c7a-0000-1000-8000-aabbccddeeff::urn:schemas-upnp-org:device:InternetGatewayDevice:1
BOOTID.UPNP.ORG: 1
CONFIGID.UPNP.ORG: 1

The device also repeats its announcement before half of the max-age time has passed. The NOTIFY message has no DATE and EXT fields, and instead of ST it contains NT and NTS: ssdp:alive.

NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://192.168.1.1:5000/rootDesc.xml
NT: upnp:rootdevice
NTS: ssdp:alive
SERVER: Linux/4.9 UPnP/2.0 Router/1.0
USN: uuid:3b1f0c7a-0000-1000-8000-aabbccddeeff::upnp:rootdevice
BOOTID.UPNP.ORG: 1
CONFIGID.UPNP.ORG: 1

The examples show the format from version 2.0 of the specification. Many gateways still announce version 1.1 and omit some of the fields.

Reflection and amplification

The specification requires the response to be sent to the source address of the query. A query with a spoofed sender address therefore directs the response to the victim’s computer. A unicast query looks similar: the HOST field contains the gateway address, and there is no MX field. A gateway reachable from the internet answers it in the same way. The ST: ssdp:all field makes the gateway respond with a separate packet for each device and service type it announces. CISA gives an amplification factor of 30.8 for SSDP, meaning the gateway sends in total about thirty times more bytes than the query contained.

TIP

Block UDP traffic to port 1900 coming from the internet on the router’s external interface, and ask your provider about filtering packets with spoofed sender addresses (BCP 38). Why: a router that answers a query from the internet becomes an amplifier in an attack on someone else’s network.

Device description - the XML file

The computer downloads the file from the address in LOCATION. For port mapping, one fragment matters: the service type and the control address.

<service>
  <serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>
  <serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>
  <controlURL>/ctl/IPConn</controlURL>
  <eventSubURL>/evt/IPConn</eventSubURL>
  <SCPDURL>/WANIPCn.xml</SCPDURL>
</service>

The controlURL address accepts SOAP requests (a format for XML messages sent over HTTP), and eventSubURL accepts event subscriptions.

Control - SOAP requests

An application asks the gateway to forward a port with the AddPortMapping action. A correct request concerns the computer that sends it.

POST /ctl/IPConn HTTP/1.1
HOST: 192.168.1.1:5000
CONTENT-TYPE: text/xml; charset="utf-8"
SOAPACTION: "urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping"
CONTENT-LENGTH: 653

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
 s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
  <u:AddPortMapping xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
   <NewRemoteHost></NewRemoteHost>
   <NewExternalPort>51820</NewExternalPort>
   <NewProtocol>UDP</NewProtocol>
   <NewInternalPort>51820</NewInternalPort>
   <NewInternalClient>192.168.1.50</NewInternalClient>
   <NewEnabled>1</NewEnabled>
   <NewPortMappingDescription>VPN client</NewPortMappingDescription>
   <NewLeaseDuration>3600</NewLeaseDuration>
  </u:AddPortMapping>
 </s:Body>
</s:Envelope>

The SOAPACTION header contains the action name, so there is no need to read the request body to know what it does. The request carries no password. The frames use version 1 of the service, which many gateways announce. Version 1 provides no access control, and the recommendations in the table were introduced only in version 2.

IGD 2 specification rule Type of rule Effect when the implementation does not apply it
An unauthenticated computer maps only its own address as NewInternalClient. Recommendation, a vendor may adopt a different policy. One computer opens a port for another computer on the network (NAT rule injection, NAT being network address translation).
An unauthenticated computer uses ports from 1024 up. Recommendation, a vendor may adopt a different policy. An ordinary user forwards ports of system services, for example 445.
The lease lasts from 1 to 604800 seconds, and the gateway replaces the value 0 with the maximum. Requirement. The rule stays on the router after the infection is removed, because nothing expires it.
UPnP services are available only from the local network side, and the gateway rejects requests from the WAN interface. Requirement. Anyone on the internet controls the NAT table.

The EternalSilence campaign described by Akamai exploited exactly the last row. According to Akamai, requests came from the internet to routers that accepted UPnP control on the WAN interface. The attackers added rules that exposed ports 139 and 445 of computers behind the router, and labelled them with the string galleta silenciosa. The gateway returns such a rule in response to a read of the port mapping table. The port and address values come from the Akamai figure, and the lease is an example.

<u:GetGenericPortMappingEntryResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
 <NewRemoteHost></NewRemoteHost>
 <NewExternalPort>47669</NewExternalPort>
 <NewProtocol>TCP</NewProtocol>
 <NewInternalPort>445</NewInternalPort>
 <NewInternalClient>192.168.10.212</NewInternalClient>
 <NewEnabled>1</NewEnabled>
 <NewPortMappingDescription>galleta silenciosa</NewPortMappingDescription>
 <NewLeaseDuration>0</NewLeaseDuration>
</u:GetGenericPortMappingEntryResponse>

Akamai found 45,113 routers with such rules. In its assessment, the operators wanted to attack SMB services behind the routers with exploits from the Eternal family (EternalBlue and EternalRed). Akamai calls the campaign opportunistic: the attackers took any router that accepted the rule.

Reading the port mapping table

The table is read with the GetGenericPortMappingEntry action and an increasing index. The gateway returns the entries one by one, and after the last one it responds with error 713 SpecifiedArrayIndexInvalid. Error 606 Action not authorized means the gateway refused to read a single entry.

<u:GetGenericPortMappingEntry xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
 <NewPortMappingIndex>0</NewPortMappingIndex>
</u:GetGenericPortMappingEntry>

Two flaws that change the threat picture

CVE-2014-8361 - a crafted field value

NVD describes the miniigd service in the Realtek SDK software package, which allows remote execution of arbitrary code through a crafted request with the NewInternalClient field. The CVSS 3.1 (vulnerability severity scale) score is 9.8, and the vulnerability is in the CISA KEV catalog. According to NVD, it was exploited in attacks at least until 2023. The NewInternalClient field usually contains an IPv4 address, less often a host name, and the specification allows both.

<NewInternalClient>[crafted value instead of an IPv4 address or host name]</NewInternalClient>

Characters outside an address or host name in this field (semicolon, backtick, dollar sign, vertical bar, ampersand) should be treated as a warning sign. An IDS (intrusion detection system) rule can look for such characters:

<(?:\w+:)?NewInternalClient\b[^>]*>[^<]*[;`$|&][^<]*<

TIP

Check whether the router runs the chip vendor’s software without updates, and replace devices for which the vendor no longer releases patches. Why: a flaw from 2014 still works on devices that nobody updates.

CVE-2020-12695 (CallStranger) - an event callback address outside the local network

A computer subscribes to a service’s events with a SUBSCRIBE request. In the CALLBACK header it gives the address to which the device should send notifications.

SUBSCRIBE /evt/IPConn HTTP/1.1
HOST: 192.168.1.1:5000
CALLBACK: <http://203.0.113.10:8080/receive>
NT: upnp:event
TIMEOUT: Second-1800

The specification before 17 April 2020 did not forbid accepting a subscription with an address in a different network from the device’s address. This is how NVD describes it, scoring the vulnerability 7.5 on the CVSS 3.1 scale. According to CERT/CC, an attacker can send large volumes of traffic to any address on the internet, which enables an amplified DDoS attack and data exfiltration. Under the corrected specification, a device must not accept a subscription with an address outside its own network segment. CERT/CC recommends disabling UPnP on internet-facing interfaces, and recommends that vendors disable subscription support by default and restrict it to the trusted local network.

The public CallStranger repository contains a tool that checks whether a device is vulnerable to CVE-2020-12695. According to the repository description, the script only simulates data exfiltration. Run it only against your own devices.

The IDS rule pattern checks every address in the CALLBACK header and skips private, link-local and loopback ranges:

<https?://(?!(?:10\.\d{1,3}|127\.\d{1,3}|192\.168|169\.254|172\.(?:1[6-9]|2\d|3[01]))\.\d{1,3}\.\d{1,3}(?::\d+)?[/>])[^>]*>

The pattern is a heuristic. A private address from another segment passes without an alert, and a more precise check compares the callback address with the device’s subnet.

What shows up in traffic and logs

Symptom Where to look What it means
UDP packets to port 1900 from addresses outside the internal network WAN interface, filter udp dst port 1900 and not (src net 10.0.0.0/8 or src net 172.16.0.0/12 or src net 192.168.0.0/16) Someone is scanning the router for the SSDP service.
UDP packets from source port 1900 to external addresses WAN interface, filter udp src port 1900 and not (dst net 10.0.0.0/8 or dst net 172.16.0.0/12 or dst net 192.168.0.0/16) The gateway answers the world and can be used to reflect traffic.
SOAP AddPortMapping requests from a computer other than the address in NewInternalClient IDS or router log NAT rule injection.
Characters outside an address or host name in the NewInternalClient field IDS, pattern from the CVE-2014-8361 section Possible attempt to exploit CVE-2014-8361.
SUBSCRIBE with a CALLBACK address outside the private network IDS, pattern from the CallStranger section Possible attempt to exploit CallStranger.
Entries in the port mapping table with ports 139 and 445, a lease of 0 or a description nobody entered Reading the port mapping table Rules injected by an infected computer or by an attacker.

The script reads the port mapping table of your own router. It sends an M-SEARCH query, downloads the device description and calls GetGenericPortMappingEntry without changing anything. It uses only the Python standard library. A gateway without authentication usually shows only the entries that belong to the computer running the script. The full table is visible in the router’s admin panel. Run the script only on a network you manage.

#!/usr/bin/env python3
"""Read the port mapping table from your own UPnP gateway (read-only)."""
import re
import socket
import urllib.error
import urllib.request
from urllib.parse import urljoin, urlparse

SSDP = ("239.255.255.250", 1900)
SERVICES = (
    "urn:schemas-upnp-org:service:WANIPConnection:1",
    "urn:schemas-upnp-org:service:WANIPConnection:2",
    "urn:schemas-upnp-org:service:WANPPPConnection:1",
)
MAX_ENTRIES = 1024


def field(xml, name):
    m = re.search(rf"<{name}>(.*?)</{name}>", xml, re.S)
    return m.group(1) if m else ""


def discover(timeout=4):
    msg = (
        "M-SEARCH * HTTP/1.1\r\n"
        "HOST: 239.255.255.250:1900\r\n"
        'MAN: "ssdp:discover"\r\n'
        "MX: 2\r\n"
        "ST: upnp:rootdevice\r\n\r\n"
    ).encode()
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.settimeout(timeout)
    s.sendto(msg, SSDP)
    found = {}
    try:
        while True:
            data, addr = s.recvfrom(65507)
            m = re.search(rb"(?im)^location:\s*(\S+)", data)
            if m:
                found[m.group(1).decode()] = addr[0]
    except socket.timeout:
        pass
    return found


def same_host(url, ip):
    u = urlparse(url)
    return u.scheme == "http" and u.hostname == ip


def find_control(location, ip):
    # The description comes from the network, so we do not pass it to an XML parser: two fields are enough.
    xml = urllib.request.urlopen(location, timeout=5).read(200_000).decode(errors="replace")
    for block in re.findall(r"<service>(.*?)</service>", xml, re.S):
        stype, ctl = field(block, "serviceType").strip(), field(block, "controlURL").strip()
        if stype in SERVICES and ctl:
            url = urljoin(location, ctl)
            return (stype, url) if same_host(url, ip) else (None, None)
    return None, None


def soap(url, svc, action, args):
    body = "".join(f"<{k}>{v}</{k}>" for k, v in args)
    env = (
        '<?xml version="1.0"?>'
        '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" '
        's:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
        f'<s:Body><u:{action} xmlns:u="{svc}">{body}</u:{action}></s:Body></s:Envelope>'
    ).encode()
    req = urllib.request.Request(
        url, env, {"Content-Type": 'text/xml; charset="utf-8"', "SOAPAction": f'"{svc}#{action}"'}
    )
    try:
        return urllib.request.urlopen(req, timeout=5).read().decode(errors="replace")
    except urllib.error.HTTPError as e:  # 500 carries the UPnP error code
        return e.read().decode(errors="replace")


for location, ip in discover().items():
    if not same_host(location, ip):
        continue
    try:
        svc, ctl = find_control(location, ip)
        if not ctl:
            continue
        print(f"Gateway {ip}  {location}")
        skipped = 0
        for i in range(MAX_ENTRIES):
            r = soap(ctl, svc, "GetGenericPortMappingEntry", [("NewPortMappingIndex", i)])
            code = field(r, "errorCode")
            if code == "713":  # end of the table
                break
            if code == "606":  # the gateway does not show this entry, move on
                skipped += 1
                continue
            if not field(r, "NewExternalPort"):  # response with no entry and no UPnP code
                print("  the gateway returned an unexpected response, reading stopped")
                break
            print(
                f"  {field(r, 'NewProtocol')} ext.{field(r, 'NewExternalPort')} -> "
                f"{field(r, 'NewInternalClient')}:{field(r, 'NewInternalPort')}  "
                f"lease={field(r, 'NewLeaseDuration')}s  description={field(r, 'NewPortMappingDescription')!r}"
            )
        if skipped:
            print(f"  skipped entries without read permission: {skipped}")
    except (urllib.error.URLError, OSError) as e:
        print(f"Gateway {ip}: connection error ({e})")

The configuration that closes the path

Step 1 removes the path completely. Steps 2-7 restrict it where UPnP has to run.

  1. Disable UPnP IGD on routers where nothing requires it. Why: without the service there is neither rule injection nor flaws in its implementation. Before disabling it, review the port mapping table in the router panel, and use the script from this article to check what the gateway shows to computers on the network. This tells you which applications will lose their forwards.

  2. Where UPnP is needed, restrict it with access rules. Why: the specification only recommends restrictions, so each vendor sets them differently, and you need to check what a given gateway does. The sample configuration file of miniupnpd, a popular open-source UPnP gateway implementation, contains these settings. The secure_mode option (enabled by default) lets a client map only its own address. The allow and deny rules define the permitted port and address ranges, and the sample file recommends forwarding only ports from 1024 up. The NAT-PMP and PCP protocols are disabled by default.

    secure_mode=yes
    allow 1024-65535 192.168.10.0/24 1024-65535
    deny 0-65535 0.0.0.0/0 0-65535
    enable_pcp_pmp=no

    The final deny rule closes the set, because it rejects everything not allowed earlier.

  3. Drop UDP 1900 traffic from the internet and do not pass the multicast address 239.255.255.250 across segment boundaries. Why: SSDP announcements are meant for discovery within one network, and carrying them between segments exposes devices and opens the way for uncontrolled traffic.

  4. Place cameras, printers, TVs and other UPnP devices in a separate segment with no routing to the user network. Why: an infected device then cannot query or change the rules of the router that serves the user network.

  5. Update router software and replace devices for which the vendor no longer releases patches. Why: flaws such as CVE-2014-8361 work on devices that nobody updates.

  6. Keep browsers up to date. From version 142, Chrome asks the user for permission before a website on the internet sends a request to a device on the local network. According to the documentation, this is meant to protect against CSRF attacks on routers and other devices. Why: the browser stops a website that tries to change router settings on the local network from the internet. The browser permission works alongside disabling UPnP on the router.

  7. Subscribe your network to the free Shadowserver reports. The Open SSDP report lists publicly accessible SSDP services in a given network. Why: it is the simplest way to learn about an internet-exposed device that nobody knew about.

Checklist

  • It is known which routers and gateways on the network support UPnP, and their port mapping tables have been reviewed.
  • UPnP is disabled wherever no service requires it.
  • Where UPnP runs, rules restrict mapping to the client’s own address and to ports from 1024 up.
  • The router drops UDP 1900 traffic and UPnP control requests from the external interface.
  • UPnP devices are in a separate network segment.
  • The router and its software are up to date, and devices without vendor support have been replaced.
  • The intrusion detection system has rules for suspicious characters in the NewInternalClient field and for CALLBACK with an address outside the private network.

Where we help

During penetration testing we check from outside and from internal segments whether routers respond to SSDP and accept control requests. We also read their port mapping tables. The result is a list of devices with remediation priorities. In industrial and building networks we check the same during an OT security assessment, and you can reach us through the contact form.

Technical basis

Topic Where to find it
Formats of M-SEARCH, NOTIFY, 200 OK responses, SUBSCRIBE and SOAP UPnP Device Architecture 2.0, chapters on discovery, control and eventing
Response to the address and port of the request sender, TTL 2 UPnP Device Architecture 2.0, chapters on search response and addressing
Ban on accepting a subscription with an address outside the device’s network segment UPnP Device Architecture 2.0, chapter on subscription
Access policy for actions, lease range, AddPortMapping and GetGenericPortMappingEntry actions WANIPConnection:2 Service
SSDP amplification factor of 30.8 CISA, TA14-017A
CallStranger impact and countermeasures CERT/CC VU#339275, NVD CVE-2020-12695
miniigd vulnerability, score and KEV entry NVD CVE-2014-8361
Rules injected in 45,113 routers Akamai, EternalSilence
Options that restrict mapping miniupnpd sample configuration file

Sources

  1. UPnP Device Architecture 2.0 (version of 17 April 2020), Open Connectivity Foundation (accessed: )
  2. WANIPConnection:2 Service, UPnP Forum (2010) (accessed: )
  3. CISA TA14-017A - UDP-Based Amplification Attacks (accessed: )
  4. CERT/CC VU#339275 - CallStranger (accessed: )
  5. NVD - CVE-2020-12695 (CallStranger) (accessed: )
  6. NVD - CVE-2014-8361 (Realtek SDK, miniigd) (accessed: )
  7. Akamai - UPnProxy - EternalSilence (accessed: )
  8. CallStranger - CVE-2020-12695 vulnerability check (GitHub repository) (accessed: )
  9. miniupnpd - sample configuration file (accessed: )
  10. Chrome - Local Network Access (accessed: )
  11. Shadowserver - Open SSDP report (accessed: )
  12. Shadowserver - report subscription (accessed: )

Need help in this area?

Our experts will help you assess the risk and plan next steps.

Talk to an expert

We'll discuss scope, methodology, and timeline.

Book a call