Skip to content

fix(security): replace exec with execFile for git commands - #162

Draft
prathamesh04 wants to merge 2 commits into
metacall:masterfrom
prathamesh04:fix/exec-to-execfile
Draft

fix(security): replace exec with execFile for git commands#162
prathamesh04 wants to merge 2 commits into
metacall:masterfrom
prathamesh04:fix/exec-to-execfile

Conversation

@prathamesh04

Copy link
Copy Markdown
Contributor

Description

Repository endpoints were using shell-based exec for git commands, allowing command injection through crafted URLs or branch names. Even with input validation, the shell remains a security risk.

Fixes #111

Changes

  • Add execFile utility as safe alternative to exec
  • Replace all exec calls with execFile using argument arrays
  • No shell involved, so metacharacters in arguments are harmless
  • Keep existing URL/branch validators for additional defense

Security Impact

This is a critical security fix that prevents:

  • Command injection through crafted git URLs
  • Command injection through crafted branch names
  • Shell metacharacter exploitation

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Build passes (npm run build)
  • Lint passes (npm run lint)

Fixes infinite loop in assignColorToWorker when all 16 ANSI colors
are allocated. Previously, the do...while loop would spin forever
looking for an unassigned color, blocking the Node.js event loop
and hanging the server at 17+ concurrent deployments.

Changes:
- Replace random retry with deterministic round-robin index
- Remove assignedColorCodes tracking map (no longer needed)
- Remove unused AssignedColorCodesType interface
- Remove stale TODO comments

Colors cycle safely when more than 16 deployments are active.

Fixes metacall#116
Repository endpoints were using shell-based exec for git commands,
allowing command injection through crafted URLs or branch names.
Even with input validation, the shell remains a security risk.

Changes:
- Add execFile utility as safe alternative to exec
- Replace all exec calls with execFile using argument arrays
- No shell involved, so metacharacters in arguments are harmless
- Keep existing URL/branch validators for additional defense

Fixes metacall#111
@prathamesh04

Copy link
Copy Markdown
Contributor Author

cc @viferga @josead

@viferga

viferga commented Aug 3, 2026

Copy link
Copy Markdown
Member

You have mixed two commits in the same one, the previous PR and the current one, if you push only the execFile change, I will merge it. @prathamesh04

@viferga
viferga marked this pull request as draft August 3, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: Repository endpoints still use shell-based exec for git commands despite input validation.

2 participants