Skip to content

Plain http to a remote farm by explicit opt-in #1834

Done
1 of 1 issue completed
Done

Description

@V3RON

Request: #1372

Problem

simlock tunnel takes only https://, or http:// to loopback. A gateway reached over Tailscale at http://100.x.y.z:4700 is refused, even though Tailscale already encrypts the link and the rest of the CLI and the console use that URL. To make it work the reporter ran a small TCP relay from 127.0.0.1:4700 to the Tailscale address, and pointed SIMLOCK_URL at the relay.

The same rule guards every way a caller reaches a farm: every CLI command with --url, simlock tunnel, simlock files, simlock mcp, and the Node clients' url. So a farm on a private network with no TLS in front of it cannot be used from another machine at all, unless the caller builds a relay.

Who it is for

Someone whose gateway or worker runs on another Mac in a tailnet, a VPN or a home network, with no TLS proxy in front of it, and who wants to lease and tunnel from their own machine or a script.

Outcome

The caller says once, on purpose, that plain http is fine, and every remote command and Node client then reaches http://<any host>. Without that, the refusal says how to allow it. Nothing decides on its own which networks are safe.

How it works for the user

flowchart TD
  A["simlock … --url http://100.75.181.35:4700"] --> B{"https, or http to 127.0.0.1, [::1], localhost?"}
  B -- yes --> C[connects, as today]
  B -- no --> D{"--allow-insecure-http, or SIMLOCK_ALLOW_INSECURE_HTTP=1?"}
  D -- yes --> C
  D -- no --> E["exit 2: the refusal names the flag and the variable"]
Loading

Before:

$ simlock tunnel forward 8081 --url http://100.75.181.35:4700
{"error":{"code":"USAGE","message":"--url must be https://, or http:// only for 127.0.0.1, [::1] or localhost"}}

After, without the opt-in:

$ simlock tunnel forward 8081 --url http://100.75.181.35:4700
{"error":{"code":"USAGE","message":"--url must be https://, or http:// only for 127.0.0.1, [::1] or localhost; to connect over plain http anyway (the token is sent unencrypted), pass --allow-insecure-http or set SIMLOCK_ALLOW_INSECURE_HTTP=1"}}

After, with it:

$ simlock tunnel forward 8081 --url http://100.75.181.35:4700 --allow-insecure-http
… the tunnel opens, as with an https URL

$ export SIMLOCK_URL=http://100.75.181.35:4700 SIMLOCK_TOKEN=slk_… SIMLOCK_ALLOW_INSECURE_HTTP=1
$ simlock lease --platform ios
… leases on the farm, as with an https URL

A Node program:

const client = await connectSimlock({
  url: "http://100.75.181.35:4700",
  token: process.env.SIMLOCK_TOKEN,
  allowInsecureHttp: true,
});

Examples

Today: checkedFarmUrl run on main (200afe5). "refused" is the scheme refusal; after, without the opt-in, it carries the new hint (B1).

--url Today After, no opt-in After, with the opt-in
https://gw.example.com accepted accepted accepted
http://127.0.0.1:4700 accepted accepted accepted
http://localhost:4700 accepted accepted accepted
http://[::1]:4700 accepted accepted accepted
http://127.0.0.2:4700 refused refused accepted
http://100.75.181.35:4700 (Tailscale) refused refused accepted
http://mac-studio.tail1234.ts.net:4700 refused refused accepted
http://192.168.1.20:4700 refused refused accepted
http://gw.example.com refused refused accepted
http://GW.example.com:4700/ refused refused accepted as http://GW.example.com:4700
http://gw.example.com/v1 refused (scheme) refused (scheme) refused: origin only, no path
ws://gw.example.com refused refused refused, same words as without the opt-in
ftp://gw.example.com refused refused refused, same words
gw.example.com:4700 (no scheme) refused refused refused, same words
SIMLOCK_ALLOW_INSECURE_HTTP (with an http --url to a remote host) After
unset refused, with the hint
empty refused, with the hint (empty counts as unset)
1 accepted
true, yes, 0 exit 2: SIMLOCK_ALLOW_INSECURE_HTTP must be 1, or unset

What could go wrong

  • The token travels unencrypted. On a network that is not encrypted, anyone on the path can read it and use the farm. The user chose this, and the refusal says so before they do.
  • The variable left set in a shell lets a later, mistyped http:// URL through without a word. Likely now and then; the cost is the same as above.
  • A command that reaches the farm in two steps (connect, then name the farm in a reconnect notice) checks the URL twice; if only one step learns the opt-in, the command fails after it connected. The tests cover each command path.

