# DNS rebinding in --inspect (insufficient fix of CVE-2018-7160)

Node's --inspect DNS-rebinding whitelist included 'localhost6', which resolves via DNS when absent from hosts, letting an attacker rebind to 127.0.0.1 and reach the debugger for RCE.

- Payout: $500
- Severity: high
- Program: Node.js
- Found by: v6ak
- Disclosed: 2021-02-23
- CVE: CVE-2021-22884, CVE-2018-7160
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/1069487
- Library page: https://bugbountylibrary.com/r/h1%3A1069487
- Tags: area:oss domain:oss impact:internal-access impact:rce kind:bounty platform:hackerone sev:high tech:nodejs technique:incomplete-fix technique:recon vuln:access-control vuln:rce

**Target:** Node.js inspector/debugger (--inspect) host whitelist in inspector_socket.cc
**Root cause:** The rebinding-protection whitelist trusted the hostname 'localhost6', which is not guaranteed in /etc/hosts and thus resolves over DNS, so an attacker-controlled DNS answer can point it at arbitrary IPs and later rebind to 127.0.0.1.
**Steps:**
1. Victim runs `node --inspect` (debugger on 9229) and has no `localhost6` entry in /etc/hosts.
2. Victim visits attacker page; page opens `http://localhost6:9229`.
3. DNS resolves `localhost6` to attacker IP (short TTL); attacker page served from that IP loads `http://localhost6:9229/json`.
4. TTL expires; DNS now answers `localhost6` -> `127.0.0.1`; the attacker-hosted page fetches `http://localhost6:9229/json` from loopback, leaking `webSocketDebuggerUrl`.
5. Attacker connects to the WebSocket debugger URL (not bound by SOP) and executes code in the Node process.
**How found:** Noticed the rebinding whitelist contained 'localhost6', reasoned it is not universally present in hosts files (absent in node:latest Docker image, Windows 10, no RFC), so it falls back to DNS resolution and can be attacker-controlled, re-enabling CVE-2018-7160.
**Exploitation:** Attacker controls/spoofs DNS for the victim, serves a page on the rebound IP, uses short TTL (and RST tricks) to force rebinding to 127.0.0.1, reads /json to obtain webSocketDebuggerUrl, then drives the inspector WebSocket to run arbitrary code in the Node instance.
**Escalation:** Debugger access yields arbitrary code execution in the Node.js process.
**Insight:** When auditing rebinding/host allowlists, check every entry against whether it is guaranteed to resolve locally; any hostname that can fall through to DNS (like localhost6, or IPv6 aliases) is a bypass primitive.

## Write-ups of the same bug (oldest first)
- 2021-02-23: [DNS rebinding in --inspect (insufficient fix of CVE-2018-7160)](https://bugbountylibrary.com/r/h1%3A1069487) — v6ak (this one)
- 2023-01-12: [DNS rebinding in --inspect (insufficient fix of CVE-2022-32212 affecting macOS devices)](https://bugbountylibrary.com/r/h1%3A1714979) — zeyu2001

