Skip to content
Path traversal Write-up Intermediate

How to replicate Jenkins CVE-2024–23897: Arbitrary File Read Vulnerability

Jenkins' command-line interface uses the args4j library, which by default expands arguments starting with '@' to the contents of the referenced file. An attacker could read arbitrary files on the Jenkins controller, with full file read possible when anonymous read access is enabled, and partial read (first line) otherwise.

red_darkin Follow

Published on medium.com

In this story, I’ll guide you through effortlessly replicating the latest Jenkins-related CVE. But before we jump into action, let’s take a closer look at this vulnerability. 🔍🌐 Ready for the ride?

Red Darkin, on medium.com

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

The args4j library's expandAtFiles feature is enabled by default and Jenkins did not disable it, so arguments beginning with '@' are replaced with file contents.

Impact

An attacker could read arbitrary files on the Jenkins controller, with full file read when anonymous read access is enabled, and partial read (first line) otherwise.

What the attacker needed

Network access to Jenkins CLI endpoint; jenkins-cli.jar downloaded; anonymous read access enabled for full read

The fix

Disable the expandAtFiles feature or upgrade to a version that does so; the text suggests unchecking 'Allow anonymous read access' as a mitigation.

How it was found

  1. Set up a vulnerable Jenkins instance using Docker Compose.
  2. Download the Jenkins CLI client jar from the Jenkins server.
  3. Run the CLI with an argument that references a file using the '@' syntax to read its contents.
  4. If anonymous read access is disabled, use a different command to read the first line of the file.
  5. Re-enable anonymous read access to read the entire file.

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 building and testing. Its command-line client lets users run commands on the Jenkins server. A library used to parse those commands has a feature that treats an argument starting with '@' as a file path and inserts the file's contents into the command. Because Jenkins did not turn this off, an attacker could make Jenkins read files from its own filesystem and show them in error messages or output.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.