mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
fix(security): add fetch timeouts to verify + IPFS HEAD probe (audit_1776853149979)
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
This commit is contained in:
1 parent
5073f56739
commit
d9fd359565
2 files changed
+5
-1
No files matched your search
@@ -56,7 +56,9 @@ const DEFAULT_MANIFEST_URL = 'https://raw.githubusercontent.com/ruvnet/ruflo/{br
|
||||
|
||||
async function fetchWitness(branch: string): Promise<Witness> {
|
||||
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}`);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user