Words used

  • farm URL: the address of a worker or gateway on another machine, given by --url, SIMLOCK_URL, or a Node client's url, e.g. https://simlock.example.com.
  • loopback: an address that never leaves this machine: 127.0.0.1, [::1] or localhost.
  • opt-in: the flag --allow-insecure-http, the variable SIMLOCK_ALLOW_INSECURE_HTTP=1, or the Node option allowInsecureHttp: true.
  • origin: the scheme, host and port of a URL, with no path, e.g. http://100.75.181.35:4700.

Non-goals

  • No address ranges or names are trusted on their own: Tailscale (100.64.0.0/10, *.ts.net) and private ranges get no special case.
  • No allow list of hosts: the opt-in covers whatever host the URL names.
  • No warning line when the opt-in is used.
  • No change to @simlock/e2e, which already takes http:// to any host.
  • No change to other URLs with a loopback-only http rule: the worker's uplink to its gateway, alert destinations, http.proxyAuth.jwksUrl.
  • No TLS setup help.

Completion conditions

  • simlock whoami --url http://<non-loopback host> --allow-insecure-http and the same with SIMLOCK_ALLOW_INSECURE_HTTP=1 reach that farm; simlock tunnel, simlock files, simlock lease and simlock mcp do too.
  • Without the opt-in, the same commands exit 2 with a message that names --allow-insecure-http and SIMLOCK_ALLOW_INSECURE_HTTP=1.
  • connectSimlock and connectSimlockAdmin with allowInsecureHttp: true reach an http:// farm; without it they throw a TypeError that names allowInsecureHttp.
  • The CLI reference and the Node client pages describe the opt-in.

Open questions

Decisions

  • No ADR: ADR 0081 §3 keeps one URL rule for every frontend, "the one simlock tunnel has". This feature changes that rule in its one place (checkedFarmUrl), so every frontend still shares it.
  • Decided by the maintainer (comment, 2026-11-24): an explicit opt-in, a flag plus a matching variable or option, allows plain http to a remote farm URL; the refusal names it; nothing guesses which networks are safe.
  • Decided in the session: the flag is --allow-insecure-http, a global flag with no value, accepted anywhere on the command line like --local, because the maintainer named a flag that takes no host and the URL already names it.
  • Decided in the session: the variable is SIMLOCK_ALLOW_INSECURE_HTTP, 1 allows, empty is unset, any other value exits 2 naming the variable, because a strict value catches =0 meant as "off", as SIMLOCK_RUN refuses a bad value.
  • Decided in the session: the "config key" is the Node clients' allowInsecureHttp option, and there is no key in config.json, because that file is the daemon's: a remote command reads no config, and config set is refused in remote mode.
  • Decided in the session: the opt-in, flag or variable, is read only when a farm URL is checked; a command that checks no farm URL ignores it and never refuses it, because it may be left in a shell, like SIMLOCK_URL. A bad variable value is refused only then too. simlock tunnel checks SIMLOCK_URL even with --local or --gateway, so the opt-in applies to it there too.
  • Decided in the session: allowInsecureHttp without url is ignored, as token without url is today; a value other than true or false throws a TypeError, as every other bad option does.
  • Decided in the session: the opt-in only widens which hosts take http://; other schemes, a path, and the 2048-character limit are refused as today.
  • Decided in the session: the refusal says the token is sent unencrypted, because that is the cost the user accepts.
  • Decided in the session: no warning line when the opt-in is used, because opting in is the acknowledgement, and a script would print it on every command.

Behaviours

