CVE-2021-43784: Github.com/opencontainers/runc Overflow Vulnerability

MODERATE
Advisory Identifier: GHSA-v95c-p5hm-xq8f
CVSS 6.0
CWE-190
Published
Advisory Summary

CVE-2021-43784 is a MODERATE (CVSS 6.0) overflow vulnerability (CWE-190: Integer Overflow or Wraparound) affecting Github.com/opencontainers/runc libraries in the Go ecosystem. The issue involves overflow in netlink bytemsg length field allows attacker to override netlink-based container configuration in runc. Remediation is available by upgrading affected packages to version 1.0.3.

CVE-2021-43784 at a Glance

CVE Identifier CVE-2021-43784
GHSA Identifier GHSA-v95c-p5hm-xq8f
Severity MODERATE
CVSS v3.1 Base Score 6.0
CWE Classification CWE-190: Integer Overflow or Wraparound
Affected Product Github.com/opencontainers/runc
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 6.0

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

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

How to Fix CVE-2021-43784

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.

github.com/opencontainers/runc fixed: 1.0.3
Upgrade github.com/opencontainers/runc to 1.0.3
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/opencontainers/runc

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-43784, 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.3), 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-190: Integer Overflow or Wraparound, where the product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. this occurs when an integer value is incremented to a value that is too large to store in the associated representation. when this occurs, the value may become a very small or negative number. 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

### Impact In runc, [netlink](https://www.man7.org/linux/man-pages/man7/netlink.7.html) is used internally as a serialization system for specifying the relevant container configuration to the C portion of our code (responsible for the based namespace setup of containers). In all versions of runc prior to 1.0.3, the encoder did not handle the possibility of an integer overflow in the 16-bit length field for the byte array attribute type, meaning that a large enough malicious byte array attribute could result in the length overflowing and the attribute contents being parsed as netlink messages for container configuration. This vulnerability requires the attacker to have some control over the configuration of the container and would allow the attacker to bypass the namespace restrictions of the container by simply adding their own netlink payload which disables all namespaces. Prior to 9c444070ec7bb83995dbc0185da68284da71c554, in practice it was fairly difficult to specify an arbitrary-length netlink message with most container runtimes. The only user-controlled byte array was the namespace paths attributes which can be specified in runc's `config.json`, but as far as we can tell no container runtime gives raw access to that configuration setting -- and having raw access to that setting **would allow the attacker to disable namespace protections entirely anyway** (setting them to `/proc/1/ns/...` for instance). In addition, each namespace path is limited to 4096 bytes (with only 7 namespaces supported by runc at the moment) meaning that even with custom namespace paths it appears an attacker still cannot shove enough bytes into the netlink bytemsg in order to overflow the uint16 counter. However, out of an abundance of caution (given how old this bug is) we decided to treat it as a potentially exploitable vulnerability with a low severity. After 9c444070ec7bb83995dbc0185da68284da71c554 (which was not present in any release of runc prior to the discovery of this bug), all mount paths are included as a giant netlink message which means that this bug becomes significantly more exploitable in more reasonable threat scenarios. The main users impacted are those who allow untrusted images with untrusted configurations to run on their machines (such as with shared cloud infrastructure), though as mentioned above it appears this bug was not practically exploitable on any released version of runc to date. ### Patches The patch for this is d72d057ba794164c3cce9451a00b72a78b25e1ae and runc 1.0.3 was released with this bug fixed. ### Workarounds To the extent this is exploitable, disallowing untrusted namespace paths in container configuration should eliminate all practical ways of exploiting this bug. It should be noted that untrusted namespace paths would allow the attacker to disable namespace protections entirely even in the absence of this bug. ### References * commit d72d057ba794 ("runc init: avoid netlink message length overflows") * https://bugs.chromium.org/p/project-zero/issues/detail?id=2241 ### Credits Thanks to Felix Wilhelm from Google Project Zero for discovering and reporting this vulnerability. In particular, the fact they found this vulnerability so quickly, before we made a 1.1 release of runc (which would've been vulnerable) was quite impressive. ### For more information If you have any questions or comments about this advisory: * Open an issue in [our repo](https://github.com/opencontainers/runc)

CVE-2021-43784 Affected Github.com/opencontainers/runc Versions

1 component(s)
Fixed Versions:
1.0.3
Product / Package Ecosystem Affected Versions Fixed Version
github.com/opencontainers/runc
Go
< 1.0.3
1.0.3

References

Frequently Asked Questions

