Skip to content

fix(packages): shell command built from environment values #12386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

odaysec
Copy link

@odaysec odaysec commented May 30, 2025

Fix the issue should avoid dynamically constructing the shell command. Instead, we can use execFile or execFileSync, which allows us to pass arguments as an array, avoiding shell interpretation of special characters. This ensures that the folderPath is treated as a literal argument and not subject to command injection.

Specifically:

  1. Replace the use of execPromise with execFilePromise (a promisified version of execFile).
  2. Modify the addToGit method to pass the folderPath as an argument to git add instead of interpolating it into the command string.

Copy link
Contributor

Welcome!

Hello there, congrats on your first PR! We're excited to have you contributing to this project.
By submitting your Pull Request, you acknowledge that you agree with the terms of our Contributor License Agreement.

Generated by 🚫 dangerJS against 4f574f6

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Security improvement to prevent command injection by replacing dynamic shell command construction with execFile in the serverless package management system.

  • The installPackages method still uses unsafe execPromise with string interpolation for yarn commands, leaving a potential command injection vulnerability
  • Consider using execFilePromise for yarn commands with arguments passed as an array: ['add', packageName]
  • Add input validation for package names to prevent malicious input
  • Consider implementing error handling for failed git operations in addToGit method

1 file reviewed, no comments
Edit PR Review Bot Settings | Greptile

Copy link
Contributor

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:4908

This environment will automatically shut down when the PR is closed or after 5 hours.

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.

1 participant