My understanding of containers is very basic and so is my understanding of AWS EC2. Recently while trying to debug a security issue, I came across a scenario where I was able to gain an RCE. Whether this RCE was in a container or on the EC2 is still not clear. But one thing of interest was that through the RCE I was able to access the EC2 metadata endpoint at
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/
Now I have a couple of conceptual questions here:
- How come from within a container I am able to access the EC2 metadata?
- Does it mean that the EC2 can also be accessed from within the container (like a container escape of some sorts)?
- I have access to the STS token, the access key id and the access key secret leaking through the metadata endpoint. How can I check the privileges of this token?