Summery
CVE-2024-23897 is a vulnerability in Jenkins 2.441 and earlier, LTS 2.426.2 and earlier as it does not disable a feature of its CLI command parser that replaces an ’@’ character followed by a file path in an argument with the file’s contents, allowing unauthenticated attackers to read arbitrary files on the Jenkins controller file system.
Affected versions:
Jenkins 2.441 and earlier
LTS 2.426.2 and earlier
Exploitation
As in the summery, the core vulnerability is connected to just how Jenkin’s CLI command parser behaves. to exploit it, you can download your target’s jenkins-cli.jar file (for example with wget) and follow a manual enumeration. I prefer to run a simple PoC which already prompts the target for the jenkins-cli.jar file and helps to streamline the process.
I tried a number of PoCs, most of them show only just a few lines of files, because an unauthenticated user is limited to just a few. I had however much more luck with the PoC by godylockz which let me read the whole files.
After you download it, you can simply run it with uv run jenkins_fileread.py --url http://10.129.230.220:8080/ --file /var/jenkins_home/credentials.xml.
You can use it to enumerate popular system files like /etc/hosts or look for private keys in user home directories. In regards to Jenkins, you can also read it’s files and look for stored credentials and orther, valuable data. You can visit Jenkins for a list of interesting files and folder to enumerate.
References
PoC by godylockz
PoC by P4x1s
PoC by xaitax
PoC by h4x0r-dz