VYPR
Medium severity4.6NVD Advisory· Published Apr 10, 2026· Updated Apr 13, 2026

CVE-2026-35659

CVE-2026-35659

Description

OpenClaw before 2026.3.22 contains a service discovery vulnerability where TXT metadata from Bonjour and DNS-SD could influence CLI routing even when actual service resolution failed. Attackers can exploit unresolved hints to steer routing decisions to unintended targets by providing malicious discovery metadata.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
openclawnpm
< 2026.3.222026.3.22

Affected products

1
  • cpe:2.3:a:openclaw:openclaw:*:*:*:*:*:node.js:*:*
    Range: <2026.3.22

Patches

2
630f1479c44f

build: prepare 2026.3.23-2

https://github.com/openclaw/openclawPeter SteinbergerMar 24, 2026via ghsa
3 files changed · +26 24
  • CHANGELOG.md+24 22 modified
    @@ -8,45 +8,47 @@ Docs: https://docs.openclaw.ai
     
     ### Changes
     
    -- ModelStudio/Qwen: add standard (pay-as-you-go) DashScope endpoints for China and global Qwen API keys alongside the existing Coding Plan endpoints, and relabel the provider group to `Qwen (Alibaba Cloud Model Studio)`. (#43878)
    -- UI/clarity: consolidate button primitives (`btn--icon`, `btn--ghost`, `btn--xs`), refine the Knot theme to a black-and-red palette with WCAG 2.1 AA contrast, add config icons for Diagnostics/CLI/Secrets/ACP/MCP sections, replace the roundness slider with discrete stops, and improve accessibility with aria-labels across usage filters. (#53272) Thanks @BunsDev.
    -- CSP/Control UI: compute SHA-256 hashes for inline `<script>` blocks in the served `index.html` and include them in the `script-src` CSP directive, keeping inline scripts blocked by default while allowing explicitly hashed bootstrap code. (#53307) Thanks @BunsDev.
    -
     ### Fixes
     
    -- Plugins/ClawHub: resolve plugin API compatibility against the active runtime version at install time, and add regression coverage for current `>=2026.3.22` ClawHub package checks so installs no longer fail behind the stale `1.2.0` constant. (#53157) Thanks @futhgar.
    -- CLI/channel auth: auto-select the single login-capable configured channel for `channels login`/`logout` instead of relying on the outbound message-channel resolver, so env-only or non-auth channels no longer cause false ambiguity errors. (#53254) Thanks @BunsDev.
    -- Control UI/auth: preserve operator scopes through the device-auth bypass path, ignore cached under-scoped operator tokens, and show a clear `operator.read` fallback message when a connection really lacks read scope, so operator sessions stop failing or blanking on read-backed pages. (#53110) Thanks @BunsDev.
    -- Plugins/uninstall: accept installed `clawhub:` specs and versionless ClawHub package names as uninstall targets, so `openclaw plugins uninstall clawhub:<package>` works again even when the recorded install was pinned to a version.
    -- Auth/OpenAI tokens: stop live gateway auth-profile writes from reverting freshly saved credentials back to stale in-memory values, and make `models auth paste-token` write to the resolved agent store, so Configure, Onboard, and token-paste flows stop snapping back to expired OpenAI tokens. Fixes #53207. Related to #45516.
    -- Agents/failover: classify generic `api_error` payloads as retryable only when they include transient failure signals, so MiniMax-style backend failures still trigger model fallback without misclassifying billing, auth, or format/context errors. (#49611) Thanks @ayushozha.
    -- Diagnostics/cache trace: strip credential fields from cache-trace JSONL output while preserving non-sensitive diagnostic fields and image redaction metadata.
    -- Docs/Feishu: replace `botName` with `name` in the channel config examples so the docs match the strict account schema for per-account display names. (#52753) Thanks @haroldfabla2-hue.
    -- Doctor/plugins: make `openclaw doctor --fix` remove stale `plugins.allow` and `plugins.entries` refs left behind after plugin removal. Thanks @sallyom
    -- Agents/replay: canonicalize malformed assistant transcript content before session-history sanitization so legacy or corrupted assistant turns stop crashing Pi replay and subagent recovery paths.
    -- ClawHub/skills: keep updating already-tracked legacy Unicode slugs after the ASCII-only slug hardening, so older installs do not get stuck behind `Invalid skill slug` errors during `openclaw skills update`. (#53206) Thanks @drobison00.
    -- Infra/exec trust: preserve shell-multiplexer wrapper binaries for policy checks without breaking approved-command reconstruction, so BusyBox/ToyBox allowlist and audit flows bind to the real wrapper while execution plans stay coherent. (#53134) Thanks @vincentkoc.
    -- LINE/runtime-api: pre-export overlapping runtime symbols before the `line-runtime` star export so jiti no longer throws `TypeError: Cannot redefine property` on startup. (#53221) Thanks @Drickon.
    -- CLI/cron: make `openclaw cron add|edit --at ... --tz <iana>` honor the requested local wall-clock time for offset-less one-shot datetimes, including DST boundaries, and keep `--tz` rejected for `--every`. (#53224) Thanks @RolfHegr.
    -- Commands/auth: stop slash-command authorization from crashing or dropping valid allowlists when channel `allowFrom` resolution hits unresolved SecretRef-backed accounts, and fail closed only for the affected provider inference path. (#52791) Thanks @Lukavyi.
    -
     ## 2026.3.23
     
     ### Breaking
     
     ### Changes
     
    +- ModelStudio/Qwen: add standard (pay-as-you-go) DashScope endpoints for China and global Qwen API keys alongside the existing Coding Plan endpoints, and relabel the provider group to `Qwen (Alibaba Cloud Model Studio)`. (#43878)
    +- UI/clarity: consolidate button primitives (`btn--icon`, `btn--ghost`, `btn--xs`), refine the Knot theme to a black-and-red palette with WCAG 2.1 AA contrast, add config icons for Diagnostics/CLI/Secrets/ACP/MCP sections, replace the roundness slider with discrete stops, and improve accessibility with aria-labels across usage filters. (#53272) Thanks @BunsDev.
    +- CSP/Control UI: compute SHA-256 hashes for inline `<script>` blocks in the served `index.html` and include them in the `script-src` CSP directive, keeping inline scripts blocked by default while allowing explicitly hashed bootstrap code. (#53307) Thanks @BunsDev.
    +
     ### Fixes
     
    +- Plugins/bundled runtimes: ship bundled plugin runtime sidecars like WhatsApp `light-runtime-api.js`, Matrix `runtime-api.js`, and other plugin runtime entry files in the npm package again, so global installs stop failing on missing bundled plugin runtime surfaces.
    +- CLI/channel auth: auto-select the single configured login-capable channel for `channels login`/`logout`, harden channel ids against prototype-chain and control-character abuse, and fall back cleanly to catalog-backed channel installs, so channel auth works again for single-channel setups and on-demand channel installs. (#53254) Thanks @BunsDev.
    +- Auth/OpenAI tokens: stop live gateway auth-profile writes from reverting freshly saved credentials back to stale in-memory values, and make `models auth paste-token` write to the resolved agent store, so Configure, Onboard, and token-paste flows stop snapping back to expired OpenAI tokens. Fixes #53207. Related to #45516.
    +- Control UI/auth: preserve operator scopes through the device-auth bypass path, ignore cached under-scoped operator tokens, and show a clear `operator.read` fallback message when a connection really lacks read scope, so operator sessions stop failing or blanking on read-backed pages. (#53110) Thanks @BunsDev.
    +- Plugins/ClawHub: resolve plugin API compatibility against the active runtime version at install time, and add regression coverage for current `>=2026.3.22` ClawHub package checks so installs no longer fail behind the stale `1.2.0` constant. (#53157) Thanks @futhgar.
    +- Plugins/uninstall: accept installed `clawhub:` specs and versionless ClawHub package names as uninstall targets, so `openclaw plugins uninstall clawhub:<package>` works again even when the recorded install was pinned to a version.
     - Browser/Chrome MCP: wait for existing-session browser tabs to become usable after attach instead of treating the initial Chrome MCP handshake as ready, which reduces user-profile timeouts and repeated consent churn on macOS Chrome attach flows. Fixes #52930. Thanks @vincentkoc.
     - Browser/CDP: reuse an already-running loopback browser after a short initial reachability miss instead of immediately falling back to relaunch detection, which fixes second-run browser start/open regressions on slower headless Linux setups. Fixes #53004. Thanks @vincentkoc.
    +- Agents/web_search: use the active runtime `web_search` provider instead of stale/default selection, so agent turns keep hitting the provider you actually configured. Fixes #53020. Thanks @jzakirov.
    +- Mistral/models: lower bundled Mistral max-token defaults to safe output budgets and teach `openclaw doctor --fix` to repair old persisted Mistral provider configs that still carry context-sized output limits, avoiding deterministic Mistral 422 rejects on fresh and existing setups. Fixes #52599. Thanks @vincentkoc.
     - ClawHub/macOS auth: honor macOS auth config and XDG auth paths for saved ClawHub credentials, so `openclaw skills ...` and gateway skill browsing keep using the signed-in auth state instead of silently falling back to unauthenticated mode. Fixes #53034.
     - ClawHub/macOS: read the local ClawHub login from the macOS Application Support path and still honor XDG config on macOS, so skill browsing uses the logged-in token on both default and XDG-style setups. Fixes #52949. Thanks @scoootscooob.
     - ClawHub/skills: resolve the local ClawHub auth token for gateway skill browsing and switch browse-all requests to search so ClawControl stops falling into unauthenticated 429s and empty authenticated skill lists. Fixes #52949. Thanks @vincentkoc.
    +- Config/warnings: suppress the confusing “newer OpenClaw” warning when a config written by a same-base correction release like `2026.3.23-2` is read by `2026.3.23`, while still warning for truly newer or incompatible versions.
    +- CLI/cron: make `openclaw cron add|edit --at ... --tz <iana>` honor the requested local wall-clock time for offset-less one-shot datetimes, including DST boundaries, and keep `--tz` rejected for `--every`. (#53224) Thanks @RolfHegr.
    +- Commands/auth: stop slash-command authorization from crashing or dropping valid allowlists when channel `allowFrom` resolution hits unresolved SecretRef-backed accounts, and fail closed only for the affected provider inference path. (#52791) Thanks @Lukavyi.
    +- Agents/failover: classify generic `api_error` payloads as retryable only when they include transient failure signals, so MiniMax-style backend failures still trigger model fallback without misclassifying billing, auth, or format/context errors. (#49611) Thanks @ayushozha.
    +- LINE/runtime-api: pre-export overlapping runtime symbols before the `line-runtime` star export so jiti no longer throws `TypeError: Cannot redefine property` on startup. (#53221) Thanks @Drickon.
    +- Telegram/threading: populate `currentThreadTs` in the threading tool-context fallback for Telegram DM topics so thread-aware tools still receive the active topic context when the main thread metadata is missing. (#52217)
    +- Diagnostics/cache trace: strip credential fields from cache-trace JSONL output while preserving non-sensitive diagnostic fields and image redaction metadata.
    +- Docs/Feishu: replace `botName` with `name` in the channel config examples so the docs match the strict account schema for per-account display names. (#52753) Thanks @haroldfabla2-hue.
    +- Doctor/plugins: make `openclaw doctor --fix` remove stale `plugins.allow` and `plugins.entries` refs left behind after plugin removal. Thanks @sallyom
    +- Agents/replay: canonicalize malformed assistant transcript content before session-history sanitization so legacy or corrupted assistant turns stop crashing Pi replay and subagent recovery paths.
    +- ClawHub/skills: keep updating already-tracked legacy Unicode slugs after the ASCII-only slug hardening, so older installs do not get stuck behind `Invalid skill slug` errors during `openclaw skills update`. (#53206) Thanks @drobison00.
    +- Infra/exec trust: preserve shell-multiplexer wrapper binaries for policy checks without breaking approved-command reconstruction, so BusyBox/ToyBox allowlist and audit flows bind to the real wrapper while execution plans stay coherent. (#53134) Thanks @vincentkoc.
     - Plugins/message tool: make Discord `components` and Slack `blocks` optional again, and route Feishu `message(..., media=...)` sends through the outbound media path, so pin/unpin/react flows stop failing schema validation and Feishu file/image attachments actually send. Fixes #52970 and #52962. Thanks @vincentkoc.
     - Gateway/model pricing: stop `openrouter/auto` pricing refresh from recursing indefinitely during bootstrap, so OpenRouter auto routes can populate cached pricing and `usage.cost` again. Fixes #53035. Thanks @vincentkoc.
    -- Mistral/models: lower bundled Mistral max-token defaults to safe output budgets and teach `openclaw doctor --fix` to repair old persisted Mistral provider configs that still carry context-sized output limits, avoiding deterministic Mistral 422 rejects on fresh and existing setups. Fixes #52599. Thanks @vincentkoc.
    -- Agents/web_search: use the active runtime `web_search` provider instead of stale/default selection, so agent turns keep hitting the provider you actually configured. Fixes #53020. Thanks @jzakirov.
     - Models/OpenAI Codex OAuth: bootstrap the env-configured HTTP/HTTPS proxy dispatcher on the stored-credential refresh path before token renewal runs, so expired Codex OAuth profiles can refresh successfully in proxy-required environments instead of locking users out after the first token expiry.
     - Models/OpenAI Codex OAuth and Plugins/MiniMax OAuth: ensure env-configured HTTP/HTTPS proxy dispatchers are initialized before OAuth preflight and token exchange requests so proxy-required environments can complete MiniMax and OpenAI Codex sign-in flows again. (#52228; fixes #51619, #51569) Thanks @openperf.
     - Plugins/memory-lancedb: bootstrap LanceDB into plugin runtime state on first use when the bundled npm install does not already have it, so `plugins.slots.memory="memory-lancedb"` works again after global npm installs without moving LanceDB into OpenClaw core dependencies. Fixes #26100.
    
  • docs/.generated/plugin-sdk-api-baseline.json+1 1 modified
    @@ -2620,7 +2620,7 @@
               "exportName": "resolveCommandAuthorization",
               "kind": "function",
               "source": {
    -            "line": 303,
    +            "line": 440,
                 "path": "src/auto-reply/command-auth.ts"
               }
             },
    
  • docs/.generated/plugin-sdk-api-baseline.jsonl+1 1 modified
    @@ -287,7 +287,7 @@
     {"declaration":"export function parseCommandArgs(command: ChatCommandDefinition, raw?: string | undefined): CommandArgs | undefined;","entrypoint":"command-auth","exportName":"parseCommandArgs","importSpecifier":"openclaw/plugin-sdk/command-auth","kind":"function","recordType":"export","sourceLine":254,"sourcePath":"src/auto-reply/commands-registry.ts"}
     {"declaration":"export function resolveCommandArgChoices(params: { command: ChatCommandDefinition; arg: CommandArgDefinition; cfg?: OpenClawConfig | undefined; provider?: string | undefined; model?: string | undefined; }): ResolvedCommandArgChoice[];","entrypoint":"command-auth","exportName":"resolveCommandArgChoices","importSpecifier":"openclaw/plugin-sdk/command-auth","kind":"function","recordType":"export","sourceLine":316,"sourcePath":"src/auto-reply/commands-registry.ts"}
     {"declaration":"export function resolveCommandArgMenu(params: { command: ChatCommandDefinition; args?: CommandArgs | undefined; cfg?: OpenClawConfig | undefined; }): { arg: CommandArgDefinition; choices: ResolvedCommandArgChoice[]; title?: string | undefined; } | null;","entrypoint":"command-auth","exportName":"resolveCommandArgMenu","importSpecifier":"openclaw/plugin-sdk/command-auth","kind":"function","recordType":"export","sourceLine":346,"sourcePath":"src/auto-reply/commands-registry.ts"}
    -{"declaration":"export function resolveCommandAuthorization(params: { ctx: MsgContext; cfg: OpenClawConfig; commandAuthorized: boolean; }): CommandAuthorization;","entrypoint":"command-auth","exportName":"resolveCommandAuthorization","importSpecifier":"openclaw/plugin-sdk/command-auth","kind":"function","recordType":"export","sourceLine":303,"sourcePath":"src/auto-reply/command-auth.ts"}
    +{"declaration":"export function resolveCommandAuthorization(params: { ctx: MsgContext; cfg: OpenClawConfig; commandAuthorized: boolean; }): CommandAuthorization;","entrypoint":"command-auth","exportName":"resolveCommandAuthorization","importSpecifier":"openclaw/plugin-sdk/command-auth","kind":"function","recordType":"export","sourceLine":440,"sourcePath":"src/auto-reply/command-auth.ts"}
     {"declaration":"export function resolveCommandAuthorizedFromAuthorizers(params: { useAccessGroups: boolean; authorizers: CommandAuthorizer[]; modeWhenAccessGroupsOff?: CommandGatingModeWhenAccessGroupsOff | undefined; }): boolean;","entrypoint":"command-auth","exportName":"resolveCommandAuthorizedFromAuthorizers","importSpecifier":"openclaw/plugin-sdk/command-auth","kind":"function","recordType":"export","sourceLine":8,"sourcePath":"src/channels/command-gating.ts"}
     {"declaration":"export function resolveControlCommandGate(params: { useAccessGroups: boolean; authorizers: CommandAuthorizer[]; allowTextCommands: boolean; hasControlCommand: boolean; modeWhenAccessGroupsOff?: CommandGatingModeWhenAccessGroupsOff | undefined; }): { ...; };","entrypoint":"command-auth","exportName":"resolveControlCommandGate","importSpecifier":"openclaw/plugin-sdk/command-auth","kind":"function","recordType":"export","sourceLine":31,"sourcePath":"src/channels/command-gating.ts"}
     {"declaration":"export function resolveDirectDmAuthorizationOutcome(params: { isGroup: boolean; dmPolicy: string; senderAllowedForCommands: boolean; }): \"disabled\" | \"unauthorized\" | \"allowed\";","entrypoint":"command-auth","exportName":"resolveDirectDmAuthorizationOutcome","importSpecifier":"openclaw/plugin-sdk/command-auth","kind":"function","recordType":"export","sourceLine":120,"sourcePath":"src/plugin-sdk/command-auth.ts"}
    
deecf68b59a9

fix(gateway): fail closed on unresolved discovery endpoints

https://github.com/openclaw/openclawPeter SteinbergerMar 23, 2026via ghsa
9 files changed · +160 38
  • CHANGELOG.md+6 0 modified
    @@ -84,6 +84,12 @@ Docs: https://docs.openclaw.ai
     
     ### Fixes
     
    +- Gateway/discovery: fail closed on unresolved Bonjour and DNS-SD service endpoints in CLI discovery, onboarding, and `gateway status` so TXT-only hints can no longer steer routing or SSH auto-target selection. Thanks @nexrin for reporting.
    +- Security/pairing: bind iOS setup codes to the intended node profile and reject first-use bootstrap redemption that asks for broader roles or scopes. Thanks @tdjackey.
    +- Web tools/Exa: align the bundled Exa plugin with the current Exa API by supporting newer search types and richer `contents` options, while fixing the result-count cap to honor Exa's higher limit. Thanks @vincentkoc.
    +- Plugins/Matrix: move bundled plugin `KeyedAsyncQueue` imports onto the stable `plugin-sdk/core` surface so Matrix Docker/runtime builds do not depend on the brittle keyed-async-queue subpath. Thanks @ecohash-co and @vincentkoc.
    +- Nostr/security: enforce inbound DM policy before decrypt, route Nostr DMs through the standard reply pipeline, and add pre-crypto rate and size guards so unknown senders cannot bypass pairing or force unbounded crypto work. Thanks @kuranikaran.
    +- Synology Chat/security: keep reply delivery bound to stable numeric `user_id` by default, and gate mutable username/nickname recipient lookup behind `dangerouslyAllowNameMatching` with new regression coverage. Thanks @nexrin.
     - Agents/default timeout: raise the shared default agent timeout from `600s` to `48h` so long-running ACP and agent sessions do not fail unless you configure a shorter limit.
     - Gateway/startup: load bundled channel plugins from compiled `dist/extensions` entries in built installs, so gateway boot no longer recompiles bundled extension TypeScript on every startup and WhatsApp-class cold starts drop back to seconds instead of tens of seconds or worse. (#47560) Thanks @ngutman.
     - Gateway/startup: prewarm the configured primary model before channel startup and retry one transient provider-runtime miss so the first Telegram or Discord message after boot no longer fails with `Unknown model: openai-codex/gpt-5.4`. Thanks @vincentkoc.
    
  • src/cli/gateway-cli.coverage.test.ts+3 1 modified
    @@ -81,7 +81,8 @@ vi.mock("../daemon/program-args.js", () => ({
       }),
     }));
     
    -vi.mock("../infra/bonjour-discovery.js", () => ({
    +vi.mock("../infra/bonjour-discovery.js", async (importOriginal) => ({
    +  ...(await importOriginal<typeof import("../infra/bonjour-discovery.js")>()),
       discoverGatewayBeacons: (opts: unknown) => discoverGatewayBeacons(opts),
     }));
     
    @@ -147,6 +148,7 @@ describe("gateway-cli coverage", () => {
             displayName: "Studio",
             domain: "openclaw.internal.",
             host: "studio.openclaw.internal",
    +        port: 18789,
             lanHost: "studio.local",
             tailnetDns: "studio.tailnet.ts.net",
             gatewayPort: 18789,
    
  • src/cli/gateway-cli/discover.ts+11 8 modified
    @@ -1,4 +1,8 @@
    -import type { GatewayBonjourBeacon } from "../../infra/bonjour-discovery.js";
    +import {
    +  type GatewayBonjourBeacon,
    +  pickResolvedGatewayHost,
    +  pickResolvedGatewayPort,
    +} from "../../infra/bonjour-discovery.js";
     import { colorize, theme } from "../../terminal/theme.js";
     import { parseTimeoutMsWithFallback } from "../parse-timeout.js";
     
    @@ -13,15 +17,14 @@ export function parseDiscoverTimeoutMs(raw: unknown, fallbackMs: number): number
     
     export function pickBeaconHost(beacon: GatewayBonjourBeacon): string | null {
       // Security: TXT records are unauthenticated. Prefer the resolved service endpoint (SRV/A/AAAA)
    -  // over TXT-provided routing hints.
    -  const host = beacon.host || beacon.tailnetDns || beacon.lanHost;
    -  return host?.trim() ? host.trim() : null;
    +  // and fail closed when discovery did not resolve a routable host.
    +  return pickResolvedGatewayHost(beacon);
     }
     
    -export function pickGatewayPort(beacon: GatewayBonjourBeacon): number {
    +export function pickGatewayPort(beacon: GatewayBonjourBeacon): number | null {
       // Security: TXT records are unauthenticated. Prefer the resolved service port over TXT gatewayPort.
    -  const port = beacon.port ?? beacon.gatewayPort ?? 18789;
    -  return port > 0 ? port : 18789;
    +  // Fail closed when discovery did not resolve a routable port.
    +  return pickResolvedGatewayPort(beacon);
     }
     
     export function dedupeBeacons(beacons: GatewayBonjourBeacon[]): GatewayBonjourBeacon[] {
    @@ -56,7 +59,7 @@ export function renderBeaconLines(beacon: GatewayBonjourBeacon, rich: boolean):
       const host = pickBeaconHost(beacon);
       const gatewayPort = pickGatewayPort(beacon);
       const scheme = beacon.gatewayTls ? "wss" : "ws";
    -  const wsUrl = host ? `${scheme}://${host}:${gatewayPort}` : null;
    +  const wsUrl = host && gatewayPort ? `${scheme}://${host}:${gatewayPort}` : null;
     
       const lines = [`- ${title} ${domain}`];
     
    
  • src/cli/gateway-cli/run-loop.test.ts+3 3 modified
    @@ -444,13 +444,13 @@ describe("gateway discover routing helpers", () => {
         expect(pickGatewayPort(beacon)).toBe(18789);
       });
     
    -  it("falls back to TXT host/port when resolve data is missing", () => {
    +  it("fails closed when resolve data is missing", () => {
         const beacon: GatewayBonjourBeacon = {
           instanceName: "Test",
           lanHost: "test-host.local",
           gatewayPort: 18789,
         };
    -    expect(pickBeaconHost(beacon)).toBe("test-host.local");
    -    expect(pickGatewayPort(beacon)).toBe(18789);
    +    expect(pickBeaconHost(beacon)).toBeNull();
    +    expect(pickGatewayPort(beacon)).toBeNull();
       });
     });
    
  • src/commands/gateway-status.test.ts+50 8 modified
    @@ -1,5 +1,6 @@
     import { describe, expect, it, vi } from "vitest";
     import type { GatewayProbeResult } from "../gateway/probe.js";
    +import type { GatewayBonjourBeacon } from "../infra/bonjour-discovery.js";
     import type { RuntimeEnv } from "../runtime.js";
     import { withEnvAsync } from "../test-utils/env.js";
     
    @@ -12,7 +13,7 @@ const readBestEffortConfig = vi.fn(async () => ({
     }));
     const resolveGatewayPort = vi.fn((_cfg?: unknown) => 18789);
     const discoverGatewayBeacons = vi.fn(
    -  async (_opts?: unknown): Promise<Array<{ tailnetDns: string }>> => [],
    +  async (_opts?: unknown): Promise<GatewayBonjourBeacon[]> => [],
     );
     const pickPrimaryTailnetIPv4 = vi.fn(() => "100.64.0.10");
     const sshStop = vi.fn(async () => {});
    @@ -117,9 +118,13 @@ vi.mock("../config/config.js", () => ({
       resolveGatewayPort,
     }));
     
    -vi.mock("../infra/bonjour-discovery.js", () => ({
    -  discoverGatewayBeacons,
    -}));
    +vi.mock("../infra/bonjour-discovery.js", async (importOriginal) => {
    +  const actual = await importOriginal<typeof import("../infra/bonjour-discovery.js")>();
    +  return {
    +    ...actual,
    +    discoverGatewayBeacons,
    +  };
    +});
     
     vi.mock("../infra/tailnet.js", () => ({
       pickPrimaryTailnetIPv4,
    @@ -220,6 +225,27 @@ describe("gateway-status command", () => {
         expect(targets[0]?.summary).toBeTruthy();
       });
     
    +  it("omits discovery wsUrl when only TXT hints are present", async () => {
    +    const { runtime, runtimeLogs, runtimeErrors } = createRuntimeCapture();
    +    discoverGatewayBeacons.mockResolvedValueOnce([
    +      {
    +        instanceName: "gateway",
    +        displayName: "Gateway",
    +        tailnetDns: "attacker.tailnet.ts.net",
    +        lanHost: "attacker.example.com",
    +        gatewayPort: 19443,
    +      },
    +    ]);
    +
    +    await runGatewayStatus(runtime, { timeout: "1000", json: true });
    +
    +    expect(runtimeErrors).toHaveLength(0);
    +    const parsed = JSON.parse(runtimeLogs.join("\n")) as {
    +      discovery?: { beacons?: Array<{ wsUrl?: string | null }> };
    +    };
    +    expect(parsed.discovery?.beacons?.[0]?.wsUrl).toBeNull();
    +  });
    +
       it("keeps status output working when tailnet discovery throws", async () => {
         const { runtime, runtimeLogs, runtimeErrors } = createRuntimeCapture();
         pickPrimaryTailnetIPv4.mockImplementationOnce(() => {
    @@ -625,21 +651,37 @@ describe("gateway-status command", () => {
         );
       });
     
    -  it("skips invalid ssh-auto discovery targets", async () => {
    +  it("does not infer ssh-auto targets from TXT-only discovery metadata", async () => {
    +    const { runtime } = createRuntimeCapture();
    +    await withEnvAsync({ USER: "steipete" }, async () => {
    +      readBestEffortConfig.mockResolvedValueOnce(makeRemoteGatewayConfig("", "", "ltok"));
    +      discoverGatewayBeacons.mockResolvedValueOnce([
    +        { instanceName: "bad", tailnetDns: "-V" },
    +        { instanceName: "txt-only", tailnetDns: "goodhost" },
    +      ]);
    +
    +      startSshPortForward.mockClear();
    +      await runGatewayStatus(runtime, { timeout: "1000", json: true, sshAuto: true });
    +
    +      expect(startSshPortForward).not.toHaveBeenCalled();
    +    });
    +  });
    +
    +  it("infers ssh-auto targets from resolved discovery hosts", async () => {
         const { runtime } = createRuntimeCapture();
         await withEnvAsync({ USER: "steipete" }, async () => {
           readBestEffortConfig.mockResolvedValueOnce(makeRemoteGatewayConfig("", "", "ltok"));
           discoverGatewayBeacons.mockResolvedValueOnce([
    -        { tailnetDns: "-V" },
    -        { tailnetDns: "goodhost" },
    +        { instanceName: "bad", tailnetDns: "-V" },
    +        { host: "goodhost", sshPort: 2222, port: 18789, instanceName: "Gateway" },
           ]);
     
           startSshPortForward.mockClear();
           await runGatewayStatus(runtime, { timeout: "1000", json: true, sshAuto: true });
     
           expect(startSshPortForward).toHaveBeenCalledTimes(1);
           const call = startSshPortForward.mock.calls[0]?.[0] as { target: string };
    -      expect(call.target).toBe("steipete@goodhost");
    +      expect(call.target).toBe("steipete@goodhost:2222");
         });
       });
     
    
  • src/commands/gateway-status.ts+11 7 modified
    @@ -1,7 +1,11 @@
     import { withProgress } from "../cli/progress.js";
     import { readBestEffortConfig, resolveGatewayPort } from "../config/config.js";
     import { probeGateway } from "../gateway/probe.js";
    -import { discoverGatewayBeacons } from "../infra/bonjour-discovery.js";
    +import {
    +  discoverGatewayBeacons,
    +  pickResolvedGatewayHost,
    +  pickResolvedGatewayPort,
    +} from "../infra/bonjour-discovery.js";
     import { resolveWideAreaDiscoveryDomain } from "../infra/widearea-dns.js";
     import { type RuntimeEnv, writeRuntimeJson } from "../runtime.js";
     import { colorize, isRich, theme } from "../terminal/theme.js";
    @@ -123,12 +127,12 @@ export async function gatewayStatusCommand(
             const user = process.env.USER?.trim() || "";
             const candidates = discovery
               .map((b) => {
    -            const host = b.tailnetDns || b.lanHost || b.host;
    -            if (!host?.trim()) {
    +            const host = pickResolvedGatewayHost(b);
    +            if (!host) {
                   return null;
                 }
                 const sshPort = typeof b.sshPort === "number" && b.sshPort > 0 ? b.sshPort : 22;
    -            const base = user ? `${user}@${host.trim()}` : host.trim();
    +            const base = user ? `${user}@${host}` : host;
                 return sshPort !== 22 ? `${base}:${sshPort}` : base;
               })
               .filter((candidate): candidate is string => Boolean(candidate));
    @@ -286,9 +290,9 @@ export async function gatewayStatusCommand(
               gatewayPort: b.gatewayPort ?? null,
               sshPort: b.sshPort ?? null,
               wsUrl: (() => {
    -            const host = b.tailnetDns || b.lanHost || b.host;
    -            const port = b.gatewayPort ?? 18789;
    -            return host ? `ws://${host}:${port}` : null;
    +            const host = pickResolvedGatewayHost(b);
    +            const port = pickResolvedGatewayPort(b);
    +            return host && port ? `ws://${host}:${port}` : null;
               })(),
             })),
           },
    
  • src/commands/onboard-remote.test.ts+50 3 modified
    @@ -9,9 +9,13 @@ const discoverGatewayBeacons = vi.hoisted(() => vi.fn<() => Promise<GatewayBonjo
     const resolveWideAreaDiscoveryDomain = vi.hoisted(() => vi.fn(() => undefined));
     const detectBinary = vi.hoisted(() => vi.fn<(name: string) => Promise<boolean>>());
     
    -vi.mock("../infra/bonjour-discovery.js", () => ({
    -  discoverGatewayBeacons,
    -}));
    +vi.mock("../infra/bonjour-discovery.js", async (importOriginal) => {
    +  const actual = await importOriginal<typeof import("../infra/bonjour-discovery.js")>();
    +  return {
    +    ...actual,
    +    discoverGatewayBeacons,
    +  };
    +});
     
     vi.mock("../infra/widearea-dns.js", () => ({
       resolveWideAreaDiscoveryDomain,
    @@ -113,6 +117,49 @@ describe("promptRemoteGatewayConfig", () => {
         );
       });
     
    +  it("does not route from TXT-only discovery metadata", async () => {
    +    detectBinary.mockResolvedValue(true);
    +    discoverGatewayBeacons.mockResolvedValue([
    +      {
    +        instanceName: "gateway",
    +        displayName: "Gateway",
    +        lanHost: "attacker.example.com",
    +        tailnetDns: "attacker.tailnet.ts.net",
    +        gatewayPort: 19443,
    +        sshPort: 2222,
    +      },
    +    ]);
    +
    +    const select: WizardPrompter["select"] = vi.fn(async (params) => {
    +      if (params.message === "Select gateway") {
    +        return "0" as never;
    +      }
    +      if (params.message === "Gateway auth") {
    +        return "off" as never;
    +      }
    +      return (params.options[0]?.value ?? "") as never;
    +    });
    +    const text: WizardPrompter["text"] = vi.fn(async (params) => {
    +      if (params.message === "Gateway WebSocket URL") {
    +        expect(params.initialValue).toBe("ws://127.0.0.1:18789");
    +        return String(params.initialValue);
    +      }
    +      return "";
    +    }) as WizardPrompter["text"];
    +    const prompter = createPrompter({
    +      confirm: vi.fn(async () => true),
    +      select,
    +      text,
    +    });
    +
    +    const next = await promptRemoteGatewayConfig({} as OpenClawConfig, prompter);
    +
    +    expect(next.gateway?.remote?.url).toBe("ws://127.0.0.1:18789");
    +    expect(select).not.toHaveBeenCalledWith(
    +      expect.objectContaining({ message: "Connection method" }),
    +    );
    +  });
    +
       it("validates insecure ws:// remote URLs and allows only loopback ws:// by default", async () => {
         const text: WizardPrompter["text"] = vi.fn(async (params) => {
           if (params.message === "Gateway WebSocket URL") {
    
  • src/commands/onboard-remote.ts+16 8 modified
    @@ -1,8 +1,12 @@
     import type { OpenClawConfig } from "../config/config.js";
     import type { SecretInput } from "../config/types.secrets.js";
     import { isSecureWebSocketUrl } from "../gateway/net.js";
    -import type { GatewayBonjourBeacon } from "../infra/bonjour-discovery.js";
    -import { discoverGatewayBeacons } from "../infra/bonjour-discovery.js";
    +import {
    +  discoverGatewayBeacons,
    +  pickResolvedGatewayHost,
    +  pickResolvedGatewayPort,
    +  type GatewayBonjourBeacon,
    +} from "../infra/bonjour-discovery.js";
     import { resolveWideAreaDiscoveryDomain } from "../infra/widearea-dns.js";
     import { resolveSecretInputModeForEnvSelection } from "../plugins/provider-auth-mode.js";
     import { promptSecretRefForSetup } from "../plugins/provider-auth-ref.js";
    @@ -14,15 +18,19 @@ const DEFAULT_GATEWAY_URL = "ws://127.0.0.1:18789";
     
     function pickHost(beacon: GatewayBonjourBeacon): string | undefined {
       // Security: TXT is unauthenticated. Prefer the resolved service endpoint host.
    -  return beacon.host || beacon.tailnetDns || beacon.lanHost;
    +  return pickResolvedGatewayHost(beacon) ?? undefined;
    +}
    +
    +function pickPort(beacon: GatewayBonjourBeacon): number | undefined {
    +  // Security: TXT is unauthenticated. Prefer the resolved service endpoint port.
    +  return pickResolvedGatewayPort(beacon) ?? undefined;
     }
     
     function buildLabel(beacon: GatewayBonjourBeacon): string {
       const host = pickHost(beacon);
    -  // Security: Prefer the resolved service endpoint port.
    -  const port = beacon.port ?? beacon.gatewayPort ?? 18789;
    +  const port = pickPort(beacon);
       const title = beacon.displayName ?? beacon.instanceName;
    -  const hint = host ? `${host}:${port}` : "host unknown";
    +  const hint = host && port ? `${host}:${port}` : "host unknown";
       return `${title} (${hint})`;
     }
     
    @@ -106,8 +114,8 @@ export async function promptRemoteGatewayConfig(
     
       if (selectedBeacon) {
         const host = pickHost(selectedBeacon);
    -    const port = selectedBeacon.port ?? selectedBeacon.gatewayPort ?? 18789;
    -    if (host) {
    +    const port = pickPort(selectedBeacon);
    +    if (host && port) {
           const mode = await prompter.select({
             message: "Connection method",
             options: [
    
  • src/infra/bonjour-discovery.ts+10 0 modified
    @@ -20,6 +20,16 @@ export type GatewayBonjourBeacon = {
       txt?: Record<string, string>;
     };
     
    +export function pickResolvedGatewayHost(beacon: GatewayBonjourBeacon): string | null {
    +  const host = beacon.host?.trim();
    +  return host ? host : null;
    +}
    +
    +export function pickResolvedGatewayPort(beacon: GatewayBonjourBeacon): number | null {
    +  const port = beacon.port;
    +  return typeof port === "number" && Number.isFinite(port) && port > 0 ? port : null;
    +}
    +
     export type GatewayBonjourDiscoverOpts = {
       timeoutMs?: number;
       domains?: string[];
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

6

News mentions

0

No linked articles in our index yet.