Command Injection Affecting check-branches package, versions *


Severity

Recommended
0.0
critical
0
10

CVSS assessment made by Snyk's Security Team

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-JS-CHECKBRANCHES-2766494
  • published 5 Sep 2024
  • disclosed 18 Apr 2022
  • credit Liran Tal

Introduced: 18 Apr 2022

CVE NOT AVAILABLE CWE-78 Open this link in a new tab
First added by Snyk

How to fix?

There is no fixed version for check-branches.

Overview

check-branches is a CLI to automatically check if your current repo branch has any conflicts with all other repo's branches. Really useful when working with big teams.

Affected versions of this package are vulnerable to Command Injection. check-branches is a command-line tool that is interacted with locally, or via CI, to confirm no conflicts exist in git branches.

However, the library follows these conventions which can be abused:

  1. It trusts branch names as they are (plain text)
  2. It spawns git commands by concatenating user input

Since a branch name is potentially a user input - as users can create branches remotely via pull requests, or simply due to privileged access to a repository - it can effectively be abused to run any command.

PoC:

  1. Install check-branches@0.0.19, which is the latest.
npm install -g check-branches
  1. Make sure there's a valid git repository with remotes configured and at least one valid branch created

  2. Create a new git branch as follows: git checkout -b ";{echo,hello,world}>/tmp/d" (these characters are indeed valid in git branch names)

  3. Run the check-branches program in the git project directory check-branches, and observe output similar to:

❯ check-branches
********************************
* check-branches CLI v0.0.19 *
********************************

✔ generating report Wow! Congratulations! Your current branch has no conflicts with any other liran-test-repo repo branches! time for 'check': 151ms

  1. Confirm that the file /tmp/d was created with the contents of hello world in it.

References

CVSS Scores

version 3.1
Expand this section

Snyk

Recommended
9.8 critical
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    High
  • Integrity (I)
    High
  • Availability (A)
    High