UPnP lets any device on your Wi-Fi rewrite your firewall without asking. Here's how to read the ledger, catch new holes overnight, and close the door without breaking game night.

Somewhere in your house a game console, a NAS or a two-year-old security camera asked your router to open a port to the internet, and the router said yes with no password, no prompt and no log line you have ever read. Run one command from any laptop on your Wi-Fi and the router will hand you the entire list, every hole, who asked for it and when it expires.

Most people never run that command. After this you'll run it every night without lifting a finger.

The Protocol That Asks Nobody

Universal Plug and Play has a piece called Internet Gateway Device, IGD for short. Any host on your LAN can send your router a small SOAP request that says "forward external port X to me on port Y," and a router with UPnP enabled obliges. There's no authentication step in the protocol. Being on the network is the credential.

The design assumed everything inside your house is friendly. Your house now contains a fridge with a firmware update channel.

Attackers noticed early. Akamai's UPnProxy research found routers that exposed their UPnP control service to the internet itself, letting strangers inject mappings from outside. In its 2022 update, Akamai counted 277,000 vulnerable devices out of 3.5 million potentially vulnerable ones, and 45,113 routers with injected mappings exposing roughly 1.7 million machines behind them on SMB ports 139 and 445. The injected entries carried a description string, "galleta silenciosa," Spanish for silent cookie.

It isn't ancient history. In August 2026 researcher Brian Khan Quintana reported CVE-2026-75501 in Calix GS7 XGS residential routers used by several U.S. ISPs: the UPnP control endpoint answered on the WAN side, so an unauthenticated request could add, list or delete port mappings and open a hole that survived reboots. Calix later said existing network controls in deployed systems prevent the reported attack scenario. Either way, the advice from the researcher was the one this post ends on.

The scary part is less the bug and more the bookkeeping. Your router keeps a ledger of every door it opened. Nobody reads it.

One Command

The miniupnp project ships a client called upnpc that speaks IGD from the client side. Install it and ask your router for its mappings:

$ sudo apt install miniupnpc # dnf install miniupnpc / pacman -S miniupnpc $ upnpc -l 

The tail of the output is the ledger:

ExternalIPAddress = 203.0.113.7 i protocol exPort->inAddr:inPort description remoteHost leaseTime 0 UDP 3074->192.168.1.23:3074 'Xbox' '' 0 1 TCP 32400->192.168.1.40:32400 'Plex Media Server' '' 7200 2 TCP 51413->192.168.1.61:51413 'Transmission at 51413' '' 3600 3 TCP 554->192.168.1.88:554 '' '' 0 

(Synthetic sample. Real output starts with discovery chatter about your gateway; the header and row format match the upnpc source.)

Each row is a live hole in your perimeter. Protocol, the external port the internet can hit, the internal address and port it lands on, the description the requesting device chose for itself, an optional remote-host restriction (almost always empty, meaning anyone), and a lease time in seconds. A lease of 0 means the hole never expires on its own.

If upnpc says no IGD was found, either UPnP is off on your router or your router doesn't speak it. Both are good news, and you can skip to the section on closing things properly.

Read It Like an Auditor

Go row by row and ask four questions.

Where does it point? Every internal address should live inside your LAN. A mapping whose internal address is outside your subnet means your router is forwarding internet traffic to some other network entirely, which is the UPnProxy signature: your router turned into somebody's relay.

What port is it? Game consoles and media servers asking for high ports are normal. Something on your LAN asking the internet to reach port 554 (RTSP, the camera stream), 23 (telnet), 445 (SMB), 3389 (RDP) or 5900 (VNC) deserves a name and an explanation.

Does it expire? A permanent mapping from a device you replaced last year is a hole with nobody behind it, or worse, a hole waiting for whatever DHCP hands that address to next.

Who asked? Empty descriptions are a smell. Cross-check the internal address against your router's DHCP table or ip neigh on any Linux box to put a device name to it.

One more line worth reading before you panic: ExternalIPAddress. If it starts with 100.64 through 100.127, your ISP has you behind carrier-grade NAT, and the mappings on your router stop at your ISP's own NAT. They're still a record of what your devices tried to do, which is useful, but they aren't reachable from the open internet the way the numbers suggest.

That row at index 3, the empty description forwarding 554 forever, is a camera that opened its own stream to the world. Many of them do this out of the box so the phone app works away from home.

portledger.py: A Ledger That Notices

Reading the ledger once is an audit. Reading it every night and diffing is a tripwire. The miniupnpc package also ships Python bindings, so the whole thing is one small script:

