Security
Headlines
HeadlinesLatestCVEs

Headline

CVE-2022-24828: Merge pull request from GHSA-x7cr-6qr6-2hh6 · composer/composer@2c40c53

Composer is a dependency manager for the PHP programming language. Integrators using Composer code to call VcsDriver::getFileContent can have a code injection vulnerability if the user can control the $file or $identifier argument. This leads to a vulnerability on packagist.org for example where the composer.json’s readme field can be used as a vector for injecting parameters into hg/Mercurial via the $file argument, or git via the $identifier argument if you allow arbitrary data there (Packagist does not, but maybe other integrators do). Composer itself should not be affected by the vulnerability as it does not call getFileContent with arbitrary data into $file/$identifier. To the best of our knowledge this was not abused, and the vulnerability has been patched on packagist.org and Private Packagist within a day of the vulnerability report.

CVE
#vulnerability#js#git#php

@@ -0,0 +1,81 @@ <?php
namespace Composer\Test\Repository\Vcs;
use Composer\Config; use Composer\Repository\Vcs\GitDriver; use Composer\Test\Mock\ProcessExecutorMock; use Composer\Test\TestCase;
class GitDriverTest extends TestCase { /** @var Config */ private $config; /** @var string */ private $home;
public function setUp() { $this->home = self::getUniqueTmpDirectory(); $this->config = new Config(); $this->config->merge(array( ‘config’ => array( ‘home’ => $this->home, ), )); }
public function testGetBranchesFilterInvalidBranchNames() { $process = new ProcessExecutorMock; $io = $this->getMockBuilder(‘Composer\IO\IOInterface’)->getMock();
$driver = new GitDriver(array(‘url’ => ‘https://example.org/acme.git’), $io, $this->config, $this->getMockBuilder(‘Composer\Util\HttpDownloader’)->disableOriginalConstructor()->getMock(), $process); $this->setRepoDir($driver, $this->home);
// Branches starting with a - character are not valid git branches names // Still assert that they get filtered to prevent issues later on $stdout = <<<GIT * main 089681446ba44d6d9004350192486f2ceb4eaa06 commit 2.2 12681446ba44d6d9004350192486f2ceb4eaa06 commit -h 089681446ba44d6d9004350192486f2ceb4eaa06 commit GIT;
$process ->expects(array(array( ‘cmd’ => 'git branch --no-color --no-abbrev -v’, ‘stdout’ => $stdout, )));
$branches = $driver->getBranches(); $this->assertSame(array( ‘main’ => '089681446ba44d6d9004350192486f2ceb4eaa06’, ‘2.2’ => '12681446ba44d6d9004350192486f2ceb4eaa06’, ), $branches); }
public function testFileGetContentInvalidIdentifier() { $this->expectException(‘\RuntimeException’);
$process = new ProcessExecutorMock; $io = $this->getMockBuilder(‘Composer\IO\IOInterface’)->getMock(); $driver = new GitDriver(array(‘url’ => ‘https://example.org/acme.git’), $io, $this->config, $this->getMockBuilder(‘Composer\Util\HttpDownloader’)->disableOriginalConstructor()->getMock(), $process);
$this->assertNull($driver->getFileContent('file.txt’, ‘h’));
$driver->getFileContent(‘file.txt’, '-h’); }
/** * @param GitDriver $driver * @param string $path */ private function setRepoDir($driver, $path)

Check failure on line 74 in tests/Composer/Test/Repository/Vcs/GitDriverTest.php

** GitHub Actions / PHPStan (7.4)**

tests/Composer/Test/Repository/Vcs/GitDriverTest.php#L74

Method Composer\Test\Repository\Vcs\GitDriverTest::setRepoDir() has no return type specified.

{ $reflectionClass = new \ReflectionClass($driver); $reflectionProperty = $reflectionClass->getProperty(‘repoDir’); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($driver, $path); } }

Related news

Researchers Report Supply Chain Vulnerability in Packagist PHP Repository

Researchers have disclosed details about a now-patched high-severity security flaw in Packagist, a PHP software package repository, that could have been exploited to mount software supply chain attacks. "This vulnerability allows gaining control of Packagist," SonarSource researcher Thomas Chauchefoin said in a report shared with The Hacker News. Packagist is used by the PHP package manager

CVE: Latest News

CVE-2023-50976: Transactions API Authorization by oleiman · Pull Request #14969 · redpanda-data/redpanda
CVE-2023-6905
CVE-2023-6903
CVE-2023-6904
CVE-2023-3907