Skip to content

antigravity-ls-proxy: ANTIGRAVITY_LS_ADDRESS port parsed with bare parseInt — malformed addresses silently discarded, managed daemon spawned instead #494

Closed

Description

@dezren39

Problem

bin/antigravity-ls-proxy.mjs validates its own listen port strictly via the shared parseProxyPort helper (#483), but the port it connects to — taken from the operator-supplied ANTIGRAVITY_LS_ADDRESS env var — is parsed with a bare parseInt and no validation at all.

bin/antigravity-ls-proxy.mjs:199-202 (LanguageServerManager.detectRunningInstances):

if (process.env.ANTIGRAVITY_LS_ADDRESS && process.env.ANTIGRAVITY_CSRF_TOKEN) {
  const parts = process.env.ANTIGRAVITY_LS_ADDRESS.split(':');
  const port = parseInt(parts[parts.length - 1], 10);
  return [{ port, token: process.env.ANTIGRAVITY_CSRF_TOKEN }];
}

This branch returns immediately, bypassing even the weak check in the add() helper below it (p > 0, lines 207-214 — which itself has no <= 65535 upper bound, so candidate ports discovered from ps/ss/lsof/log lines are also unbounded above).

Evidence (verified this run on main 72a52d4)

Replaying the exact lines 200-202 logic in Node:

ANTIGRAVITY_LS_ADDRESS resulting candidate port
127.0.0.1:abc NaN
127.0.0.1: NaN
127.0.0.1:99999 99999
127.0.0.1:0 0
127.0.0.1:-5 -5
127.0.0.1:18745abc 18745 (trailing junk silently dropped)
127.0.0.1:18745.9 18745 (fraction silently dropped)

And the add() helper accepts 99999 / 65536 as candidate ports.

Why it matters

Suggested fix / acceptance criteria

  • The ANTIGRAVITY_LS_ADDRESS port is validated strictly (digits only, integer 1-65535), reusing parseProxyPortValue from bin/proxy-port.mjs where practical; a malformed address fails fast with an error naming ANTIGRAVITY_LS_ADDRESS and the offending value, instead of silently falling back to a managed daemon.
  • The add() candidate helper rejects ports > 65535 as well as <= 0 / NaN.
  • Regression tests cover at least: abc, empty port, 0, 99999, 18745abc, 18745.9, and a valid host:18745; and the bin proxies: *_PROXY_PORT parsed with bare parseInt — invalid values crash opaquely or bind the wrong port #483 guard test (or a new one) catches a bare parseInt on the ANTIGRAVITY_LS_ADDRESS path.
  • node --test bin/proxy-port.test.mjs (plus any new test file) passes.

Dedup: #483 covered only the *_PROXY_PORT listen ports (closed); #435 is about single-sourcing the proxies' port configuration in opencode config, not about validating this address; no open or closed issue covers ANTIGRAVITY_LS_ADDRESS parsing.

Activity

  1. added a commit that references this issue on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions