T09 · Insecure Skill Coding Practices
- Location
scripts/install-or-upgrade.mjs:41- Finding
Shared cache directory permits a symlink race during artifact download
- Content
View full analysis
path.resolve(value)))]) { if (await writableDirectory(candidate)) return candidate; } throw new InstallError('No writable bounded plugin cache', 'PLUGIN_LOCAL_CACHE_UNAVAILABLE'); } ``` ```js async function downloadArtifact(targetPath, fetchImpl = fetch) { if ((await optionalSha256(targetPath)) === ARTIFACT_SHA256) return targetPath; const partPath = `${targetPath}.part`; await rm(partPath, { force: true }); let lastError; for (let attempt = 1; attempt <= 3; attempt += 1) { try { const response = await fetchImpl(ARTIFACT_URL, { redirect: 'follow', signal: AbortSignal.timeout(30_000), }); if (!response.ok) throw new Error(`download returned HTTP ${response.status}`); const bytes = Buffer.from(await response.arrayBuffer()); if (bytes.length === 0 || bytes.length > MAX_ARTIFACT_BYTES) { throw new Error('downloaded artifact size is outside bounds'); } const hand ...[truncated 3056 chars]- Remediation
View remediation
