日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
PHP Composer漏洞可能引發(fā)供應(yīng)鏈攻擊

Composer是PHP中管理和安全軟件依賴的主要工具,被開發(fā)團隊廣泛應(yīng)用于更新過程等。因此,Composer使用名為Packagist 的在線服務(wù)來確定包下載供應(yīng)鏈的正確性。而Packagist每個月的下載請求在14億次左右。

研究人員在進行安全研究時,在 Packagist使用的Composer源碼中發(fā)現(xiàn)了一個嚴重的安全漏洞,漏洞CVE編號為CVE-2021-29472。攻擊者利用該漏洞可以在Packagist.org 服務(wù)器上執(zhí)行任意系統(tǒng)命令。此外,攻擊者還可以進一步竊取維護者憑證,或?qū)螺d重定向到傳播后門依賴的第三方服務(wù)器。

漏洞分析

在請求下載包時,Composer 首先會查詢Packagist來獲取元數(shù)據(jù)。元數(shù)據(jù)中包含2個獲取代碼源的域source和dist。Source只想開發(fā)庫,dist只想預(yù)構(gòu)建的庫。Composer在從庫中下載代碼時會使用外部系統(tǒng)命令來避免重新實現(xiàn)針對每隔版本控制軟件的邏輯。因此,這些調(diào)用都是用wrapper ProcessExecutor來執(zhí)行的:

 
 
 
  1. composer/src/Composer/Util/ProcessExecutor.php 
  2.   
  3. use Symfony\Component\Process\Process; 
  4. // [...] 
  5. class ProcessExecutor 
  6.     // [...] 
  7.     public function execute($command, &$output = null, $cwd = null) 
  8.     { 
  9.         if (func_num_args() > 1) { 
  10.             return $this->doExecute($command, $cwd, false, $output); 
  11.         } 
  12.         return $this->doExecute($command, $cwd, false); 
  13.     } 
  14.     // [...] 
  15.     private function doExecute($command, $cwd, $tty, &$output = null) 
  16.     { 
  17.         // [...] 
  18.         if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) { 
  19.             // [1] 
  20.             $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout()); 
  21.         } else { 
  22.             // [2] 
  23.             $process = new Process($command, $cwd, null, null, static::getTimeout()); 
  24.         } 
  25.         if (!Platform::isWindows() && $tty) { 
  26.             try { 
  27.                 $process->setTty(true); 
  28.             } catch (RuntimeException $e) { 
  29.                 // ignore TTY enabling errors 
  30.             } 
  31.         } 
  32.         $callback = is_callable($output) ? $output : array($this, 'outputHandler'); 
  33.         $process->run($callback); 

在 [1]和[2]中,可以看到參數(shù) $command 是在shell中執(zhí)行的。大多數(shù)的ProcessExecutor 調(diào)用都是在版本控制軟件驅(qū)動中執(zhí)行的,版本控制軟件負載原創(chuàng)和本地庫的所有操作。比如,在Git驅(qū)動中:

 
 
 
  1. composer/src/Composer/Repository/Vcs/GitDriver.php 
  2.   
  3. public static function supports(IOInterface $io, Config $config, $url, $deep = false) 
  4.     if (preg_match('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) { 
  5.         return true; 
  6.     } 
  7.     // [...] 
  8.     try { 
  9.         $gitUtil->runCommand(function ($url) { 
  10.             return 'git ls-remote --heads ' . ProcessExecutor::escape($url); // [1] 
  11.         }, $url, sys_get_temp_dir()); 
  12.     } catch (\RuntimeException $e) { 
  13.         return false; 
  14.     } 

使用ProcessExecutor::escape() 可以將參數(shù)$url 逃逸以預(yù)防子命令($(...), `...`) ,但是無法預(yù)防用戶提供(--)開頭的值,只要加上其他的參數(shù)就可以成為最終的命令。這類漏洞就叫做參數(shù)注入。

類似的有漏洞的模式也出現(xiàn)在其他驅(qū)動中,用戶控制的數(shù)據(jù)可以成功繞過檢查并連接在一起成為系統(tǒng)命令:

 
 
 
  1. composer/src/Composer/Repository/Vcs/SvnDriver.php 
  2. public static function supports(IOInterface $io, Config $config, $url, $deep = false) 
  3.     $url = self::normalizeUrl($url); 
  4.     if (preg_match('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) { 
  5.         return true; 
  6.     } 
  7.     // [...] 
  8.     $process = new ProcessExecutor($io); 
  9.     $exit = $process->execute( 
  10.         "svn info --non-interactive ".ProcessExecutor::escape($url), 
  11.         $ignoredOutput 
  12.     ); 
  13. composer/src/Composer/Repository/Vcs/HgDriver.php 
  14. public static function supports(IOInterface $io, Config $config, $url, $deep = false) 
  15.     if (preg_match('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) { 
  16.         return true; 
  17.     } 
  18.     // [...] 
  19.     $process = new ProcessExecutor($io); 
  20.     $exit = $process->execute(sprintf('hg identify %s', ProcessExecutor::escape($url)), $ignored); 
  21.     return $exit === 0; 

更多技術(shù)細節(jié)參見:https://blog.sonarsource.com/php-supply-chain-attack-on-composer

補丁

研究人員將該漏洞提交給Packagist團隊后,該團隊快速反應(yīng),在12個小時內(nèi)就部署了安全補丁。

本文翻譯自:https://blog.sonarsource.com/php-supply-chain-attack-on-composer


本文題目:PHP Composer漏洞可能引發(fā)供應(yīng)鏈攻擊
本文鏈接:http://www.5511xx.com/article/cdseopd.html