Skip to content
Info disclosure Write-up Advanced

From Limited file read to full access on Jenkins (CVE-2024-23897)

A Jenkins instance vulnerable to CVE-2024-23897 allowed unauthenticated attackers to read the first few lines of arbitrary files. The author leveraged this limited file read to extract the first 16 bytes of the Hudson secret and the master key, then brute-forced the remaining bytes to decrypt stored credentials.

Ahmed Sherif Follow

Published on xphantom.nl

As a red teamer, you encountered a Jenkins instance that is vulnerable to CVE-2024-23897, which allowed for limited arbitrary file read. Without credentials and with the /script endpoint inaccessible, you sought to leverage this vulnerability by revealing Hudson to decypt the credentials.

Ahmed Sherif, on xphantom.nl

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the args4j library expands file contents into command arguments when an argument starts with '@', allowing unauthenticated users to read the first lines of arbitrary files.

Impact

An attacker could decrypt stored credentials, potentially leading to full access to the Jenkins instance and remote code execution, though the text notes that none of the standard RCE conditions were met in this case.

What the attacker needed

Jenkins vulnerable to CVE-2024-23897; Network access to Jenkins CLI endpoint; No authentication required

The fix

Upgrade Jenkins to a version that fixes CVE-2024-23897, as recommended in the security advisory.

How it was found

  1. Use the Jenkins CLI or a Python exploit to read the first lines of files such as /proc/self/environ and credentials.xml.
  2. Retrieve the Hudson secret file and the master key file using the same file-read technique.
  3. Extract the first 16 bytes of the Hudson secret and compute the SHA-256 hash of the first 16 bytes of the master key.
  4. Parse the encrypted credential to obtain the IV and ciphertext.
  5. Brute-force the missing bytes of the Hudson secret by trying all possible byte values and checking if decryption yields printable characters starting with '-----'.
  6. Use the recovered Hudson secret and master key to decrypt the stored credentials.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Jenkins is a tool that automates software builds. A bug in its command-line interface let anyone read the first few lines of any file on the server. The author used this to grab pieces of the secret keys Jenkins uses to encrypt saved passwords, then guessed the missing parts to unlock them.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.