the_open_door
coffee
ESEN
← Back to index

Jenkins CLI file read (CVE-2024-23897)

The Jenkins CLI uses the args4j library to parse its arguments. By default, when an argument starts with @, args4j interprets it as "replace with the contents of this file". Jenkins never disabled that expansion, so an attacker can pass @/path/to/file and make Jenkins read that server file and return its contents in the error or command output (CVE-2024-23897).

java -jar jenkins-cli.jar -s http://<ip>:8080 help "@/etc/passwd"
# or with a dedicated PoC:
python3 51993.py -u http://<ip>:8080 -p /etc/passwd

With arbitrary read, the target is the initialAdminPassword (/root/.jenkins/secrets/initialAdminPassword) or the decryption keys (master.key + hudson.util.Secret) to recover stored credentials (secrets in source). Once in as administrator, Jenkins's Script Console runs Groovy with the process privileges, closing the chain to RCE.

The vulnerable Jenkins often listens only on localhost; it's reached after compromising the host with an SSH local port forward.

Nuances. The read can be complete (anonymous users with read permission) or partial (a few lines per error message) depending on permissions; even the partial one usually suffices for the short initialAdminPassword. It affects Jenkins 2.441/LTS 2.426.2 and earlier.

How to detect it. CLI use leaves a trail in Jenkins' log: commands invoked with an argument starting with @ (the mark of args4j expansion), and the use of the CLI download channel (/cli with websocket/duplex). Reading secrets/initialAdminPassword or master.key/hudson.util.Secret is the telling target. If the attack completes the chain, administrative access and Groovy execution in the Script Console (/script) follow, a very high-severity event. A spike of CLI commands with @ from an unusual IP is the signature.

Defence. Update Jenkins; disable CLI access if unused; and don't expose the panel even on the internal network without strong authentication, since the Script Console turns any admin into RCE.

Machines where it's used

  • VmdakProving Grounds Practice