Id Behaviour (invoker, action, what it sees) Seam Cases Task
B1 A CLI user names an http:// farm URL to a non-loopback host with no opt-in: the command exits 2 with USAGE and I2's refusal, before it connects. runCli with a faked environment (fake WebSocket and HTTP ports) whoami --url http://100.75.181.35:4700; the same URL from SIMLOCK_URL; tunnel forward 8081; files list; mcp; SIMLOCK_ALLOW_INSECURE_HTTP="" → refused; https:// and http://127.0.0.1:4700 with no opt-in → no refusal #1839
B2 With --allow-insecure-http anywhere on the command line, or SIMLOCK_ALLOW_INSECURE_HTTP=1, the same command reaches the farm: the session socket opens at ws://<host:port>/v1/session, a tunnel at ws://<host:port>/v1/leases/<id>/tunnel, files calls http://<host:port>/v1/…. runCli with a faked environment; runMcpStdio's remote input for mcp whoami with the flag before the command; with the flag after it; with the variable; lease (connect, then its reconnect notice names the farm, X4); tunnel forward 8081; files list; mcp (the farm connect of a tool call gets the opt-in, X6) #1839
B3 The opt-in changes nothing else. runCli with a faked environment --allow-insecure-http with ws://, ftp://, no scheme → the scheme refusal without the hint; with http://gw.example.com/v1 → the origin refusal; a 2049-character http:// URL → refused; --allow-insecure-http=1 → exit 2 --allow-insecure-http takes no value; the flag with --local and no URL → the command runs locally; SIMLOCK_ALLOW_INSECURE_HTTP=true with an http remote URL → exit 2 with I3's message; the same value with no farm URL → the local command runs; SIMLOCK_URL=http://100.75.181.35:4700 with SIMLOCK_ALLOW_INSECURE_HTTP=1 and --local: tunnel forward 8081 reaches the farm, whoami runs locally; the same with SIMLOCK_ALLOW_INSECURE_HTTP=true: tunnel exits 2 with I3's message, whoami runs locally #1839
B4 A Node program calls connectSimlock or connectSimlockAdmin with an http:// non-loopback url: without allowInsecureHttp: true it throws I4's TypeError before anything is sent; with it, it connects to ws://<host:port>/v1/session. connectSimlock (src/client/index.ts) and connectSimlockAdmin (src/admin/index.ts) with a fake webSocket connector client: no option → TypeError; false → TypeError; true → connects; admin: true → connects; allowInsecureHttp: "yes" → TypeError `allowInsecureHttp` must be true or false; allowInsecureHttp: true with endpoint and no url → local connect as today; true with ws:// → the scheme TypeError #1839
B5 The website describes the opt-in. website pages reference/cli.mdx: a global flag row for --allow-insecure-http, the --url rows (global and tunnel) name it, a SIMLOCK_ALLOW_INSECURE_HTTP row in the environment table; reference/node-client.mdx: an allowInsecureHttp row, the url row names it; using-devices/node-client.mdx: the url line names it; the CLI's --help text names the flag #1839

Stored state

none

Interfaces

Id What Shape and bounds Errors and limits Where Task Used by
I1 The farm URL rule: checkedFarmUrl gains the opt-in and the caller's own hint checkedFarmUrl(text, name, insecure: { allowed: boolean; hint: string }): with allowed, http: to any host passes the scheme step; the path, query, fragment and length steps are unchanged The scheme refusal, when http: was refused only for its host: <name> must be https://, or http:// only for 127.0.0.1, [::1] or localhost; to connect over plain http anyway (the token is sent unencrypted), <hint>; any other scheme refusal keeps today's words with no hint src/simlock-client/farm-url.ts #1839 —
I2 CLI opt-in: global flag --allow-insecure-http (no value) and the variable SIMLOCK_ALLOW_INSECURE_HTTP; the router carries the flag (boolean) and the variable's raw value (string or undefined), unjudged, to every farm URL check (RemoteFarm, CommandContext for tunnel); the CLI wrapper around I1 judges them there Flag present, or variable exactly 1 → allowed; variable empty or unset → not I1's refusal with hint pass --allow-insecure-http or set SIMLOCK_ALLOW_INSECURE_HTTP=1, exit 2 USAGE; --allow-insecure-http takes no value for --allow-insecure-http=…, exit 2 src/cli/index.ts, src/cli/environment.ts, src/cli/types.ts, src/cli/tree.ts #1839 —
I3 A bad SIMLOCK_ALLOW_INSECURE_HTTP Any value but 1 or empty, judged only by a farm URL check, before the URL itself SIMLOCK_ALLOW_INSECURE_HTTP must be 1, or unset, exit 2 USAGE src/cli/connect.ts (checkedFarm, and the check tunnel calls) #1839 —
I4 Node option allowInsecureHttp on ConnectSimlockOptions and ConnectSimlockAdminOptions Optional boolean, default false; read only with url I1's refusal as a TypeError, name `url`, hint set `allowInsecureHttp: true` ; a non-boolean → TypeError `allowInsecureHttp` must be true or false src/simlock-client/remote-connector.ts (RemoteConnectInput), src/client/index.ts, src/admin/index.ts #1839 —
I5 simlock mcp's farm input carries the opt-in to its farm connect remote: { url; token; allowInsecureHttp: boolean } — src/mcp/main.ts:60,176, src/mcp/connect.ts:158 #1839 —

Existing code

Commit 200afe5.