What is CVE-2021-43784?
CVE-2021-43784 is a security vulnerability in Github.com/opencontainers/runc involving Overflow in netlink bytemsg length field allows attacker to override netlink-based container configuration in RunC under CWE-190: Integer Overflow or Wraparound.
Which Github.com/opencontainers/runc versions are affected?
Affected versions include releases prior to 1.0.3 across affected packages: github.com/opencontainers/runc.
What version fixes CVE-2021-43784?
Upgrading to 1.0.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/opencontainers/runc affected?
Yes, github.com/opencontainers/runc is affected in releases prior to 1.0.3. Upgrade your dependency to 1.0.3 or later.
What is the CVSS score of CVE-2021-43784?
CVE-2021-43784 has a CVSS v3.1 base score of 6.0 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:L/I:L/A:L.
What CWE is associated with CVE-2021-43784?
CVE-2021-43784 is classified under CWE-190: Integer Overflow or Wraparound (The product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. This occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may become a very small or negative number.).
How can I check Go dependencies for CVE-2021-43784?
Run the dependency tree command: 'inspect dependencies for github.com/opencontainers/runc'. 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-v95c-p5hm-xq8f",
  "modified" : "2024-05-31T17:47:57Z",
  "published" : "2021-12-07T21:22:39Z",
  "aliases" : [ "CVE-2021-43784" ],
  "summary" : "Overflow in netlink bytemsg length field allows attacker to override netlink-based container configuration in RunC",
  "details" : "### Impact\n\nIn runc, [netlink](https://www.man7.org/linux/man-pages/man7/netlink.7.html) is used internally as a serialization system for specifying the relevant container configuration to the C portion of our code (responsible for the based namespace setup of containers). In all versions of runc prior to 1.0.3, the encoder did not handle the possibility of an integer overflow in the 16-bit length field for the byte array attribute type, meaning that a large enough malicious byte array attribute could result in the length overflowing and the attribute contents being parsed as netlink messages for container configuration.\n\nThis vulnerability requires the attacker to have some control over the configuration of the container and would allow the attacker to bypass the namespace restrictions of the container by simply adding their own netlink payload which disables all namespaces.\n\nPrior to 9c444070ec7bb83995dbc0185da68284da71c554, in practice it was fairly difficult to specify an arbitrary-length netlink message with most container runtimes. The only user-controlled byte array was the namespace paths attributes which can be specified in runc's `config.json`, but as far as we can tell no container runtime gives raw access to that configuration setting -- and having raw access to that setting **would allow the attacker to disable namespace protections entirely anyway** (setting them to `/proc/1/ns/...` for instance). In addition, each namespace path is limited to 4096 bytes (with only 7 namespaces supported by runc at the moment) meaning that even with custom namespace paths it appears an attacker still cannot shove enough bytes into the netlink bytemsg in order to overflow the uint16 counter.\n\nHowever, out of an abundance of caution (given how old this bug is) we decided to treat it as a potentially exploitable vulnerability with a low severity. After 9c444070ec7bb83995dbc0185da68284da71c554 (which was not present in any release of runc prior to the discovery of this bug), all mount paths are included as a giant netlink message which means that this bug becomes significantly more exploitable in more reasonable threat scenarios.\n\nThe main users impacted are those who allow untrusted images with untrusted configurations to run on their machines (such as with shared cloud infrastructure), though as mentioned above it appears this bug was not practically exploitable on any released version of runc to date.\n\n### Patches\nThe patch for this is d72d057ba794164c3cce9451a00b72a78b25e1ae and runc 1.0.3 was released with this bug fixed.\n\n### Workarounds\nTo the extent this is exploitable, disallowing untrusted namespace paths in container configuration should eliminate all practical ways of exploiting this bug. It should be noted that untrusted namespace paths would allow the attacker to disable namespace protections entirely even in the absence of this bug.\n\n### References\n* commit d72d057ba794 (\"runc init: avoid netlink message length overflows\")\n* https://bugs.chromium.org/p/project-zero/issues/detail?id=2241\n\n### Credits\nThanks to Felix Wilhelm from Google Project Zero for discovering and reporting this vulnerability. In particular, the fact they found this vulnerability so quickly, before we made a 1.1 release of runc (which would've been vulnerable) was quite impressive.\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [our repo](https://github.com/opencontainers/runc)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:L/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/opencontainers/runc"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.0.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/opencontainers/runc/security/advisories/GHSA-v95c-p5hm-xq8f"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-43784"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/opencontainers/runc/commit/9c444070ec7bb83995dbc0185da68284da71c554"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/opencontainers/runc/commit/d72d057ba794164c3cce9451a00b72a78b25e1ae"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/opencontainers/runc/commit/dde509df4e28cec33b3c99c6cda3d4fd5beafc77"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/opencontainers/runc/commit/f50369af4b571e358f20b139eea52d612eb55eed"
  }, {
    "type" : "WEB",
    "url" : "https://bugs.chromium.org/p/project-zero/issues/detail?id=2241"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/opencontainers/runc"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2021/12/msg00005.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2024/02/msg00005.html"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2022-0274"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-190" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-12-06T22:09:36Z",
    "nvd_published_at" : "2021-12-06T18:15:00Z"
  }
}