CVE-2021-30465: Github.com/opencontainers/runc Mount Destinations Can Be Swapped Vulnerability
HIGHCVE-2021-30465 is a HIGH (CVSS 7.6) mount destinations can be swapped vulnerability (CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')) affecting Github.com/opencontainers/runc libraries in the Go ecosystem. The issue involves mount destinations can be swapped via symlink-exchange to cause mounts outside the rootfs. Remediation is available by upgrading affected packages to version 1.0.0-rc95.
CVE-2021-30465 at a Glance
Security Impact
CVSS: 7.6
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:A/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:N).
How to Fix CVE-2021-30465
To remediate this vulnerability, upgrade all affected Github.com/opencontainers/runc dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade github.com/opencontainers/runc to 1.0.0-rc95
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/opencontainers/runc
How to Check if You Are Affected
To determine whether your application is affected by CVE-2021-30465, inspect your project dependencies for Github.com/opencontainers/runc:
inspect dependencies for github.com/opencontainers/runc
Analyze the terminal output to locate any version of Github.com/opencontainers/runc in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.0-rc95), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition'), where the product contains a concurrent code sequence that requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence operating concurrently. In Github.com/opencontainers/runc, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2021-30465 Affected Github.com/opencontainers/runc Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/opencontainers/runc
|
Go |
< 1.0.0-rc95
|
1.0.0-rc95
|
References
Frequently Asked Questions
What is CVE-2021-30465?
Which Github.com/opencontainers/runc versions are affected?
What version fixes CVE-2021-30465?
Is github.com/opencontainers/runc affected?
What is the CVSS score of CVE-2021-30465?
What CWE is associated with CVE-2021-30465?
How can I check Go dependencies for CVE-2021-30465?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-c3xm-pvg7-gh7r",
"modified" : "2021-05-21T19:34:43Z",
"published" : "2021-05-25T18:44:42Z",
"aliases" : [ "CVE-2021-30465" ],
"summary" : "mount destinations can be swapped via symlink-exchange to cause mounts outside the rootfs",
"details" : "### Summary\n\nrunc 1.0.0-rc94 and earlier are vulnerable to a symlink exchange attack whereby\nan attacker can request a seemingly-innocuous container configuration that\nactually results in the host filesystem being bind-mounted into the container\n(allowing for a container escape). CVE-2021-30465 has been assigned for this\nissue.\n\nAn attacker must have the ability to start containers using some kind of custom\nvolume configuration, and while recommended container hardening mechanisms such\nas LSMs (AppArmor/SELinux) and user namespaces will restrict the amount of\ndamage an attacker could do, they do not block this attack outright. We have a\nreproducer using Kubernetes (and the below description mentions\nKubernetes-specific paths), but this is not a Kubernetes-specific issue.\n\nThe now-released [runc v1.0.0-rc95][release] contains a fix for this issue, we\nrecommend users update as soon as possible.\n\n[release]: https://github.com/opencontainers/runc/releases/tag/v1.0.0-rc95\n\n### Details\n\nIn circumstances where a container is being started, and runc is mounting\ninside a volume shared with another container (which is conducting a\nsymlink-exchange attack), runc can be tricked into mounting outside of the\ncontainer rootfs by swapping the target of a mount with a symlink due to a\ntime-of-check-to-time-of-use (TOCTTOU) flaw. This is fairly similar in style to\nprevious TOCTTOU attacks (and is a problem we are working on solving with\nlibpathrs).\n\nHowever, this alone is not useful because this happens inside a mount namespace\nwith `MS_SLAVE` propagation applied to `/` (meaning that the mount doesn't\nappear on the host -- it's only a \"host-side mount\" inside the container's\nnamespace). To exploit this, you must have additional mount entries in the\nconfiguration that use some subpath of the mounted-over host path as a source\nfor a subsequent mount.\n\nHowever, it turns out with some container orchestrators (such as Kubernetes --\nthough it is very likely that other downstream users of runc could have similar\nbehaviour be accessible to untrusted users), the existence of additional volume\nmanagement infrastructure allows this attack to be applied to gain access to\nthe host filesystem without requiring the attacker to have completely arbitrary\ncontrol over container configuration.\n\nIn the case of Kubernetes, this is exploitable by creating a symlink in a\nvolume to the top-level (well-known) directory where volumes are sourced from\n(for instance,\n`/var/lib/kubelet/pods/$MY_POD_UID/volumes/kubernetes.io~empty-dir`), and then\nusing that symlink as the target of a mount. The source of the mount is an\nattacker controlled directory, and thus the source directory from which\nsubsequent mounts will occur is an attacker-controlled directory. Thus the\nattacker can first place a symlink to `/` in their malicious source directory\nwith the name of a volume, and a subsequent mount in the container will\nbind-mount `/` into the container.\n\nApplying this attack requires the attacker to start containers with a slightly\npeculiar volume configuration (though not explicitly malicious-looking such as\nbind-mounting `/` into the container explicitly), and be able to run malicious\ncode in a container that shares volumes with said volume configuration. It\nhelps the attacker if the host paths used for volume management are well known,\nthough this is not a hard requirement.\n\n### Patches\nThis has been patched in runc 1.0.0-rc95, and users should upgrade as soon as\npossible. The patch itself can be found [here](https://github.com/opencontainers/runc/commit/0ca91f44f1664da834bc61115a849b56d22f595f).\n\n### Workarounds\n\nThere are no known workarounds for this issue.\n\nHowever, users who enforce running containers with more confined security\nprofiles (such as reduced capabilities, not running code as root in the\ncontainer, user namespaces, AppArmor/SELinux, and seccomp) will restrict what\nan attacker can do in the case of a container breakout -- we recommend users\nmake use of strict security profiles if possible (most notably user namespaces\n-- which can massively restrict the impact a container breakout can have on the\nhost system).\n\n### References\n* [commit](https://github.com/opencontainers/runc/commit/0ca91f44f1664da834bc61115a849b56d22f595f)\n* [seclists public disclosure](https://www.openwall.com/lists/oss-security/2021/05/19/2)\n\n### Credit\n\nThanks to Etienne Champetier for discovering and disclosing this vulnerability,\nto Noah Meyerhans for writing the first draft of this patch, and to Samuel Karp\nfor testing it.\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n* Open an issue in [our issue tracker](https://github.com/opencontainers/runc/issues).\n* Email us at <security@opencontainers.org>.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:A/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/opencontainers/runc"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.0.0-rc95"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 1.0.0-rc94"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/opencontainers/runc/security/advisories/GHSA-c3xm-pvg7-gh7r"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-30465"
}, {
"type" : "WEB",
"url" : "https://github.com/opencontainers/runc/commit/0ca91f44f1664da834bc61115a849b56d22f595f"
}, {
"type" : "WEB",
"url" : "https://bugzilla.opensuse.org/show_bug.cgi?id=1185405"
}, {
"type" : "WEB",
"url" : "https://github.com/opencontainers/runc/releases"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2023/03/msg00023.html"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/35ZW6NBZSBH5PWIT7JU4HXOXGFVDCOHH"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/4HOARVIT47RULTTFWAU7XBG4WY6TDDHV"
}, {
"type" : "WEB",
"url" : "https://security.gentoo.org/glsa/202107-26"
}, {
"type" : "WEB",
"url" : "https://security.netapp.com/advisory/ntap-20210708-0003"
}, {
"type" : "WEB",
"url" : "http://www.openwall.com/lists/oss-security/2021/05/19/2"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22", "CWE-362", "CWE-367" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2021-05-21T19:34:43Z",
"nvd_published_at" : "2021-05-27T13:15:00Z"
}
}