T03 · Remote Payload Retrieval and Execution
Error
- Location
- scripts/bootstrap.ts:267
- Finding
- Unverified Remote Code Is Downloaded and Executed During Bootstrap<![CDATA[ ## Vulnerability Details **File Location**: `scripts/bootstrap.ts:267-350` **Vulnerability Type**: Remote payload retrieval and insecure dependency installation **Risk Level**: High ### Vulnerable Code ```ts function downloadViaNpm(skill: SkillCatalogEntry, targetDir: string): { ok: boolean; message: string } { const tmpDir = mkdtempSync(path.join(os.tmpdir(), 'aelf-skills-pack-')); const packageRef = `${skill.npm.name}@${skill.npm.version}`; const packResult = runCommand('npm', ['pack', packageRef, '--pack-destination', tmpDir]); if (!packResult.ok) { return { ok: false, message: packResult.stderr || packResult.stdout || `npm pack failed for ${packageRef}`, }; } const lines = packResult.stdout .split(/\r?\n/) .map(value => value.trim()) .filter(Boolean); const tarballName = lines[lines.length - 1]; const tarballPath = path.join(tmpDir, tarballName); const extractResult = runCommand('tar', ['-xzf', tarballPath, '-C', targetDir, '--strip-components=1']); if (!extractResult.ok) { return { ok: false, message: extractResult.stderr || extractResult.stdout || `tar extract failed for ${packageRef}`, }; } rmSync(tmpDir, { recursive: true, force: true }); return { ok: true, message: `downloaded via npm: ${packageRef}`, }; } function downloadViaGithub(skill: SkillCatalogEntry, targetDir: string): { ok: boolean; message: string } { if (!skill.repository.https) { return { ok: false, message: 'repository.https is missing', }; } const cloneResult = runCommand('git', ['clone', '--depth', '1', skill.repository.https, targetDir]); if (!cloneResult.ok) { return { ok: false, message: cloneResult.stderr || cloneResult.stdout || `git clone failed for ${skill.repository.https}`, }; } return { ok: true, message: `downloaded via github: ${skill.repository.https}`, }; } function installSkillDependencies(skillDir: str ...[truncated 2795 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Validate every catalog against a strict schema before using it. 2. Permit only explicitly approved npm scopes, package names, repository hosts, and repository owners. 3. Pin GitHub sources to reviewed commit hashes rather than cloning a mutable default branch. 4. Record and verify npm tarball integrity hashes or trusted package provenance before extraction. 5. Treat custom catalogs as untrusted and require an explicit high-risk confirmation before downloading or installing their entries. 6. Disable dependency lifecycle scripts by default using the package manager's supported safe-install option. Require a separate, explicit opt-in when scripts are necessary. 7. Perform installation in a sandbox or container with minimal filesystem access, no inherited secrets, and restricted network access. 8. Audit the downloaded package manifest and lockfile before dependency installation. 9. Prefer lockfile-based, frozen dependency resolution so transitive packages cannot silently change. 10. Clearly document that omitting `--skip-install` executes third-party installation logic. ]]>
