CVE-2024-29895
CVE-2024-29895
Weakness (CWE)
CVSS Vector
v3.1- Attack Vector
- Network
- Attack Complexity
- Low
- Privileges Required
- None
- User Interaction
- None
- Scope
- Changed
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Description
Cacti provides an operational monitoring and fault management framework. A command injection vulnerability on the 1.3.x DEV branch allows any unauthenticated user to execute arbitrary command on the server when `register_argc_argv` option of PHP is `On`. In `cmd_realtime.php` line 119, the `$poller_id` used as part of the command execution is sourced from `$_SERVER['argv']`, which can be controlled by URL when `register_argc_argv` option of PHP is `On`. And this option is `On` by default in many environments such as the main PHP Docker image for PHP. Commit 53e8014d1f082034e0646edc6286cde3800c683d contains a patch for the issue, but this commit was reverted in commit 99633903cad0de5ace636249de16f77e57a3c8fc.
Comprehensive Technical Analysis of CVE-2024-29895
1. Vulnerability Assessment and Severity Evaluation
CVE ID: CVE-2024-29895 CVSS Score: 10
Severity Evaluation: The CVSS score of 10 indicates a critical vulnerability. This score reflects the high impact and ease of exploitation, making it a top priority for remediation. The vulnerability allows unauthenticated users to execute arbitrary commands on the server, which can lead to complete system compromise.
Vulnerability Type: Command Injection
Affected Component:
Cacti, an operational monitoring and fault management framework, specifically in the cmd_realtime.php script.
2. Potential Attack Vectors and Exploitation Methods
Attack Vector:
The vulnerability can be exploited by any unauthenticated user who can manipulate the $poller_id parameter in the URL. This parameter is sourced from $_SERVER['argv'], which can be controlled via the URL when the register_argc_argv option of PHP is enabled.
Exploitation Methods:
- URL Manipulation: An attacker can craft a URL that includes malicious commands as part of the
$poller_idparameter. - Command Injection: The malicious commands are then executed on the server, allowing the attacker to perform actions such as reading sensitive files, modifying system settings, or installing malware.
Example Exploit:
http://example.com/cmd_realtime.php?poller_id=`id`
This URL would execute the id command on the server, revealing the user ID of the process running the web server.
3. Affected Systems and Software Versions
Affected Software: Cacti 1.3.x DEV branch
Affected Environments:
- Systems where the
register_argc_argvoption of PHP is enabled. - Environments using the main PHP Docker image, as this option is enabled by default.
Specific Versions:
- Cacti 1.3.x DEV branch before the patch in commit
53e8014d1f082034e0646edc6286cde3800c683d. - Note: The patch was reverted in commit
99633903cad0de5ace636249de16f77e57a3c8fc, so systems using versions after this reversion are also vulnerable.
4. Recommended Mitigation Strategies
Immediate Mitigation:
- Disable
register_argc_argv: Ensure that theregister_argc_argvoption in PHP is set toOff. This can be done by modifying thephp.iniconfiguration file:register_argc_argv = Off - Update Cacti: Apply the patch from commit
53e8014d1f082034e0646edc6286cde3800c683dmanually, even though it was reverted. This involves modifying thecmd_realtime.phpscript to sanitize the$poller_idparameter.
Long-Term Mitigation:
- Regular Patching: Ensure that all software, including Cacti and PHP, is regularly updated to the latest stable versions.
- Input Validation: Implement robust input validation and sanitization mechanisms to prevent command injection attacks.
- Least Privilege: Run the web server and Cacti with the least privileges necessary to minimize the impact of a successful exploit.
5. Impact on Cybersecurity Landscape
Immediate Impact:
- System Compromise: Unauthenticated attackers can gain full control over affected systems, leading to data breaches, unauthorized access, and potential deployment of malware.
- Operational Disruption: Compromised monitoring systems can lead to operational disruptions and loss of visibility into network and system health.
Long-Term Impact:
- Increased Awareness: This vulnerability highlights the importance of secure coding practices and the need for regular security audits.
- Patch Management: Organizations will need to prioritize patch management and ensure that all software dependencies are regularly updated.
6. Technical Details for Security Professionals
Vulnerable Code Snippet:
// cmd_realtime.php line 119
$poller_id = $_SERVER['argv'][1];
system("poller_command --poller-id=" . $poller_id);
Patch Details:
The patch in commit 53e8014d1f082034e0646edc6286cde3800c683d likely involves sanitizing the $poller_id parameter to prevent command injection. For example:
$poller_id = escapeshellarg($_SERVER['argv'][1]);
system("poller_command --poller-id=" . $poller_id);
Detection and Monitoring:
- Log Analysis: Monitor server logs for unusual command executions or errors related to the
cmd_realtime.phpscript. - Intrusion Detection: Implement intrusion detection systems (IDS) to detect and alert on suspicious activities related to command injection.
- Network Monitoring: Use network monitoring tools to detect unusual outbound connections or data exfiltration attempts.
Conclusion:
CVE-2024-29895 represents a critical vulnerability that requires immediate attention. Organizations should prioritize mitigation efforts, including disabling the register_argc_argv option and applying the necessary patches. Regular security audits and adherence to best practices in secure coding and patch management are essential to prevent similar vulnerabilities in the future.