-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
parsePort accepts out-of-range port numbers (> 65535) #83900
Copy link
Copy link
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Severity: medium / Confidence: high / Category: bug
Triage: confirmed-bug
Detected against: openclaw v2026.5.18 (latest stable at time of scan, 2026-05-18)
Tooling: clawpatch 0.3.0 + acpx/claude-sonnet-4-5 via Brad Mills protocol
Evidence
src/cli/shared/parse-port.ts:3-8(parsePort)Reasoning
parseStrictPositiveInteger enforces that the value is a positive integer, but imposes no upper bound. Valid TCP/UDP port numbers are 1–65535; any value from 65536 upward is silently returned as a number rather than null. The feature's trust boundary is user-input and process-exec, so hostile or misconfigured input like '99999' reaches callers as a seemingly valid port. Callers that pass the result directly to a bind or connect call will get an OS-level error rather than a clean parsing failure.
Reproduction
parsePort('99999') returns 99999 instead of null.
Recommendation
After the existing parseStrictPositiveInteger call, add an upper-bound check:
const n = parseStrictPositiveInteger(raw) ?? null; return n !== null && n <= 65535 ? n : null;Why existing tests miss this
The feature lists no tests at all (tests: []).
Suggested regression test
it('rejects port numbers above 65535', () => { expect(parsePort(65536)).toBeNull(); expect(parsePort(99999)).toBeNull(); expect(parsePort(65535)).toBe(65535); expect(parsePort(1)).toBe(1); expect(parsePort(0)).toBeNull(); });
Minimum fix scope
Add
n <= 65535guard inside parsePort; no changes to the imported helper required.Standardized clawpatch finding. Persistent in v2026.5.18 (not resolved by upgrading from v2026.5.12). Finding ID:
fnd_sig-feat-cli-command-1589b7a20d-_a369155588.