
CVE-2024-23897 is a critical vulnerability discovered in Jenkins, a popular continuous integration tool. This vulnerability allows remote command execution (RCE) on the Jenkins server due to a lack of proper restrictions on node access and connection functions.
CVE-ID: CVE-2024-23897Type: Remote Code Execution (RCE)Impact: An unauthenticated attacker can send specially crafted requests that allow arbitrary commands to be executed on the Jenkins server, leading to system compromise.Affected: Jenkins versions prior to the fix of this CVE.jenkins-cli.jar file, which allows communication between Jenkins and its nodes.Jenkins server.Jenkins to the latest available version that has fixed this vulnerability.This Python script exploits the CVE-2024-23897 vulnerability in outdated Jenkins servers. The script interacts with the Jenkins server and executes arbitrary commands using the jenkins-cli.jar file.
Python 3.xrequests and subprocess libraries installed in the execution environment.Jenkins vulnerable server.Download the file jenkins-cli.jar` from the Jenkins server.Connect Jenkins node using the downloaded file and execute malicious commands on the remote server.Perform specific actions such as reading arbitrary files on the server.Installing dependencies: Make sure you have Python 3 and the requests library installed. You can install it using pip:pip3 install requests
Script Usage: Download the exploitation script file and run it from the terminal:
python3 cve-2024-23897.py
The script will ask you to enter the following parameters:
Jenkins Server IP Address: The IP where Jenkins is running.Jenkins Server Port: The port that Jenkins is listening on (default is 8080).Path to read file: The path of the file you want to access on the vulnerable server (for example, /etc/passwd).The script will download the jenkins-cli.jar file from the Jenkins server and then execute the commands defined in the file you have indicated as a parameter.
To test the vulnerability in a controlled environment, we have included a Docker-based vulnerable lab. You will only need to unzip the ZIP file on your Kali Linux machine, run the .sh file, and deploy the Docker environment to perform the test.
Download the LAB .tar: First, unzip the file containing the vulnerable lab:
Run the deployment script: Inside a folder, you will have to have the 2 files, one of them auto_mount.sh. This script is designed to deploy the vulnerable Docker environment automatically and the laboratory in TAR that you will have to pass as a parameter. Run it with:
bash auto_mount.sh cve-2024-23897.tar
The script will take the compressed Docker .tar file as a parameter to launch the vulnerable container and test the exploitation of the vulnerability.
Connect to the Jenkins server: Once the Docker environment is running, you will be able to connect to the Jenkins server from your Kali Linux machine. The Jenkins interface will be available at the IP address and port configured in the container.
Run Exploit Script: Now that the vulnerable Jenkins server is running, you can run the exploit script on the Kali machine and try remote code execution on Jenkins.
Python script to exploit the CVE-2024-23897 vulnerability.Docker environment.Docker file to raise vulnerable Jenkins server.Developed by: d1se0
Contact: [email protected]