Research/opnsense-captive-lastseen-roam
0-dayNo CVEHighPublic

OPNsense captive-portal last_seen IPv4 roam

OPNsense core 26.7.6 captive-portal roaming still inherits a session for the newest hostwatch IPv4 on a MAC, plus every IPv6. GHSA-864r stopped add-every-IPv4. The leftover IPv4 is ORDER BY last_seen DESC. Labbed.

Name
OPNsense captive-portal last_seen IPv4 roam
Type
0-day analysis
CVE
n/a
CVE Risk
high
Disclosure Status
public
Vendor
OPNsense (Deciso B.V.)
Affected
OPNsense core 26.7.6 (a842fe48) captive portal roaming. Hostwatch and roaming default on. Leftover of the GHSA-864r 26.7.3 filter. L2-adjacent unauth host on a captive-portal zone.
Published
13 Oct 2026
Updated
13 Oct 2026
Tags
0-day, opnsense, captive-portal, roaming, cwe-345, cwe-863

They kept one IPv4. They kept the wrong one.

I am @abraxas_null. The proof of concept is on GitHub: abraxas/opnsense-captive-lastseen-roam (loopback client). The lab stack is lab/: Dockerfile, docker-compose.yml, run.sh, poc.py. Authorized lab only. It talks to loopback.

This is OPNsense core 26.7.6 "Xenial Xenops" (a842fe48c21288d11a422cb944678e8eb308becf). No CVE yet. CWE-345 / CWE-863. 7.4 High (CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:N). Remote. Network-access bypass. L2-adjacent unauth host on a captive-portal zone. Roaming on.

GHSA-864r (Moderate, 26.7.3) was "add every IPv4 observed for a MAC." The fix keeps one IPv4 plus all IPv6. That IPv4 is list_hosts.py ORDER BY last_seen DESC. Primary IP is then assigned from unfiltered current_ips[0]. Gratuitous ARP attacker_IP is-at victim_MAC updates last_seen. After 26.7.3 that IPv4 is no longer one of many. It is the IPv4 the filter keeps if it is newer than the victim's own ARP. IPv6 NDP was never capped.

Vendor rated the sibling Moderate. Unauth portal IP takeover is High on this bar.

Why OPNsense, and this pin

I wanted a firewall people put in front of a hotel, a campus, a guest SSID. Captive portal is the unauth surface on that zone. WebGUI is LAN by default. WAN GUI is off unless someone turns it on. configd is root. After the 2026 public wave, mwexec($cmd) is gone, CSRF GET mutators are POST-gated, and the named GHSAs are closed on this peel.

I pinned 26.7.6, not master, not 27.1.a ALPHA, not EOL 26.1. Annotated tag 216a9748 peels to commit a842fe48 (2026-10-08). Plugins and the FreeBSD tree are out of pin. I only wanted Critical or High. Remote preferred. Medium stays on the floor unless it chains.

Twenty-eight hunts. Auth and lockout, ACL and CSRF, mwexec and configd, captive portal, API keys, XMLRPC HA, firmware, config XPath, UidField, OpenVPN, IPsec, DHCP, Unbound, Suricata, legacy src/www/, NTP GPS, diagnostics, backup, GeoIP, templates, WireGuard, LDAP, wizard, script wrappers, lighttpd, XSS-to-root, ZFS and tunables.

The skip list is half the hunt

The 2026 public wave is closed on this peel: CVE-2026-34578, 44193, 44194, 44195, 45158, 53581, 57155, and the 26.7.x GHSAs. Hunt only a new unmatched walk of a public fix.

Captive portal already had a named Moderate. GHSA-864r-q4j5-5mjq: roaming forged ARP, patched 26.7.3 / 26.4.2p1. Original walk: every IPv4 for the MAC joined cp_client_ips and __captiveportal_zone_N. I do not re-file "add all IPv4s."

Documented portal auth stays documented. AccessController::beforeExecuteRoute skips WebGUI session and CSRF so the zone lighttpd can POST /api/captiveportal/access/logon. Empty authservers is anonymous logon of that client's IP. LogicalTrust 2023 zip-slip still has the realpath gate. Default vouchers are random_int 8+10. Portal splash XSS sits on a different origin than the WebGUI.

