{"record":{"id":"036c640dad80319c","repo":"JuliusBrussee/caveman","slug":"cave-gateway-identity-unverified","errorCode":"cave_gateway_identity_unverified","errorMessage":"cave_gateway_identity_unverified: non-loopback gateway ${gatewayURL} requires https","messagePattern":"cave_gateway_identity_unverified: non-loopback gateway (.+?) requires https","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/runtime.ts","lineNumber":5221,"sourceCode":"  });\n  return probe;\n}\n\nexport async function ensureCaveRuntime(\n  gatewayURL: string,\n  fetchImpl: typeof globalThis.fetch,\n): Promise<GatewayProviderBilling> {\n  const url = new URL(gatewayURL);\n  const loopback = isLoopbackHostname(url.hostname);\n  if (!loopback) {\n    // A non-loopback gateway is never taken on faith: routing there sends the\n    // provider credential plus every x-cave-* header to that host, so it must\n    // prove Caveman identity before it gets any traffic. Plain http cannot\n    // authenticate the peer at all, and an https host that fails the\n    // /health/ready identity handshake is equally unverified — both fail\n    // closed here so resolveCaveRoute degrades to observe-only passthrough.\n    if (url.protocol !== \"https:\") {\n      throw new Error(\n        `cave_gateway_identity_unverified: non-loopback gateway ${gatewayURL} requires https`,\n      );\n    }\n    const identity = await gatewayIdentity(gatewayURL, fetchImpl);\n    if (identity !== undefined) return identity.providerBilling;\n    throw new Error(\n      `cave_gateway_identity_unverified: ${gatewayURL}/health/ready did not identify as caveman-proxy`,\n    );\n  }\n  const readyBilling = await runtimeReady(gatewayURL, fetchImpl);\n  if (readyBilling !== undefined) return readyBilling;\n\n  const command = process.env.CAVEMAN_CLI_BIN ?? \"caveman\";\n  let startupFailure: Error | undefined;\n  let invocation;\n  try {\n    invocation = portableInvocation(command, [\"start\"], { env: buildRuntimeControlEnv() });\n  } catch (error) {","sourceCodeStart":5203,"sourceCodeEnd":5239,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/runtime.ts#L5203-L5239","documentation":"For non-loopback gateway hosts, the runtime requires https because it forwards the provider credential plus all x-cave-* headers to that host, and the peer must prove Caveman identity. Plain http cannot authenticate the peer at all, so resolveCaveRoute fails closed with this error rather than leaking credentials to an unauthenticated host.","triggerScenarios":"Configuring gatewayURL with an http:// scheme whose host is not loopback (not 127.0.0.1/localhost/::1), so the credential-forwarding path refuses to trust it.","commonSituations":"Pointing the gateway at a LAN or remote machine with http://; copy-pasting an internal http URL into CAVEMAN gateway config; TLS termination misconfigured so only http is served.","solutions":["Serve the gateway over https (TLS cert on the gateway, or put it behind an https reverse proxy)","Update gatewayURL to https:// in the runtime/agent config","If the gateway is truly local, use a loopback host (127.0.0.1 or localhost), which is exempt from the https requirement"],"exampleFix":"// before\nconst gatewayURL = 'http://gateway.internal:7788';\n// after\nconst gatewayURL = 'https://gateway.internal:7788';","handlingStrategy":"validation","validationCode":"const u = new URL(gatewayURL);\nconst isLoopback = ['127.0.0.1','localhost','::1'].includes(u.hostname);\nif (!isLoopback && u.protocol !== 'https:') throw new Error('non-loopback gateway must be https');","typeGuard":"function isSecureGateway(url: string): boolean {\n  const u = new URL(url);\n  return u.protocol === 'https:' || ['127.0.0.1','localhost','::1'].includes(u.hostname);\n}","tryCatchPattern":null,"preventionTips":["Default all non-loopback gateway URLs to https in config templates","Terminate TLS at the gateway or a reverse proxy","Restrict non-https gateways to loopback hosts in dev only"],"tags":["security","tls","gateway","configuration"],"backgroundTag":"invalid-url","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}