Skip to content

fix Unsafe shell command constructed from library input index #14203

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: dev
Choose a base branch
from

Conversation

odaysec
Copy link
Contributor

@odaysec odaysec commented May 13, 2025

execa.commandSync(`yarn add ${dependencies.join(' ')}`, { cwd: indexPath });

fix the issue should avoid constructing the shell command as a single string and instead pass the command and its arguments as an array to execa.commandSync. This approach prevents the shell from interpreting special characters in the input, mitigating the risk of command injection. Specifically:

  1. Replace the string concatenation with an array of arguments.
  2. Use execa's execa.sync method with the command and arguments passed as separate parameters.

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies
  • Pull request labels are added

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@odaysec odaysec requested a review from a team as a code owner May 13, 2025 10:37
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