Skip to content

Commit

Permalink
[SECURITY-2455]
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-beck authored and jenkinsci-cert-ci committed Nov 2, 2021
1 parent eae3384 commit 104c751
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
19 changes: 0 additions & 19 deletions core/src/main/java/hudson/FilePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ public final class FilePath implements SerializableOnlyOverRemoting {
*/
private static final int MAX_REDIRECTS = 20;

/**
* Escape hatch for some additional protections against sending callables intended to be locally used only
*/
private static /* non-final for Groovy */ boolean REJECT_LOCAL_CALLABLE_DESERIALIZATION = SystemProperties.getBoolean(FilePath.class.getName() + ".rejectLocalCallableDeserialization", true);

/**
* When this {@link FilePath} represents the remote path,
* this field is always non-null on the controller (the field represents
Expand Down Expand Up @@ -601,13 +596,6 @@ public Void invoke(File dir, VirtualChannel channel) throws IOException, Interru
return null;
}
private static final long serialVersionUID = 1L;

protected Object readResolve() {
if (REJECT_LOCAL_CALLABLE_DESERIALIZATION) {
throw new IllegalStateException("This callable is not intended to be sent through a channel");
}
return this;
}
}

/**
Expand Down Expand Up @@ -660,13 +648,6 @@ public Void invoke(File dir, VirtualChannel channel) throws IOException, Interru
return null;
}
private static final long serialVersionUID = 1L;

protected Object readResolve() {
if (REJECT_LOCAL_CALLABLE_DESERIALIZATION) {
throw new IllegalStateException("This callable is not intended to be sent through a channel");
}
return this;
}
}

/**
Expand Down
17 changes: 17 additions & 0 deletions test/src/test/java/jenkins/security/Security2455Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import hudson.model.Node;
import hudson.model.TaskListener;
import hudson.remoting.VirtualChannel;
import hudson.slaves.DumbSlave;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
Expand Down Expand Up @@ -809,6 +810,22 @@ public Object call() throws Exception {

// --------

// Misc tests

@LocalData
@Test
public void testRemoteLocalUnzip() throws Exception {
final DumbSlave onlineSlave = j.createOnlineSlave();
final File zipFile = new File(j.jenkins.getRootDir(), "file.zip");
assertTrue(zipFile.isFile());
final FilePath agentRootPath = onlineSlave.getRootPath();
final FilePath agentZipPath = agentRootPath.child("file.zip");
new FilePath(zipFile).copyTo(agentZipPath);
agentZipPath.unzip(agentRootPath);
}

// --------

// Utility functions

protected static FilePath toFilePathOnController(File file) {
Expand Down
Binary file not shown.

0 comments on commit 104c751

Please sign in to comment.