#!/usr/bin/env python3 """portledger: ask your router which holes UPnP has punched, and what changed since last time. run: python3 portledger.py nightly: python3 portledger.py --quiet --ntfy https://ntfy.sh/your-random-topic test: python3 portledger.py --fixture mappings.json """ import argparse, ipaddress, json, os, sys, time, urllib.request STATE = os.path.expanduser("~/.portledger.json") RISKY = {21: "ftp", 22: "ssh", 23: "telnet", 80: "http", 139: "smb", 445: "smb", 554: "rtsp/camera", 1900: "ssdp", 3389: "rdp", 5000: "upnp/nas", 5900: "vnc", 8080: "http-alt", 8443: "https-alt", 8291: "winbox", 37777: "dvr"} RED, AMB, DIM, OFF = "\033[1;31m", "\033[1;33m", "\033[2m", "\033[0m" def from_router(): import miniupnpc # pip install miniupnpc u = miniupnpc.UPnP() u.discoverdelay = 2000 if not u.discover(): sys.exit("no UPnP gateway answered. that is good news, or UPnP is off.") u.selectigd() rows, i = [], 0 while i < 1024: m = u.getgenericportmapping(i) # (eport, proto, (ihost, iport), desc, enabled, rhost, lease) if m is None: break eport, proto, (ihost, iport), desc, enabled, rhost, lease = m rows.append({"eport": eport, "proto": proto, "ihost": ihost, "iport": iport, "desc": desc, "enabled": enabled, "rhost": rhost, "lease": lease}) i += 1 return u.lanaddr, u.externalipaddress(), rows def judge(m, lan): why = [] try: if ipaddress.ip_address(m["ihost"]) not in lan: why.append("POINTS OUTSIDE YOUR LAN") # the UPnProxy tell except ValueError: why.append("bad internal address") if m["eport"] in RISKY or m["iport"] in RISKY: why.append(RISKY.get(m["eport"]) or RISKY.get(m["iport"])) if m["lease"] == 0: why.append("never expires") if not m["desc"].strip(): why.append("no description") return why def key(m): return f'{m["proto"]}/{m["eport"]}->{m["ihost"]}:{m["iport"]}' def main(): ap = argparse.ArgumentParser() ap.add_argument("--fixture", help="json file with lanaddr, wan, rows (for testing)") ap.add_argument("--prefix", type=int, default=24, help="LAN prefix length (default /24)") ap.add_argument("--ntfy", help="ntfy topic URL; pinged when a new risky mapping appears") ap.add_argument("--quiet", action="store_true", help="only print changes") a = ap.parse_args() if a.fixture: fx = json.load(open(a.fixture)) lanaddr, wan, rows = fx["lanaddr"], fx["wan"], fx["rows"] else: lanaddr, wan, rows = from_router() lan = ipaddress.ip_network(f"{lanaddr}/{a.prefix}", strict=False) old = json.load(open(STATE)) if os.path.exists(STATE) else {} now = {key(m): m for m in rows} new, gone = sorted(set(now) - set(old)), sorted(set(old) - set(now)) if not a.quiet: print(f"{DIM}gateway says WAN={wan} LAN={lan} mappings={len(rows)}{OFF}") loud = [] for k, m in sorted(now.items(), key=lambda kv: kv[1]["eport"]): why = judge(m, lan) tag = "NEW " if k in new and old else " " if a.quiet and old and not tag.strip(): continue color = RED if why else "" print(f"{color}{tag}{k:<34} {m['desc'][:28]!r:<30} {', '.join(why)}{OFF if color else ''}") if k in new and why: loud.append(f"{k} {m['desc']} ({', '.join(why)})") for k in gone: print(f"{DIM}GONE {k} {old[k]['desc']!r}{OFF}") with open(STATE, "w") as f: json.dump(now, f, indent=1) if loud and a.ntfy: body = "\n".join(loud).encode() req = urllib.request.Request(a.ntfy, data=body, headers={"Title": "portledger", "Priority": "high"}) urllib.request.urlopen(req, timeout=5) if __name__ == "__main__": main() 

Install the bindings with pip install miniupnpc (inside a venv, or with --break-system-packages if you like living that way). The script walks the mapping table by index until the router runs out, flags anything that points outside your LAN, lands on a risky port, never expires or carries no description, and diffs against last night's snapshot.

First run, an ordinary house:

gateway says WAN=203.0.113.7 LAN=192.168.1.0/24 mappings=3 UDP/3074->192.168.1.23:3074 'Xbox' never expires TCP/32400->192.168.1.40:32400 'Plex Media Server' TCP/51413->192.168.1.61:51413 'Transmission at 51413' 

