From d9fd3595655706923a97595d2b7b05c17dfd0424 Mon Sep 17 00:00:00 2001 From: Reuven Date: Sun, 3 May 2026 20:18:56 -0400 Subject: [PATCH] fix(security): add fetch timeouts to verify + IPFS HEAD probe (audit_1776853149979) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two no-timeout fetch sites a hung remote could pin indefinitely: src/commands/verify.ts:fetchWitness Bare fetch(url) for the verification manifest. Now AbortSignal.timeout(30000) — a sub-MB JSON over a public CDN should never need more than 30s, and we'd rather fail fast than hang the verify CLI. src/transfer/ipfs/upload.ts:checkContent HEAD probe to an IPFS gateway, no timeout. Now AbortSignal.timeout(10000) — HEAD without a body has no excuse to take longer. Other no-timeout sites (download.ts streaming, upload.ts large POSTs) are deliberately left alone — an absolute timeout would falsely abort slow but progressing transfers of large blobs. Those need a connect-vs-transfer timeout split, deferred to a separate change. Verified: - tsc --noEmit clean --- v3/@claude-flow/cli/src/commands/verify.ts | 4 +++- v3/@claude-flow/cli/src/transfer/ipfs/upload.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/v3/@claude-flow/cli/src/commands/verify.ts b/v3/@claude-flow/cli/src/commands/verify.ts index d3c3c798f1..a2b84b95b1 100644 --- a/v3/@claude-flow/cli/src/commands/verify.ts +++ b/v3/@claude-flow/cli/src/commands/verify.ts @@ -56,7 +56,9 @@ const DEFAULT_MANIFEST_URL = 'https://raw.githubusercontent.com/ruvnet/ruflo/{br async function fetchWitness(branch: string): Promise { const url = DEFAULT_MANIFEST_URL.replace('{branch}', branch); - const res = await fetch(url); + // audit_1776853149979: bare fetch had no timeout — a hung GitHub CDN would + // pin the verify command indefinitely. 30s is generous for a sub-MB JSON. + const res = await fetch(url, { signal: AbortSignal.timeout(30000) }); if (!res.ok) { throw new Error(`Failed to fetch manifest from ${url}: ${res.status} ${res.statusText}`); } diff --git a/v3/@claude-flow/cli/src/transfer/ipfs/upload.ts b/v3/@claude-flow/cli/src/transfer/ipfs/upload.ts index ccd6088216..e6cdc45055 100644 --- a/v3/@claude-flow/cli/src/transfer/ipfs/upload.ts +++ b/v3/@claude-flow/cli/src/transfer/ipfs/upload.ts @@ -381,6 +381,8 @@ export async function checkContent( try { const response = await fetch(`${gateway}/ipfs/${cid}`, { method: 'HEAD', + // audit_1776853149979: HEAD probe should never hang; 10s upper bound. + signal: AbortSignal.timeout(10000), }); if (response.ok) {