Security context
Low· 3.6GHSA-584m-7r4m-8j6v CVE-2023-27903CWE-863Published Mar 10, 2023

Incorrect Authorization in Jenkins Core

Research this vulnerability

Research is free — Hunters explains how the bug works, the root-cause code pattern, how the fix addresses it, and how to test whether a target is affected, in chat. Investigate & write exploit is a paid run — the engine reads the advisory and fix commits, then builds and validates a working proof-of-concept exploit with reproduction steps.

Affected versions

2.376 → fixed in 2.387.10 → fixed in 2.375.42.388 → fixed in 2.394

Details

When triggering a build from the Jenkins CLI, Jenkins creates a temporary file on the controller if a file parameter is provided through the CLI’s standard input. Jenkins 2.393 and earlier, LTS 2.375.3 and earlier, and , and LTS prior to 2.387.1 creates this temporary file in the default temporary directory with the default permissions for newly created files. If these permissions are overly permissive, they may allow attackers with access to the Jenkins controller file system to read and write the file before it is used in the build. This vulnerability only affects operating systems using a shared temporary directory for all users (typically Linux). Additionally, the default permissions for newly created files generally only allows attackers to read the temporary file. Jenkins 2.394, LTS 2.375.4, and LTS 2.387.1 creates the temporary file with more restrictive permissions. As a workaround, you can set a different path as your default temporary directory using the Java system property java.io.tmpdir, if you’re concerned about this issue but unable to immediately update Jenkins.

The fix

[SECURITY-3058]

Kevin-CB· Feb 23, 2023, 07:59 AM+21554587b06d
core/src/main/java/hudson/model/FileParameterDefinition.java+2 1
@@ -31,6 +31,7 @@
import hudson.cli.CLICommand;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.Objects;
import javax.servlet.ServletException;
import net.sf.json.JSONObject;
@@ -118,7 +119,7 @@ private String getFileName(String possiblyPathName) {
@Override
public ParameterValue createValue(CLICommand command, String value) throws IOException, InterruptedException {
// capture the file to the server
- File local = File.createTempFile("jenkins", "parameter");
+ File local = Files.createTempFile("jenkins", "parameter").toFile();
String name;
if (value.isEmpty()) {
FileUtils.copyInputStreamToFile(command.stdin, local);

References