Locking Down the Instance Metadata Service: Announcing Imds-Filterd
daemonology.net
daemonology.net
The protection I would highly recommend everyone use is enabling Amazon's "v2" metadata service [2] in enforce mode, which will neuter nearly all SSRF metadata attacks. This won't do anything if someone has RCE on your host, but it would have prevented the Capital One breach the author uses as their example. Nearly every metadata compromise in recent history has been through SSRF.
Another aspirational read is how Netflix detects credential compromise [3]: the first time a host asks for metadata credentials they save its ip address, and if they ever see those credentials used from a different ip address they alert on it.
[1]: https://zerodium.com/program.html
[2]: https://aws.amazon.com/blogs/security/defense-in-depth-open-...
[3]: https://netflixtechblog.com/netflix-cloud-security-detecting...
[0] https://github.com/opsdisk/cloud_metadata_extractor/blob/mas...
I would say that how frequently it's possible depends on the context. If someone gets RCE as user nobody running inside /var/empty, there's a wide range of vulnerabilities which they would be unable to utilize. Even more so if they're locked down with Capsicum or other sandboxing tools.
People talk about RCE as if it's a single category, but there are many cases where someone might be able to execute arbitrary code inside a sandbox while not having the ability to execute arbitrary code on the host system.
https://aws.amazon.com/blogs/security/defense-in-depth-open-...
I haven't looked at the Linux kernel code, but keeping routes cached per-flow is a trivial optimization; I'd be shocked if they weren't using it.