Surfaces that returned nothing

X-Forwarded-For looked like a gift. getClientIp() trusts the entire XFF value when REMOTE_ADDR's first dotted octet is 127. Zone lighttpd proxies to 127.0.0.1:8999, so that branch is live. mod_proxy appends the connecting address. A client X-Forwarded-For: 0.0.0.0/0 becomes comma-junk, not a clean pf CIDR. extforward.headers = ("X-Real-Ip") has no forwarder. Empty forwarder is untrusted. Not High.

SessionController will POST an ip with only striptags into captiveportal allow. That is a logged-in page-services-captiveportal action, same operator who can set allowedAddresses. Not unauth.

Voucher brute without a lockout is still ~80^18 plus a 2s fail delay. Template overlay cannot escape /var/captiveportal/zoneN/htdocs/. MAC whitelist is a documented bypass. I folded extra IPs on a whitelisted MAC into this leftover instead of minting a second id.

The dedicated portal hunt almost closed as "GHSA-864r is the story." Then I read the filter.

How 26.7.3 kept one IPv4

Python
def _filter_addresses(self, addresses, roaming):
    if not addresses:
        return []

    if not roaming:
        return [addresses[0]]

    result = []
    first_ipv4_found = False

    for addr in addresses:
        ip = ipaddress.ip_address(addr)

        if ip.version == 4:
            if not first_ipv4_found:
                result.append(addr)
                first_ipv4_found = True
        else:
            result.append(addr)

    return result

addresses is not a stable lease. ARP.reload loads list_hosts.py --last-seen-window 86400 -v. With hostwatch on, that query is ORDER BY last_seen DESC. First insertion into _table is the newest observation. get_all_addresses_by_mac walks _table.items(), so the first IPv4 for a MAC is whichever hostwatch row for that MAC is newest.

The original GHSA packet (gratuitous ARP attacker_IP is-at victim_MAC) is exactly what updates last_seen for attacker_IP under the victim MAC.

Then the primary-IP rewrite uses the unfiltered first row, not the filtered IPv4:

Python
current_ips = self.arp.get_all_addresses_by_mac(db_client['macAddress'])
addresses = self._filter_addresses(current_ips, allow_roaming)
if len(addresses) > 0 and db_client['ipAddress'] != addresses[0]:
    self.db.update_client_ip(zoneid, db_client['sessionId'], current_ips[0])
    db_client['ipAddress'] = current_ips[0]

Condition compares addresses[0] (filtered). Assignment writes current_ips[0] (raw last_seen winner). Roaming unions that primary with the filtered set and _add_client feeds the whole set to PF.add_to_table. Addresses no longer in list_session_ips are deleted from pf, so the victim IPv4 can drop off the table.

IPv6 is still "all of them." SLAAC privacy addresses need several. A forged NA that hostwatch stores under the victim MAC still extends the session to the attacker's IPv6. Same unauthenticated observation channel.

MAC-change drop keys on the primary IP's ARP. The GHSA packet is attacker_IP is-at victim_MAC, so the victim primary still looks like the victim MAC and the session is not reset. That is why this is not "the attacker must use the victim MAC on the wire," which the advisory already distinguished.

Roaming defaults on. Hostwatch defaults on. The leftover is default for a zone that exists.

Wrong turns, in order

I treated GHSA-864r as fully closed because the changelog said one IPv4. One IPv4 is a policy. Newest IPv4 is a different policy.

I expected first_ipv4_found to mean first lease. It means first in the last_seen list.

I expected IPv6 to be capped the same way. It is not. The lab kept both 2001:db8::10 and 2001:db8::99.

I spent a day on XFF. The proxy appends. That is the right hardening for a different bug.

I almost scored this Moderate to match the sibling. Unauth network-access bypass on a portal zone is High here.

The lab

Python gadget of the pinned _filter_addresses / list_hosts.py / arp.py lines. Seed a hostwatch sqlite with the victim lease older and a forged GARP newer, same MAC. Run pin list_hosts.py. Load pin ARP.get_all_addresses_by_mac. Call pin _filter_addresses with roaming on and off. Oracle is a witness file, not live pf.