Searches: checkedFarmUrl in src (5 non-test call sites: connect.ts, tunnel.ts, lease.ts, remote-connector.ts, its definition), remoteConnectOptions (3: client, admin, its definition), checkedFarm( (3: connect.ts, mcp.ts, files.ts), SIMLOCK_URL in src/cli non-test (5), only for 127.0.0.1 in website/src/content/docs (3 pages), http(s) URL in packages/e2e/src (1).

Id Code (path:line) Today With this feature Handled by
X1 src/simlock-client/farm-url.ts:14-35 checkedFarmUrl https:, or http: with a host in LOOPBACK_HOSTS; the scheme is judged before the origin Takes the opt-in and hint (I1) B1, B3, I1
X2 src/cli/connect.ts:41-55 checkedFarm Checks farm.url as --url; used by connectFarm (:58-71), commands/mcp.ts:25, commands/files.ts:53 Passes RemoteFarm's opt-in; its result carries it on to mcp B1, B2, I2
X3 src/cli/connect.ts:58-71 connectFarm → connectSimlockAdmin → remoteConnectOptions (src/simlock-client/remote-connector.ts:61) The typed client checks the URL a second time connectFarm passes allowInsecureHttp, or every command but tunnel and files fails after checkedFarm passed B2, I4
X4 src/cli/commands/lease.ts:147-154 Checks environment.remote.url again after the connect, for the reconnect notice Passes the opt-in, or lease throws after connecting B2
X5 src/cli/commands/tunnel.ts:110-119 checkedUrl, called at :666 with context.url Checks --url/SIMLOCK_URL itself, even with --local (src/cli/tree.ts:12) Takes the opt-in from the command context B1, B2, I2
X6 src/mcp/main.ts:60,172-182 farmEnvironment → src/mcp/connect.ts:158-170 connectToFarm → connectSimlock remote is { url, token }; every tool call and renewal connects through the typed client, which checks the URL again remote and connectToFarm carry allowInsecureHttp (I5) B2, I5
X7 src/cli/index.ts:95-124 extractGlobalFlags; :71-77 daemonFlagNamed; :295-320 the router Takes --token, --url, --gateway, --local; builds RemoteFarm at :313 from the flag or SIMLOCK_URL Also takes --allow-insecure-http; the router adds the opt-in to RemoteFarm and to the command context B2, B3, I2
X8 src/cli/environment.ts:504-505 Reads SIMLOCK_URL and SIMLOCK_TOKEN into the environment Also reads SIMLOCK_ALLOW_INSECURE_HTTP B2, B3, I2, I3
X9 src/simlock-client/remote-connector.ts:47-80 remoteConnectOptions; :91 Refuses url with local options; origin.replace(/^http/, "ws") already turns http: into ws: Reads allowInsecureHttp (I4); no transport change B4, I4
X10 src/client/index.ts:65-101, src/admin/index.ts:115-135 The options interfaces have url and token; token without url is ignored (:93-101) Gain allowInsecureHttp B4, I4
X11 src/cli/index.ts:63-69 the USAGE text Names --token, --url, --gateway, --local Names --allow-insecure-http B5
X12 website/src/content/docs/docs/reference/cli.mdx:57,281,896; reference/node-client.mdx:28; using-devices/node-client.mdx:65 State the https-or-loopback rule Name the opt-in B5
X13 packages/e2e/src/options.ts:79 Takes any http(s) URL; it does not call checkedFarmUrl Unchanged Non-goals
X14 src/cli/index.ts:232-249 REMOTE_REFUSED_PATHS config set is refused in remote mode Unchanged; why the opt-in is no config key Decisions

Tasks

Completion conditions: all four are delivered by #1839.

Open work in the same area: draft PRs #1837 (adds a command to src/cli/index.ts), #1809 (touches src/cli/commands/tunnel.ts) and #1497 (touches src/cli/environment.ts) edit the same files in other places; no Depends on, since they are drafts and touch other lines.

Written by an agent.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    feature:spec
    on Nov 24, 2026
  2. V3RON commented on Nov 24, 2026

    @V3RON
    ContributorAuthor

    Design posted: business sections, Decisions, Behaviours B1–B5, Interfaces I1–I5, Existing code X1–X14; one task.

    Written by an agent.

  3. V3RON commented on Nov 25, 2026

    @V3RON
    ContributorAuthor

    Spec updated: T1 is #1839; Tasks section filled.

    Written by an agent.

  4. added
    feature:planned
    and removed
    feature:spec
    on Nov 25, 2026
  5. github-actions commented on Nov 25, 2026

    @github-actions
    Contributor

    Closing: all 1 sub-issues are closed. The PR that closed the last one walks the completion conditions (delivery rule 9); reopen this if one does not hold on main. Flip its ADRs to Accepted if delivery has not.

  6. V3RON commented on Nov 25, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1850 (#1839)
    Parked: none
    Waiting: none
    Decided: none

    Written by an agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions