# vercel-labs/portless — AlpLab Radar Static Code Audit

- Ring: `adopt`
- Category: `dev`
- Overall score: `4.3/5`
- Implementation check: `verified`
- Maturity: `active`
- Audited commit: `83ed9d00cfdf` (read-only; nothing from the repository was executed)
- Reviewed at: 2026-12-01T20:26:55Z
- Repository: https://github.com/vercel-labs/portless
- Radar entry: https://radar.alplab.co/#repo/vercel-labs/portless
- License: `Apache-2.0`
- CI workflows: `.github/workflows`
- Tags: `local-dev`, `reverse-proxy`, `https`, `localhost`, `devtools`, `mcp`

## Summary

A local reverse-proxy daemon that assigns each dev server a random port and serves it at a stable named https://<name>.localhost URL, with a managed local CA and per-hostname SNI certs, /etc/hosts sync, HTTP/2+WebSocket proxying, LAN/tunnel sharing, worktree-aware naming, and an MCP server for agents.

## Implementation Check

Every headline README claim maps to working code I read: named routing and dashboard in packages/portless/src/proxy.ts (findRoute, createProxyServer with HTTP/2 allowHTTP1 and RFC 8441 extended-CONNECT WebSocket bridging), CA generation and per-distro trust in packages/portless/src/certs.ts (generateCA, CertIssuer.sniCallback, trustCALinux, NSS/WSL paths), worktree naming in auto.ts usage in cli.ts, tunnel sharing in packages/portless/src/tunnel.ts (ngrok/cloudflared/netbird providers), and the MCP server in packages/portless/src/mcp.ts (createServer with 2026-07-28 and legacy initialize).

## When to Use

Use it when running one or many local dev servers (or agent-driven test flows) where stable HTTPS URLs matter: OAuth redirects, cookies, cross-app env wiring, LAN/tunnel demos. Not for production routing, machines without Node >= 24 or a system openssl, or environments where adding a local CA to the trust store and editing the hosts file is unacceptable.

## Sub-scores

| Dimension | Score |
|---|---|
| quality | 4.5/5 |
| usability | 4.5/5 |
| reliability | 3.0/5 |
| security | 4.5/5 |
| integration | 5.0/5 |

## Code Evidence

packages/portless/src/proxy.ts createProxyServer: Host-header routing with loop detection (x-portless-hops, MAX_PROXY_HOPS=5), TLS/plain demux by first-byte peek (0x16), unprivileged loopback-only guard (guardLoopbackOnly), RFC 8441 WebSocket bridging that synthesizes Sec-WebSocket-Key and verifies the backend Sec-WebSocket-Accept hash; packages/portless/src/upstream-pool.ts UpstreamPool: per-backend admission control (MAX_REQUEST_SOCKETS=48, MAX_QUEUED_REQUESTS=512) with 408/503/504 rejection mapping and ECONNRESET replay for idempotent requests; packages/portless/src/routes.ts RouteStore: lockdir locking with owner PID and stale reclaim, atomic wx-tmp+rename saves, port allocation in 4000-4999 skipping BLOCKED_PORTS, stale records retired with recovery data; packages/portless/src/certs.ts: SNI certs restricted to configured TLDs and live routes (CertIssuer.sniCallback admission tiers), SHA-1 signature rejection (isCertSignatureStrong), duplicate-extension CA regeneration, ephemeral unregistered-cert rate limiting (EPHEMERAL_BURST); packages/portless/src/utils.ts findStateDirProblem/resolveTrustedPath: refuses state dirs that are foreign-owned, group/world-writable, or reachable via untrusted symlinks; packages/portless/src/cli-utils.ts spawnCommand: single-quote shellEscape for /bin/sh -c and explicit cmd.exe /d /s /c, and resolveScriptArgForwarding refuses arg forwarding through scripts with shell operators or comments; packages/portless/src/mcp.ts createServer: strict tool-argument validation against schemas, argv-only child invocation with no shell; packages/portless/src/tunnel.ts buildNetbirdEnv: NetBird password/pin passed via env vars, not argv; packages/portless/src/hosts.ts writeHostsFileAtomic: wx temp + rename with EBUSY/EXDEV fallback and post-write verification. Tests are substantial and core-path: packages/portless/src/proxy.test.ts (~180KB), cli.test.ts (~362KB), routes.test.ts, certs.test.ts, upstream-pool.test.ts, plus tests/e2e with Next/Nuxt/Vite/Astro/SvelteKit/React Router; .github/workflows/ci.yml runs lint, dual type-check (tsc-ts and tsc), build, unit tests, docs route tests, e2e on Ubuntu, and a Windows job that installs and verifies the scheduled-task service (port listening, PT0S limit, SYSTEM principal) then uninstalls it.

## Issues Found

Minor, none disqualifying for normal use: packages/portless/src/upstream-pool.ts connect() sets rejectUnauthorized:false for backend TLS (documented, loopback-only); .github/workflows/ci.yml and release.yml use tag-pinned but un-SHA-pinned actions (16 unpinned_actions signals), a supply-chain hardening gap; the openssl binary is a hard runtime dependency for TLS mode but is not declared in packages/portless/package.json.

## Key Risks

Static review only; nothing was executed, so 'tests exist' is verified but 'tests pass' is not. Hard operational requirements: Node >= 24 (engines in packages/portless/package.json), a system openssl binary for TLS mode (invoked via execFileSync in certs.ts, not declared as a dependency), and sudo/admin for the default 443/80 bind plus CA trust on first run (--unprivileged and --no-tls escape hatches exist). Upstream TLS to backends intentionally disables certificate verification (rejectUnauthorized:false in upstream-pool.ts connect()), loopback-dialed only and documented in the README. Pre-1.0 (v0.18.1) so CLI surface may still shift; repo has a single 246KB cli.ts and 98KB cli-utils.ts, which concentrates a lot of logic in two files. Nothing was run, so runtime behavior on specific distros (NixOS, WSL) is taken from code and docs, not verified.

## Reviewed Files

- `README.md`
- `AGENTS.md`
- `.github/workflows/ci.yml`
- `.github/workflows/release.yml`
- `packages/portless/package.json`
- `packages/portless/vitest.config.ts`
- `packages/portless/src/cli.ts`
- `packages/portless/src/proxy.ts`
- `packages/portless/src/routes.ts`
- `packages/portless/src/certs.ts`
- `packages/portless/src/hosts.ts`
- `packages/portless/src/mcp.ts`
- `packages/portless/src/upstream-pool.ts`
- `packages/portless/src/cli-utils.ts`
- `packages/portless/src/utils.ts`
- `packages/portless/src/child-env.ts`
- `packages/portless/src/tunnel.ts`
- `tests/e2e/package.json`
