Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix: validate configured IPv4 hosts literally [H19]
Corey Olsone88674f8ad94
diff --git a/src/api.js b/src/api.jsindex 37903017..029f1990 100644--- a/src/api.js+++ b/src/api.js@@ -1,4 +1,3 @@-import { isIP } from 'node:net';/** The local API v1: the CLI's moves, persistent board identities and live events (A2). */import {createHash,@@ -872,6 +871,12 @@ function credentialMatches(candidate, expected) {return candidate.length === expected.length && timingSafeEqual(candidate, expected);}+/** Accept only canonical dotted-decimal IPv4 literals, without DNS or alternate numeric forms. */+function isLiteralIPv4(host) {+ const octets = host.split('.');+ return octets.length === 4 && octets.every(octet => /^(?:0|[1-9]\d{0,2})$/u.test(octet) && Number(octet) <= 255);+}+/** Share the local router with the person's view and other local transports; the standalone API explicitly denies person authority.* @param {{ secret: string | Buffer, getPort: () => number, runCommand: Function, projects?: () => any[], scope?: { projectRoot: string }, isMain?: boolean, allowedOrigins?: string[], allowedHosts?: string[], onStateBuild?: Function, onItemBuild?: Function, personChannel?: string, stateDetail?: string, sessionCookie?: {name:string,value:string} }} [options]*/@@ -898,7 +903,7 @@ export function createLocalApiHandler({ secret, getPort, runCommand, projects =const cookieKey = sessionCookie === undefined ? null : Buffer.from(sessionCookie.value);const permittedOrigins = new Set(allowedOrigins);// A transport may name exact literal interface addresses; DNS names, ports and wildcards are not authority.- if (!Array.isArray(allowedHosts) || allowedHosts.some(host => typeof host !== 'string' || isIP(host) !== 4 || host === '0.0.0.0')) {+ if (!Array.isArray(allowedHosts) || allowedHosts.some(host => typeof host !== 'string' || !isLiteralIPv4(host) || host === '0.0.0.0')) {throw new TypeError('createLocalApiHandler allowedHosts needs literal IPv4 addresses, without ports or wildcard binds');}const permittedHosts = [...new Set(allowedHosts)];diff --git a/test/api.test.js b/test/api.test.jsindex a14240b5..fe8314b5 100644--- a/test/api.test.js+++ b/test/api.test.js@@ -158,7 +158,7 @@ test('local API admits only configured literal IPv4 hosts at their own origin [Hconst defaulted = await startLocalHandler(t, box);const denied = await apiFetch(defaulted, '/api/v1/boards', { headers: { host, origin } });assert.equal((await apiError(denied, 401)).code, 'AUTH_REQUIRED', 'omitting the allowlist preserves loopback-only Host authority');- for (const invalid of ['localhost', '0.0.0.0', '2001:db8::1']) assert.throws(() => createLocalApiHandler({+ for (const invalid of ['localhost', '0.0.0.0', '2001:db8::1', '192.168.7', '192.168.7.256', '192.168.007.9', '192.168.7.9:80']) assert.throws(() => createLocalApiHandler({secret: randomUUID(), getPort: () => 1, runCommand: main, projects: () => [], allowedHosts: [invalid],}), TypeError, `invalid LAN host ${invalid} is rejected`);});