Skip to content

Security: Argument Injection in git add command#555

Open
tomaioo wants to merge 1 commit into
semantic-release:masterfrom
tomaioo:fix/security/argument-injection-in-git-add-command
Open

Security: Argument Injection in git add command#555
tomaioo wants to merge 1 commit into
semantic-release:masterfrom
tomaioo:fix/security/argument-injection-in-git-add-command

Conversation

@tomaioo

@tomaioo tomaioo commented Jul 22, 2026

Copy link
Copy Markdown

Summary

Security: Argument Injection in git add command

Problem

Severity: High | File: lib/git.js:L26

In lib/git.js, the add function passes the files array directly into the execa arguments for git add. If a file path contains strings that start with - (e.g., -u or --all), git may interpret them as command-line options rather than file paths. This can lead to argument injection, potentially allowing unintended files to be staged or other git options to be triggered.

Solution

Prepend -- to the git arguments before the file list to explicitly mark the end of options and treat all subsequent arguments as file paths. For example: ['add', '--force', '--ignore-errors', '--', ...files].

Changes

  • lib/git.js (modified)

In `lib/git.js`, the `add` function passes the `files` array directly into the `execa` arguments for `git add`. If a file path contains strings that start with `-` (e.g., `-u` or `--all`), `git` may interpret them as command-line options rather than file paths. This can lead to argument injection, potentially allowing unintended files to be staged or other git options to be triggered.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
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