{"record":{"id":"c648d9ed22326c07","repo":"JuliusBrussee/caveman","slug":"signature-check-failed-for-checksums-txt-refusin-c648d9","errorCode":null,"errorMessage":"signature check failed for checksums.txt — refusing to install","messagePattern":"signature check failed for checksums\\.txt — refusing to install","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/shared/binary-installer/installer.mjs","lineNumber":198,"sourceCode":"  }\n  const found = onPath(name);\n  if (found) return found;\n  const binDir = join(process.env.CAVEMAN_HOME ?? join(homedir(), \".caveman\"), \"bin\");\n  const target = join(binDir, binaryInstallFilename(name));\n  if (executable(target)) return target;\n\n  const { os, arch } = targetPlatform();\n  const artifact = `${name}_${os}_${arch}`;\n  const base = (process.env.CAVE_BINARY_RELEASE_BASE ?? BINARY_RELEASE_BASE_DEFAULT).replace(/\\/+$/, \"\");\n  const release = `${base}/${BINARY_RELEASE}`;\n  const timeout = timeoutMs();\n  const [checksumsResponse, signatureResponse] = await Promise.all([\n    asset(`${release}/checksums.txt`, timeout),\n    asset(`${release}/checksums.txt.keysig`, timeout),\n  ]);\n  const [checksums, signature] = await Promise.all([checksumsResponse.text(), signatureResponse.text()]);\n  if (!signedDigest(checksums, signature)) {\n    throw new Error(\"signature check failed for checksums.txt — refusing to install\");\n  }\n  const expected = expectedDigest(checksums, artifact);\n  mkdirSync(binDir, { recursive: true });\n  // Per-process part path, and NO pre-unlink. A fixed `${target}.part` plus a\n  // cleanup() immediately before an O_CREAT|O_EXCL open made the exclusivity\n  // guard unreachable: two concurrent installs (npx -y caveman-mcp is registered\n  // per MCP session, so several agents can start one at once) raced — B unlinked\n  // A's directory entry and created its own inode, A hashed ITS OWN bytes and\n  // matched, and then the PATH-based chmod+rename published B's half-written file\n  // as \"checksum verified\". Both the chmod and the rename now act on a name only\n  // this process can own.\n  //\n  // ponytail: a SIGKILL mid-download now leaves one stray .part behind instead of\n  // reusing the fixed name. Sweep binDir for stale .part files if that ever shows\n  // up in the wild.\n  const part = `${target}.${process.pid}.${randomBytes(6).toString(\"hex\")}.part`;\n  try {\n    const actual = await download(`${release}/${artifact}`, part, timeout);","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/binary-installer/installer.mjs#L180-L216","documentation":"Before trusting checksums.txt, `ensureBinary` also downloads `checksums.txt.keysig` and passes both to `signedDigest(checksums, signature)`, which verifies the signature (e.g. minisign-style signed digest). If verification fails, the installer refuses to install — treating the manifest as tampered, forged, or unparseable. This is the supply-chain trust root for the whole download.","triggerScenarios":"Calling `ensureBinary()` when `signedDigest(checksums, signature)` returns falsy: signature file content doesn't verify against the embedded public key, the .keysig download returned an error page (which then fails parsing as a signature), the manifest was regenerated with a different signing key, or a proxy altered the manifest bytes in transit.","commonSituations":"Corporate TLS-intercepting proxies modifying response bodies; release re-signed with a rotated key while installed copies still verify the old key; captive portal/auth pages served for the .keysig URL; CDN caching a checksums.txt from one release with the .keysig of another (mismatched pair fetched via cached URLs).","solutions":["curl both `${release}/checksums.txt` and `${release}/checksums.txt.keysig` and confirm they are the expected plain-text manifest and signature, not an HTML error page.","Clear any intermediate cache/proxy (or fetch with cache-busting) so the manifest and signature come from the same release.","If the release was legitimately re-signed, update to an installer version that trusts the new key.","Check that you are hitting the official release host and not a mirror that alters content.","As a last resort, install the binary manually and export the envVar override."],"exampleFix":"// before: mismatched cached pair\n// checksums.txt (v1.2.0) + .keysig (v1.1.0) -> verification fails\n// after: bust cache and refetch the consistent pair\ncurl -H \"Cache-Control: no-cache\" \"$RELEASE/checksums.txt\" -o checksums.txt\ncurl -H \"Cache-Control: no-cache\" \"$RELEASE/checksums.txt.keysig\" -o checksums.txt.keysig","handlingStrategy":"try-catch","validationCode":"const [txt, sig] = await Promise.all([\n  fetch(`${release}/checksums.txt`).then(r => r.text()),\n  fetch(`${release}/checksums.txt.keysig`).then(r => r.text()),\n]);\nif (!txt.startsWith(\"untrusted comment\") && !/^[a-f0-9]{64} /m.test(txt)) {\n  throw new Error(\"checksums.txt or signature looks wrong (proxy/portal page?)\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ensureBinary({ name, envVar });\n} catch (e) {\n  if (String(e.message).includes(\"refusing to install\")) {\n    // treat as potential tampering: do NOT bypass silently\n    console.error(\"Signature verification failed; verify release host and proxy, then retry.\");\n    throw e;\n  }\n  throw e;\n}","preventionTips":["Never disable signature verification to work around this error; find why it fails.","Watch for TLS-intercepting proxies on CI runners that alter download bytes.","Update installed tooling when the release signing key is rotated.","Fetch manifest and signature from the same origin without caching layers in between."],"tags":["supply-chain","signature","security"],"backgroundTag":"checksum-mismatch","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"}