Docker release_agent cgroups escape
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
For further details, refer to the original blog post. This is just a summary:
Original PoC:
The proof of concept (PoC) demonstrates a method to exploit cgroups by creating a release_agent
file and triggering its invocation to execute arbitrary commands on the container host. Here's a breakdown of the steps involved:
Prepare the Environment:
A directory
/tmp/cgrp
is created to serve as a mount point for the cgroup.The RDMA cgroup controller is mounted to this directory. In case of absence of the RDMA controller, it's suggested to use the
memory
cgroup controller as an alternative.
Set Up the Child Cgroup:
A child cgroup named "x" is created within the mounted cgroup directory.
Notifications are enabled for the "x" cgroup by writing 1 to its notify_on_release file.
Configure the Release Agent:
The path of the container on the host is obtained from the /etc/mtab file.
The release_agent file of the cgroup is then configured to execute a script named /cmd located at the acquired host path.
Create and Configure the /cmd Script:
The /cmd script is created inside the container and is configured to execute ps aux, redirecting the output to a file named /output in the container. The full path of /output on the host is specified.
Trigger the Attack:
A process is initiated within the "x" child cgroup and is immediately terminated.
This triggers the
release_agent
(the /cmd script), which executes ps aux on the host and writes the output to /output within the container.
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Last updated