Adding separate check for symlink to prevent jailbreak

Otherwise a symlink can be created to point to a file outside $JENKINS_HOME and be read
This commit is contained in:
Kohsuke Kawaguchi committed 2014-10-17 19:03:55 -07:00
1 parent ec1e47c053
commit 8a105ce57c
6 files changed
+41 -3

No files matched your search

+12 -1
View File
@@ -617,7 +617,7 @@ public final class FilePath implements Serializable {
act(new SecureFileCallable<Void>() {
private static final long serialVersionUID = 1L;
public Void invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
writing(f);
symlinking(f);
Util.createSymlink(f.getParentFile(),target,f.getName(),listener);
return null;
}
@@ -2692,6 +2692,17 @@ public final class FilePath implements Serializable {
return f;
}
/**
* Pass through 'f' after ensuring that we can create that symlink.
*/
private File symlinking(File f) {
FilePathFilter filter = filterNonNull();
if (!f.exists())
filter.create(f);
filter.symlink(f);
return f;
}
/**
* Pass through 'f' after ensuring that we can delete that file.
*/