Loopback wait 127.0.0.1:18820. Compose project opnsense-captive-lastseen-roam. Full OPNsense FreeBSD VM is out of this lab pass. Live GARP on the wire and live zone-table pass stay inferred. No exploit payloads.

Last run:

Plain text
SUCCESS opnsense-captive-lastseen-roam attacker-ipv4-kept=192.0.2.99 victim-ipv4-dropped=yes roaming=1 OPNSENSE-CAPTIVE-LASTSEEN-ROAM-WITNESS

Stack tears down on EXIT.

What an attacker can do

Method Sink Privilege
Newest hostwatch IPv4 for a MAC with roaming=1 pin _filter_addresses / list_hosts.py ORDER BY last_seen DESC; primary from unfiltered current_ips[0] Integrity (lab-proven): attacker 192.0.2.99 kept, victim 192.0.2.10 dropped, primary=192.0.2.99. Lab: attacker-ipv4-kept=192.0.2.99 victim-ipv4-dropped=yes roaming=1.
Same MAC, roaming=0 _filter_addresses returns [addresses[0]] Negative (lab-proven): first IPv4 192.0.2.10 kept.
IPv6 on the same MAC, roaming=1 _filter_addresses keeps every non-v4 Integrity (lab-proven): all IPv6 kept (2001:db8::10 and 2001:db8::99).
Forged GARP / NDP that hostwatch stores under the victim MAC live PF.add_to_table / IPFW.add_accounting on __captiveportal_zone_N Integrity (inferred): attacker source IP matches the portal pass table. Session username and quota stay the victim's. Live GARP on the wire and live zone-table pass are not run in this gadget.
Same table add ipfw accounting rule number per session Integrity (inferred): attacker bytes count on the victim session.
Victim IPv4 no longer first _remove_client / pf delete of addresses not in list_session_ips Availability (inferred): victim IPv4 can drop off the zone table while the attacker IPv4 stays.

Lab-proven vs inferred: last_seen IPv4 keep/drop, roaming=0 first-IP, and IPv6-all are lab-proven. Forged GARP on the wire, live pf/ipfw pass, and accounting smear are inferred from the pin control flow.

Requires: L2-adjacent unauth host on a captive-portal zone. Roaming on (default). Hostwatch on (default). One already-authorized session on that zone. Unauth HTTP on the zone is not required for the leftover. AccessController logon is how the victim got into the table. The attacker only needs hostwatch to believe a new IP belongs to that MAC.

Adjacent surface that stays closed

Surface Lab
GHSA-864r add-every-IPv4 closed on 26.7.3; this leftover is the last_seen IPv4 plus all IPv6
roaming=0 first IPv4 kept; attacker IPv4 not selected
XFF / X-Real-Ip spoof of a different logon IP zone proxy appends; not a clean pf CIDR
Unauth logon of the caller IP documented portal login of getClientIp()
Voucher brute on default 8+10 CSPRNG not this leftover
Template zip-slip realpath plus admin upload
Portal splash XSS to WebGUI origin different port / chroot
WAN-unauth L2-adjacent on the zone
WebGUI / root / voucher mint stays closed

No unauth WebGUI. No root. No WAN skip of the portal. SessionController connect-any-IP stays on the portal admin ACL.

The fix

Pick the IPv4 the session already authorized, not the newest hostwatch row for that MAC. Cap IPv6 the same way, or require NDP that the kernel still holds. Do not assign primary from unfiltered current_ips[0] when the filter already chose a different address. Treat a GARP that only updates last_seen as untrusted observation, which is the GHSA-864r invariant.

Replay:

Plain text
cd lab
./run.sh

Loopback wait 127.0.0.1:18820. Witness OPNSENSE-CAPTIVE-LASTSEEN-ROAM-WITNESS.

References

Abraxas Labs https://abraxaslabs.tech https://github.com/abraxas https://x.com/abraxas_null (@abraxas_null) abraxas.null@proton.me