All posts Security

NDCLI 1.50.3 Ties the WebAdmin Tunnel of device connect to Your Browser

SECURITY 4 MIN READ NETDEFENSE TEAM

NDCLI 1.50.2 made the WebAdmin tunnel of ndcli device connect check every request before it goes to the firewall. NDCLI 1.50.3 goes a step further: the tunnel now answers only the browser that opened its link. These changes came out of our own review of 1.50.2. Upgrade when you can.

TL;DR

  • device connect prints the WebAdmin link as http://127.0.0.1:<port>/?ndcli=<token>. Opening it once gives your browser a cookie for this session, and the tunnel refuses any request without that cookie.
  • The link works in the first browser that opens it. Another browser needs a new device connect.
  • Scripts that call the tunnel need a cookie jar, and an Origin header on requests other than GET or HEAD.
  • Upgrade NDCLI to 1.50.3 with Homebrew, Scoop or the release download.

What 1.50.2 left open

The 1.50.2 checks decide where a request comes from by what the browser says about it: the Host, the Origin and the fetch metadata headers. Two things fall outside them:

  • Another user on the same machine. The tunnel listens on 127.0.0.1, and every local user can reach that address. A program of theirs that connects to the port sends what it likes, so the browser checks don’t apply to it.
  • Browsers that send no fetch metadata. Older browsers don’t send Sec-Fetch-Site, so the tunnel had less to judge a request by.

The link device connect prints now carries a one-time token. The tunnel answers that link’s first request itself and never sends it to the firewall: it sets a cookie for this session and moves on to the WebAdmin’s start page, so the token leaves the address bar. The cookie is HttpOnly and SameSite=Strict, and a request without it never reaches the firewall.

  • Another local user’s program holds neither the token nor the cookie, so its requests are refused.
  • A page from another site doesn’t get the cookie: with SameSite=Strict, the browser leaves it off requests that other sites start. This holds in browsers that send no fetch metadata too, as long as they support SameSite cookies.
  • The used link is worth nothing. The token and the cookie are separate random values, so a link copied out of the terminal after use opens nothing.

The cookie is not a full boundary against another user on the same machine. Cookies don’t tell ports apart, so a local user who gets your browser to open a page they serve on 127.0.0.1 can reach the cookie. On a shared machine, close the tunnel when you’re done with it.

What you'll notice

Open the link that device connect prints, in the browser you’ll use. http://localhost:<port> answers with a refusal that names the 127.0.0.1 link. A second browser, or the same one after its cookies are cleared, needs a new device connect.

Scripts

A script that calls the tunnel opens the link once with a private cookie jar, then sends the jar with every request. The URL is the WebAdmin tunnel: line that device connect prints on stderr when its output isn’t a terminal. The jar then holds the session’s credential, so keep it private (mktemp makes it readable only by you), and remove it when you’re done:

script bash
$ jar=$(mktemp)
$ curl -sc "$jar" "$URL" >/dev/null
$ curl -sb "$jar" http://127.0.0.1:<port>/
$ rm -f "$jar"

A request other than GET or HEAD that has no Origin, no Referer and no fetch metadata now gets 403 Forbidden. A browser sends one of them with such a request, so in practice this affects only scripts: send Origin: http://127.0.0.1:<port>.

Also in 1.50.3

  • The tunnel’s own answers, its refusals and the page that moves on to the WebAdmin, are marked no-store, so the browser doesn’t keep them.
  • A request that names a full URL as its target must carry the tunnel’s own Host header as well.
  • The page that moves on to the WebAdmin can’t send the browser round in a loop.

Upgrade to 1.50.3

macOS / Linux (Homebrew) bash
$ brew upgrade ndcli
Windows (Scoop) powershell
$ scoop update ndcli

Or download the binary from the NDCLI 1.50.3 release, as in Installation. Run ndcli version to check you have it. A tunnel that is already open keeps the old behaviour until you close it, so restart any running device connect sessions after the upgrade.

The device connect reference has the command’s flags, and Remote Access covers remote sessions in general.

Related reading

Security Security Fixes From Our November Security Review: Agent 1.33.0 and ndcli 1.52.0
Feature NDCLI 1.51.0 Opens the WebAdmin of device connect in Your Browser
Guide How to Reach an OPNsense Firewall Behind CGNAT Without Opening a Port

Enjoyed this post? Explore more in the documentation.