T08 · Insecure Dependencies
- Location
scripts/main.ts:399- Finding
Unpinned Third-Party Packages Are Downloaded and Executed at Runtime
- Content
View full analysis
Vulnerability Details
File Location:
scripts/main.ts:399-422andscripts/main.ts:661-687
Vulnerability Type: Unpinned runtime dependency execution
Risk Level: MediumVulnerable Code
ts async function extractAsar( asarPath: string, dest: string, json: boolean ): Promise<void> { mkdirSync(dest, { recursive: true }); const args = ["-y", "@electron/asar", "extract", asarPath, dest]; const code = json ? await new Promise<number>((res) => { const p = spawn("npx", args, { stdio: ["ignore", "ignore", "pipe"] }); let err = ""; p.stderr?.on("data", (d) => (err += d.toString())); p.on("close", (c) => { if ((c ?? 1) !== 0) process.stderr.write(err); res(c ?? 1); }); p.on("error", (e) => { process.stderr.write(e.message); res(1); }); }) : await runForwarded("npx", args); if (code !== 0) throw new Error(`@electron/asar extract failed (code ${code})`); }ts function formatBatches(files: string[], json: boolean): Promise<void> { const maxArgLen = 50_000; let batch: string[] = []; let len = 0; const flush = async () => { if (batch.length === 0) return; const args = ["-y", "prettier", "--write", ...batch]; const code = json ? await new Promise<number>((res) => { const p = spawn("npx", args, { stdio: ["ignore", "ignore", "pipe"] }); let err = ""; p.stderr?.on("data", (d) => (err += d.toString())); p.on("close", (c) => { if ((c ?? 1) !== 0) process.stderr.write(err); res(c ?? 1); }); p.on("error", (e) => { process.stderr.write(e.message); res(1); }); }) : await runForwarded("npx", args);Technical
...[truncated 1853 chars]
- Remediation
View remediation
Remediation Suggestions
- Declare exact, reviewed versions of Bun,
@electron/asar, and Prettier in a project manifest. - Commit a lockfile containing resolved versions and integrity hashes.
- Install dependencies using lockfile-enforcement options such as
npm cior the equivalent trusted package-manager command. - Invoke project-local binaries rather than using
npx -yto retrieve packages on demand. - Configure the package manager to use a trusted registry and preserve integrity verification.
- Require an already installed, trusted runtime instead of automatically retrieving Bun through
npx. - Periodically review and deliberately update pinned dependencies after security testing.
- Declare exact, reviewed versions of Bun,
