Skip to content

proxy-relay: RELAY_TARGET_PORTS is parsed with bare Number()+filter — invalid entries are silently dropped and hex/scientific spellings are coerced to ports nobody configured #3082

Closed

Description

@dezren39

proxy-relay: RELAY_TARGET_PORTS is parsed with bare Number()+filter — invalid entries are silently dropped and hex/scientific spellings are coerced to ports nobody configured

Evidence (verified this run, main d4279a4)

bin/proxy-relay.mjs:47-50 parses its target-port list outside the house strict parser:

const TARGET_PORTS = (process.env.RELAY_TARGET_PORTS || '')
  .split(',')
  .map((s) => Number(s.trim()))
  .filter((n) => Number.isInteger(n) && n >= 1 && n <= 65535);

Replicating that exact expression (node, this run) shows the failure modes:

Input Result
18745,19745 [18745, 19745] (correct)
18745,abc [18745] — bad entry silently dropped
18745,19745typo [18745] — typo'd fallback target silently dropped
0x4a39 [19001] — hex spelling coerced to a port nobody configured
1e4 [10000] — scientific spelling coerced
18745.0 [18745] — decimal spelling coerced
99999,18745 [18745] — out-of-range entry silently dropped

This is exactly the class of bug bin/proxy-port.mjs was built to eliminate (#483, #494): its header states a bare parse "silently becomes" a different port, and every other fleet proxy routes its listen port through parseProxyPort/parseAddressPortValue so a bad value fails at startup naming the variable and its value. The relay's own listen/proxy ports do use the helper (proxy-relay.mjs:39,55); only the target list escapes it. The adoption guard in bin/proxy-port.test.mjs ("all eight parse sites in the six proxies use the shared helper") enumerates six files and *_PROXY_PORT names only, so it cannot see this site — and there is no bin/proxy-relay.test.mjs.

Why it matters

The relay is a raw TCP forwarder whose whole job is trying target ports in order (preferred starts at TARGET_PORTS[0], proxy-relay.mjs:57). A typo in the configured list does not fail startup: the relay starts healthy with a silently shortened target list, and the missing fallback target is only discovered when the primary target is down — i.e. at the moment the fallback was needed. A coerced spelling (0x…, 1e4) makes it dial a port that was never configured at all.

Dedup

Open+closed search 2026-10-31 for RELAY_TARGET_PORTS / "proxy-relay target ports" returned no issue. Neighbours are distinct: #483/#494 built the strict helper for listen/address ports; #2823 (open) covers antigravity-direct's bare-Number() listen port/timeout, a different file and variable.

Acceptance criteria

  • Every entry of RELAY_TARGET_PORTS is validated strictly (decimal integer 1–65535, e.g. via a list parser in bin/proxy-port.mjs built on parseProxyPortValue); any invalid entry aborts startup with an error naming RELAY_TARGET_PORTS and the offending entry — no silent drops, no hex/scientific/decimal coercion.
  • Valid lists (including entries with surrounding spaces, as today) parse unchanged; the "required" error for an absent/empty list stays.
  • New tests (bin/proxy-relay.test.mjs or an extension of bin/proxy-port.test.mjs) cover: valid list, typo'd entry, hex entry, out-of-range entry, and the all-invalid case; the adoption guard is extended so a future bare-Number() port parse in bin/ is caught.
  • node --test bin/proxy-port.test.mjs (and the new tests) pass.

Filed by new-issue-creator-code-b (Lane B), 2026-10-31 run.

Activity

  1. added
    queue/queued
    source/creator
    task/triage
    status/needs-triage
    priority/low
    app/proxy-relay
    kind/bug
    effort/s
    on Oct 31, 2026
  2. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  3. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

  4. added
    status/duplicate
    and removed
    task/triage
    status/needs-triage
    queue/queued
    on Oct 31, 2026
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

    app/proxy-relayeffort/skind/bugpriority/lowsource/creatorstatus/duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions