Attack Simulation & Response

Red TeamEnd-to-end simulation using real adversary tradecraft Blue TeamThreat hunting, monitoring and incident response Purple TeamGrow your offensive and defensive teams together Ransomware Response24/7 emergency response for encrypted systems

Security Testing

Penetration TestingFinding flaws in web, network and mobile applications Enterprise Penetration TestingRegulation-aligned testing for finance and large enterprises Vulnerability ScanningContinuous scanning, prioritised with CVSS
A free scoping call tailored to your organisation.
All services Get a quote

Forensic Threat Hunting

PotreX VestigeHidden threat scanning across disk, memory and forensic traces

Threat Intelligence

PotreX ArgosDark web and leak-focused threat intelligence

Penetration Testing

PotreX BallistaEnterprise penetration testing platform with finding management
Every product can be deployed on-premises or in the cloud.
All products Request a demo
Services
Products
Blog Contact Us Sign In
Home / Blog / CVE-2024-23897
Vulnerability Analysis

Jenkins CLI: From an @ Sign to Full Takeover

Summary

Jenkins' built-in command line interface parses arguments with the args4j library. That library's @file feature expands an argument beginning with @ into the contents of the named file.

Jenkins never disabled the feature, so anyone who can reach the CLI can read arbitrary files from the server through error messages. In a default installation anonymous users can reach the CLI, which makes the issue unauthenticated.

Advisory details

CVECVE-2024-23897
ComponentJenkins — built-in CLI (args4j expandAtFiles)
ClassCWE-22 / CWE-200 · Arbitrary file read and information disclosure
SeverityCRITICAL · CVSS 9.8
Affected versionsJenkins ≤ 2.441 and LTS ≤ 2.426.2
Fixed versions2.442 · LTS 2.426.3
PrerequisiteCLI access — anonymous read permission is enough in most installs

Root cause: a convenience feature left on

args4j offers @ expansion so that long argument lists can be read from a file, and the feature is enabled by default. Jenkins hands user-supplied arguments straight to that parser, turning the feature into a file read primitive.

The content read back is reflected in the “no argument is allowed” error message, which is what lets an attacker harvest the first lines of files one request at a time.

Harmless verification

analyst@ubuntu: ~/labs/jenkins –□✕
analyst@ubuntu:~/labs/jenkins$ curl -s -I http://ci.lab.local/login | grep -i '^x-jenkins'
X-Jenkins: 2.441
X-Jenkins-Session: 5c0a2b11

#  below 2.442 — affected version

Figure 1 — Reading the Jenkins version from a response header

For verification we use a file whose contents are public anyway; the point is only to prove the read capability.

analyst@ubuntu: ~/labs/jenkins –□✕
analyst@ubuntu:~/labs/jenkins$ java -jar jenkins-cli.jar -s http://ci.lab.local/ who-am-i '@/etc/hostname'
ERROR: No argument is allowed: ci-build-01
java -jar jenkins-cli.jar who-am-i

#  the error message reflected the file contents
#  the same path could have read credentials.xml or master.key

Figure 2 — Proving the read capability with a harmless file

Impact chain

Readable files include secrets/master.key, secrets/hudson.util.Secret and credentials.xml. Together those three allow every credential stored in Jenkins — cloud keys, repository tokens, deployment passwords — to be decrypted, and the CI/CD pipeline then leads into production.

Remediation

analyst@ubuntu: ~/labs/jenkins –□✕
analyst@ubuntu:~/labs/jenkins$ sudo apt install --only-upgrade jenkins && java -jar jenkins-cli.jar -s http://ci.lab.local/ who-am-i '@/etc/hostname'
Setting up jenkins (2.442) ...
ERROR: No argument is allowed: @/etc/hostname

#  the argument is no longer expanded — no file contents leak

Figure 3 — Expansion disabled after the upgrade

  • Upgrade Jenkins to 2.442 / LTS 2.426.3 or later.
  • If you cannot upgrade immediately, disable the CLI entirely.
  • Remove anonymous read permission and restrict CLI access at the network layer.
  • If the instance was internet-facing before patching, rotate every credential stored in Jenkins.

Log hunting

analyst@ubuntu: /var/log/jenkins –□✕
analyst@ubuntu:/var/log/jenkins$ grep -ohE '"(GET|POST) /cli[^"]*' jenkins.log* | sort | uniq -c | sort -rn | head -n 3
    642 "POST /cli?remoting=false
     58 "GET /cli

#  heavy traffic to the CLI endpoint — automated scanning

Figure 4 — Counting requests to the CLI endpoint

Conclusion

CI/CD systems concentrate the keys to production in one place, which makes them a high-value target. Build servers should not be internet-facing, credentials belong in an external vault, and access should follow least privilege.

Sources

Test it in your own environment

We test your CI/CD pipeline along the access chain that runs from build servers into production.

Call now · 0850 551 01 01 WhatsApp · Send a message Email · info@potrex.com