k8s Runtime Attack Scenarios 1
A deliberately vulnerable .NET Core API deployed in Kubernetes exposes a remote code execution endpoint that lets an attacker run arbitrary Linux commands inside the container. The author demonstrates confirming the flaw and then reading files and creating files in the container.
Hello, in this article, I will show you a scenario that uses the Remote Code Execution vulnerability and runs Linux commands in the Container, in the K8s environment.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the API endpoint passes user-supplied input directly to a shell or process launcher without validation, so arbitrary commands execute in the container.
Impact
An attacker could run arbitrary commands in the container, inspect available tools, create files and read application configuration, which could be used to damage the application or reach other containers on the network.
What the attacker needed
Network access to the service; the vulnerable demo app deployed
How it was found
- Deploy the lab environment with the provided Kubernetes manifest and open the Swagger page.
- Send a request to the vulnerable endpoint with a command to print the working directory to confirm code execution.
- List the /bin folder to see which tools are available in the container.
- Check the user and permissions the commands run under.
- Create a file under /bin to show write access.
- Read the application's web.config file.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The demo application has a feature that runs a command on the server using whatever text the user supplies, instead of only doing its intended job. Because the server trusts that text, someone can make it run any command they like inside the container, such as listing folders or reading files. This is called remote code execution, meaning an outsider can run their own programs on someone else's machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.