Critical severityCISA KEVNVD Advisory· Published Jan 24, 2024· Updated Oct 21, 2025
CVE-2024-23897
CVE-2024-23897
Description
Jenkins 2.441 and earlier, LTS 2.426.2 and earlier does not disable a feature of its CLI command parser that replaces an '@' character followed by a file path in an argument with the file's contents, allowing unauthenticated attackers to read arbitrary files on the Jenkins controller file system.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
org.jenkins-ci.main:jenkins-coreMaven | >= 1.606, < 2.426.3 | 2.426.3 |
org.jenkins-ci.main:jenkins-coreMaven | >= 2.427, < 2.440.1 | 2.440.1 |
org.jenkins-ci.main:jenkins-coreMaven | >= 2.441, < 2.442 | 2.442 |
Affected products
1- Jenkins Project/Jenkinsv5Range: 0
Patches
13 files changed · +73 −2
core/src/main/java/hudson/cli/CLICommand.java+15 −1 modified@@ -26,6 +26,7 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.AbortException; import hudson.Extension; import hudson.ExtensionList; @@ -51,6 +52,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import jenkins.model.Jenkins; +import jenkins.util.SystemProperties; import org.apache.commons.discovery.ResourceClassIterator; import org.apache.commons.discovery.ResourceNameIterator; import org.apache.commons.discovery.resource.ClassLoaders; @@ -62,6 +64,7 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; +import org.kohsuke.args4j.ParserProperties; import org.kohsuke.args4j.spi.OptionHandler; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.authentication.BadCredentialsException; @@ -107,6 +110,16 @@ */ @LegacyInstancesAreScopedToHudson public abstract class CLICommand implements ExtensionPoint, Cloneable { + + /** + * Boolean values to either allow or disallow parsing of @-prefixes. + * If a command line value starts with @, it is interpreted as being a file, loaded, + * and interpreted as if the file content would have been passed to the command line + */ + @SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL", justification = "Accessible via System Groovy Scripts") + @Restricted(NoExternalUse.class) + public static boolean ALLOW_AT_SYNTAX = SystemProperties.getBoolean(CLICommand.class.getName() + ".allowAtSyntax"); + /** * Connected to stdout and stderr of the CLI agent that initiated the session. * IOW, if you write to these streams, the person who launched the CLI command @@ -307,7 +320,8 @@ private void logAndPrintError(Throwable e, String errorMessage, String logMessag * @since 1.538 */ protected CmdLineParser getCmdLineParser() { - return new CmdLineParser(this); + ParserProperties properties = ParserProperties.defaults().withAtSyntax(ALLOW_AT_SYNTAX); + return new CmdLineParser(this, properties); } /**
core/src/main/java/hudson/cli/declarative/CLIRegisterer.java+3 −1 modified@@ -59,6 +59,7 @@ import org.jvnet.localizer.ResourceBundleHolder; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; +import org.kohsuke.args4j.ParserProperties; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.core.Authentication; @@ -131,7 +132,8 @@ protected CmdLineParser getCmdLineParser() { private CmdLineParser bindMethod(List<MethodBinder> binders) { registerOptionHandlers(); - CmdLineParser parser = new CmdLineParser(null); + ParserProperties properties = ParserProperties.defaults().withAtSyntax(ALLOW_AT_SYNTAX); + CmdLineParser parser = new CmdLineParser(null, properties); // build up the call sequence Stack<Method> chains = new Stack<>();
test/src/test/java/jenkins/security/Security3314Test.java+55 −0 added@@ -0,0 +1,55 @@ +package jenkins.security; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.not; + +import hudson.cli.CLICommandInvoker; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; +import jenkins.model.Jenkins; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.jvnet.hudson.test.JenkinsRule; + +@RunWith(Parameterized.class) +public class Security3314Test { + private String commandName; + + @Rule + public final JenkinsRule j = new JenkinsRule(); + + /** + * connect-node to test the CLICommand behavior + * disable-job to test the CLIRegisterer behavior (@CLIMethod) + */ + @Parameterized.Parameters + public static List<String> commands() { + return Arrays.asList("connect-node", "disable-job"); + } + + public Security3314Test(String commandName) { + this.commandName = commandName; + } + + @Test + public void commandShouldNotParseAt() throws Exception { + CLICommandInvoker command = new CLICommandInvoker(j, commandName); + + Path tempPath = Files.createTempFile("tempFile", ".txt"); + tempPath.toFile().deleteOnExit(); + String content = "AtGotParsed"; + Files.write(tempPath, content.getBytes()); + + final CLICommandInvoker.Result result = command + .authorizedTo(Jenkins.READ) + .invokeWithArgs("@" + tempPath); + + assertThat(result.stderr(), containsString("@" + tempPath)); + assertThat(result.stderr(), not(containsString("AtGotParsed"))); + } +}
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
12- github.com/advisories/GHSA-6f9g-cxwr-q5jrghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2024-23897ghsaADVISORY
- www.jenkins.io/security/advisory/2024-01-24/ghsavendor-advisoryWEB
- packetstormsecurity.com/files/176839/Jenkins-2.441-LTS-2.426.3-CVE-2024-23897-Scanner.htmlghsaWEB
- packetstormsecurity.com/files/176840/Jenkins-2.441-LTS-2.426.3-Arbitrary-File-Read.htmlghsaWEB
- www.openwall.com/lists/oss-security/2024/01/24/6ghsaWEB
- github.com/jenkinsci/jenkins/commit/554f03782057c499c49bbb06575f0d28b5200edbghsaWEB
- www.cisa.gov/known-exploited-vulnerabilities-catalogghsaWEB
- www.jenkins.io/changelog-stable/ghsaWEB
- www.sonarsource.com/blog/excessive-expansion-uncovering-critical-security-vulnerabilities-in-jenkinsghsaWEB
- www.vicarius.io/vsociety/posts/the-anatomy-of-a-jenkins-vulnerability-cve-2024-23897-revealed-1ghsaWEB
- www.sonarsource.com/blog/excessive-expansion-uncovering-critical-security-vulnerabilities-in-jenkins/mitre
News mentions
0No linked articles in our index yet.