CVE-2021-43816: Github.com/containerd/containerd Unprivileged Pod Using `hostPath` Can Vulnerability

HIGH
Advisory Identifier: GHSA-mvff-h3cj-wj9c
CVSS 8.0
CWE-281
Published
Advisory Summary

CVE-2021-43816 is a HIGH (CVSS 8.0) unprivileged pod using `hostpath` can vulnerability (CWE-281: Improper Preservation of Permissions) affecting Github.com/containerd/containerd libraries in the Go ecosystem. The issue involves unprivileged pod using `hostpath` can side-step active lsm when it is selinux. Remediation is available by upgrading affected packages to version 1.5.9.

CVE-2021-43816 at a Glance

CVE Identifier CVE-2021-43816
GHSA Identifier GHSA-mvff-h3cj-wj9c
Severity HIGH
CVSS v3.1 Base Score 8.0
CWE Classification CWE-281: Improper Preservation of Permissions
Affected Product Github.com/containerd/containerd
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 8.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2021-43816

To remediate this vulnerability, upgrade all affected Github.com/containerd/containerd dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/containerd/containerd fixed: 1.5.9
Upgrade github.com/containerd/containerd to 1.5.9
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/containerd/containerd

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-43816, inspect your project dependencies for Github.com/containerd/containerd:

inspect dependencies for github.com/containerd/containerd

Analyze the terminal output to locate any version of Github.com/containerd/containerd in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.5.9), 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-281: Improper Preservation of Permissions, where the product does not preserve permissions or incorrectly preserves permissions when copying, restoring, or sharing objects, which can cause them to have less restrictive permissions than intended. In Github.com/containerd/containerd, 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

### Impact Containers launched through containerd’s CRI implementation on Linux systems which use the SELinux security module and containerd versions since v1.5.0 can cause arbitrary files and directories on the host to be relabeled to match the container process label through the use of specially-configured bind mounts in a hostPath volume. This relabeling elevates permissions for the container, granting full read/write access over the affected files and directories. Kubernetes and crictl can both be configured to use containerd’s CRI implementation. If you are not using containerd’s CRI implementation (through one of the mechanisms described above), you are not affected by this issue. ### Patches This bug has been fixed in containerd 1.5.9. Because file labels persist independently of containerd, users should both update to these versions as soon as they are released and validate that all files on their host are correctly labeled. ### Workarounds Ensure that no sensitive files or directories are used as a hostPath volume source location. Policy enforcement mechanisms such a Kubernetes Pod Security Policy [AllowedHostPaths](https://kubernetes.io/docs/concepts/policy/pod-security-policy/#volumes-and-file-systems) may be specified to limit the files and directories that can be bind-mounted to containers. ### For more information If you have any questions or comments about this advisory: * Open an issue in [containerd](https://github.com/containerd/containerd/issues/new/choose) * Email us at [security@containerd.io](mailto:security@containerd.io)

CVE-2021-43816 Affected Github.com/containerd/containerd Versions

1 component(s)
Fixed Versions:
1.5.9
Product / Package Ecosystem Affected Versions Fixed Version
github.com/containerd/containerd
Go
≥ 1.5.0
< 1.5.9
1.5.9

References

Frequently Asked Questions

What is CVE-2021-43816?
CVE-2021-43816 is a security vulnerability in Github.com/containerd/containerd involving Unprivileged pod using `hostPath` can side-step active LSM when it is SELinux under CWE-281: Improper Preservation of Permissions.
Which Github.com/containerd/containerd versions are affected?
Affected versions include releases prior to 1.5.9 across affected packages: github.com/containerd/containerd.
What version fixes CVE-2021-43816?
Upgrading to 1.5.9 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/containerd/containerd affected?
Yes, github.com/containerd/containerd is affected in releases prior to 1.5.9. Upgrade your dependency to 1.5.9 or later.
What is the CVSS score of CVE-2021-43816?
CVE-2021-43816 has a CVSS v3.1 base score of 8.0 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2021-43816?
CVE-2021-43816 is classified under CWE-281: Improper Preservation of Permissions (The product does not preserve permissions or incorrectly preserves permissions when copying, restoring, or sharing objects, which can cause them to have less restrictive permissions than intended.).
How can I check Go dependencies for CVE-2021-43816?
Run the dependency tree command: 'inspect dependencies for github.com/containerd/containerd'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mvff-h3cj-wj9c",
  "modified" : "2022-04-04T20:40:33Z",
  "published" : "2022-01-06T17:36:59Z",
  "aliases" : [ "CVE-2021-43816" ],
  "summary" : "Unprivileged pod using `hostPath` can side-step active LSM when it is SELinux",
  "details" : "### Impact\n\nContainers launched through containerd’s CRI implementation on Linux systems which use the SELinux security module and containerd versions since v1.5.0 can cause arbitrary files and directories on the host to be relabeled to match the container process label through the use of specially-configured bind mounts in a hostPath volume. This relabeling elevates permissions for the container, granting full read/write access over the affected files and directories. Kubernetes and crictl can both be configured to use containerd’s CRI implementation.\n\nIf you are not using containerd’s CRI implementation (through one of the mechanisms described above), you are not affected by this issue.\n\n### Patches\n\nThis bug has been fixed in containerd 1.5.9.  Because file labels persist independently of containerd, users should both update to these versions as soon as they are released and validate that all files on their host are correctly labeled.\n\n### Workarounds\n\nEnsure that no sensitive files or directories are used as a hostPath volume source location.  Policy enforcement mechanisms such a Kubernetes Pod Security Policy [AllowedHostPaths](https://kubernetes.io/docs/concepts/policy/pod-security-policy/#volumes-and-file-systems) may be specified to limit the files and directories that can be bind-mounted to containers.\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* Open an issue in [containerd](https://github.com/containerd/containerd/issues/new/choose)\n* Email us at [security@containerd.io](mailto:security@containerd.io)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/containerd/containerd"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.5.0"
      }, {
        "fixed" : "1.5.9"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/containerd/containerd/security/advisories/GHSA-mvff-h3cj-wj9c"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-43816"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/containerd/containerd/issues/6194"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/containerd/containerd/commit/a731039238c62be081eb8c31525b988415745eea"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dweomer/containerd/commit/f7f08f0e34fb97392b0d382e58916d6865100299"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/containerd/containerd"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/GD5GH7NMK5VJMA2Y5CYB5O5GTPYMWMLX"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/MPDIZMI7ZPERSZE2XO265UCK5IWM7CID"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-281" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-01-05T21:09:16Z",
    "nvd_published_at" : "2022-01-05T19:15:00Z"
  }
}