The next morning, with --quiet, you only see what changed:

NEW TCP/554->192.168.1.88:554 '' rtsp/camera, never expires, no description NEW TCP/47622->10.77.4.12:445 'galleta silenciosa' POINTS OUTSIDE YOUR LAN, smb, never expires GONE TCP/51413->192.168.1.61:51413 'Transmission at 51413' 

(Both runs are synthetic, generated from test fixtures. The second line is a staged UPnProxy-style injection so you know what the bad one looks like.)

The torrent client closed its hole when it quit. A camera you plugged in yesterday opened a stream to the world. And something forwarded an external port to an SMB service on a network that isn't yours, which means stop reading and go pull the router's power.

Put it on a schedule:

$ crontab -e 17 3 * * * /usr/bin/python3 /home/you/portledger.py --quiet --ntfy https://ntfy.sh/pick-a-long-random-topic >> /home/you/portledger.log 2>&1 

Any always-on box on the LAN works. Public ntfy topics are readable by anyone who guesses the name, so make yours long and random.

Close It Without Breaking Game Night

Here's the take: turn UPnP off, and replace it with exactly the forwards you can name.

Every guide that tells you to disable UPnP gets the same reply in the comments, "my Xbox says Strict NAT now." That's true and fixable. Reserve a DHCP address for the console, then add a static forward for its ports by hand. Microsoft and Sony both publish the port lists for their networks; for Xbox the headline one is UDP 3074, the same port you just watched it request. Now the hole exists because you put it there, and it points at one address you chose.

For everything you reach from outside, your NAS, your Home Assistant, your homelab, stop punching holes entirely. A WireGuard tunnel gives you the whole LAN through one authenticated UDP port, and a mesh VPN like Tailscale needs zero inbound ports. If you want a dedicated box for that, SPECTER BOX: Portable Remote-Administration Lab ($25) is an interactive build manual for exactly this shape: a Pi Zero 2 W with an ESP32-C3 watchdog and recovery path, encrypted access to systems you own, and authorized administration workflows, so remote access becomes one reviewed tunnel instead of a dozen anonymous forwards.

If you truly need UPnP for one stubborn device, a router running OpenWrt lets you keep the convenience and lose the blank check. Its miniupnpd config takes permission rules evaluated in order, so you can allow one device and deny everyone else:

# /etc/config/upnpd config perm_rule option action 'allow' option ext_ports '3074' option int_addr '192.168.1.23/32' option int_ports '3074' option comment 'Xbox only' config perm_rule option action 'deny' option ext_ports '0-65535' option int_addr '0.0.0.0/0' option int_ports '0-65535' option comment 'everyone else' 

Then service miniupnpd restart. The camera can ask all night. The answer is no.

A GL.iNet GL-MT6000 Flint 2 is the easy on-ramp here because its firmware is built on OpenWrt and ships with the LuCI interface a click away, so the rules above apply without flashing anything. Check that the listing is the MT6000 and not an older Flint model if you care about Wi-Fi 6 and the 2.5 GbE ports.

If you'd rather run a real firewall distribution, a Protectli Vault FW4C runs OPNsense or pfSense on four Intel 2.5 GbE ports, and both have UPnP services with per-address access control lists. It's more box than most apartments need. It's also the last router you'll ever have to wonder about.

Watch the Doors You Closed

Turning UPnP off doesn't make your devices stop asking. They keep shouting SSDP discovery packets at the multicast address 239.255.255.250 on port 1900, looking for a gateway that will say yes. Those shouts are the most honest inventory of "things in my house that want the internet to reach them" you'll ever get.

A small sensor sees them. A Raspberry Pi 5 on a mirrored switch port running Suricata will log every one, along with everything else your network does that you never agreed to. The 4 GB model is enough for a home sensor, and a proper USB-C supply matters more than the RAM.

The $20 SOC: Build a Tiny Defensive Network Monitor ($20) is the build for that sensor. It covers Raspberry Pi placement, deciding what traffic and logs the sensor can legitimately observe, Suricata, Zeek and Elastic, logging, and validating the whole thing in a home lab you own. The free starter for it lives on GitHub at numbpill3d/20-soc-lite, a Suricata triage script you point at the event log:

$ ./triage.sh /var/log/suricata/eve.json 

Grep the result for 1900 and you'll find the camera still begging. Let it beg. Run upnpc -l one more time and read the empty ledger.