GHSA-mm44-wc5p-wqhq: Cbor Denial of Service Vulnerability

HIGH
Published
Advisory Summary

GHSA-mm44-wc5p-wqhq is a HIGH denial of service vulnerability (General Security Weakness) affecting Cbor libraries in the Maven ecosystem. The issue involves denial of service due to reference expansion in versions earlier than 4.0. Remediation is available by upgrading affected packages to version 4.0.0.

GHSA-mm44-wc5p-wqhq at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-mm44-wc5p-wqhq
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Cbor
Package Ecosystem Maven
Published Date
Last Updated

How to Fix GHSA-mm44-wc5p-wqhq

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

com.upokecenter:cbor fixed: 4.0.0
<dependency>
    <groupId>com.upokecenter</groupId>
    <artifactId>cbor</artifactId>
    <version>4.0.0</version>
</dependency>
Verify Direct and Transitive Dependencies

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

mvn dependency:tree -Dincludes=com.upokecenter

How to Check if You Are Affected

To determine whether your Java application is affected by GHSA-mm44-wc5p-wqhq, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=com.upokecenter

Analyze the terminal output to locate any version of Cbor in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.0.0), your application is affected.

Note: The mvn dependency:tree -Dincludes=com.upokecenter command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under General Security Weakness. In Cbor, 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 The CBOR library supports optional tags that enable CBOR objects to contain references to objects within them. Versions earlier than 4.0 resolved those references automatically. While this by itself doesn't cause much of a security problem, a denial of service can happen if those references are deeply nested and used multiple times (so that the same reference to the same object occurs multiple times), and if the decoded CBOR object is sent to a serialization method such as EncodeToBytes, ToString, or ToJSONString, since the objects referred to are expanded in the process and take up orders of magnitude more memory than if the references weren't resolved. The impact of this problem on any particular system varies. In general, the risk is higher if the system allows users to send arbitrary CBOR objects without authentication, or exposes a remote endpoint in which arbitrary CBOR objects can be sent without authentication. ### Patches This problem is addressed in version 4.0 by disabling reference resolution by default. Users should use the latest version of this library. ### Workarounds Since version 3.6, an encoding option (`resolvereferences=true` or `resolvereferences=false`) in CBOREncodeOptions sets whether the CBOR processor will resolve these kinds of references when decoding a CBOR object. Set `resolvereferences=false` to disable reference resolution. In version 3.6, if the method used CBORObject.Read() or CBORObject.DecodeFromBytes() to decode a serialized CBOR object, call the overload that takes CBOREncodeOptions as follows: CBORObject.DecodeFromBytes(bytes, new CBOREncodeOptions("resolvereferences=false")); In versions 3.5 and earlier, this issue is present only if the CBOR object is an array or a map. If the application does not expect a decoded CBOR object to be an array or a map, it should check the CBOR object's type before encoding that object, as follows: if (cbor.Type != CBORType.Array && cbor.Type != CBORType.Map) { cbor.EncodeToBytes(); } Alternatively, for such versions, the application can use WriteTo to decode the CBOR object to a so-called "limited memory stream", that is, a Stream that throws an exception if too many bytes would be written. How to write such a limited-memory stream is nontrivial and beyond the scope of this advisory. LimitedMemoryStream stream = new LimitedMemoryStream(100000); // Limit to 100000 bytes cbor.WriteTo(stream); return stream.ToBytes(); To check whether a byte array representing a CBOR object might exhibit this problem, check whether the array contains the byte 0xd8 followed immediately by either 0x19 or 0x1d. This check catches all affected CBOR objects but may catch some non-affected CBOR objects (notably integers and byte strings). ### References See the Wikipedia article [Billion laughs attack](https://en.wikipedia.org/wiki/Billion_laughs_attack) and the related issue in [Kubernetes](https://github.com/kubernetes/kubernetes/issues/83253). ### For more information If you have any questions or comments about this advisory, open an issue in [the CBOR repository](https://github.com/peteroupc/cbor-java).

GHSA-mm44-wc5p-wqhq Affected Cbor Versions

1 component(s)
Fixed Versions:
4.0.0
Product / Package Ecosystem Affected Versions Fixed Version
com.upokecenter:cbor
Maven
< 4.0.0
4.0.0

References

Frequently Asked Questions

What is GHSA-mm44-wc5p-wqhq?
GHSA-mm44-wc5p-wqhq is a security vulnerability in Cbor involving Denial of service due to reference expansion in versions earlier than 4.0 under General Security Weakness.
Which Cbor versions are affected?
Affected versions include releases prior to 4.0.0 across affected packages: com.upokecenter:cbor.
What version fixes GHSA-mm44-wc5p-wqhq?
Upgrading to 4.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is cbor affected?
Yes, com.upokecenter:cbor is affected in releases prior to 4.0.0. Upgrade your dependency to 4.0.0 or later.
What CWE is associated with GHSA-mm44-wc5p-wqhq?
GHSA-mm44-wc5p-wqhq is classified under General Security Weakness.
How can I check Maven dependencies for GHSA-mm44-wc5p-wqhq?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=com.upokecenter'. 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-mm44-wc5p-wqhq",
  "modified" : "2022-01-18T23:05:18Z",
  "published" : "2020-07-07T16:45:24Z",
  "aliases" : [ ],
  "summary" : "Denial of service due to reference expansion in versions earlier than 4.0",
  "details" : "### Impact\n\nThe CBOR library supports optional tags that enable CBOR objects to contain references to objects within them. Versions earlier than 4.0 resolved those references automatically. While this by itself doesn't cause much of a security problem, a denial of service can happen if those references are deeply nested and used multiple times (so that the same reference to the same object occurs multiple times), and if the decoded CBOR object is sent to a serialization method such as EncodeToBytes, ToString, or ToJSONString, since the objects referred to are expanded in the process and take up orders of magnitude more memory than if the references weren't resolved.\n\nThe impact of this problem on any particular system varies. In general, the risk is higher if the system allows users to send arbitrary CBOR objects without authentication, or exposes a remote endpoint in which arbitrary CBOR objects can be sent without authentication.\n\n### Patches\n\nThis problem is addressed in version 4.0 by disabling reference resolution by default. Users should use the latest version of this library.\n\n### Workarounds\n\nSince version 3.6, an encoding option (`resolvereferences=true` or `resolvereferences=false`) in CBOREncodeOptions sets whether the CBOR processor will resolve these kinds of references when decoding a CBOR object. Set `resolvereferences=false` to disable reference resolution.\n\nIn version 3.6, if the method used CBORObject.Read() or CBORObject.DecodeFromBytes() to decode a serialized CBOR object, call the overload that takes CBOREncodeOptions as follows:\n\n    CBORObject.DecodeFromBytes(bytes, new CBOREncodeOptions(\"resolvereferences=false\"));\n\nIn versions 3.5 and earlier, this issue is present only if the CBOR object is an array or a map. If the application does not expect a decoded CBOR object to be an array or a map, it should check the CBOR object's type before encoding that object, as follows:\n\n    if (cbor.Type != CBORType.Array && cbor.Type != CBORType.Map) {\n       cbor.EncodeToBytes();\n    }\n\nAlternatively, for such versions, the application can use WriteTo to decode the CBOR object to a so-called \"limited memory stream\", that is, a Stream that throws an exception if too many bytes would be written. How to write such a limited-memory stream is nontrivial and beyond the scope of this advisory.\n\n    LimitedMemoryStream stream = new LimitedMemoryStream(100000); // Limit to 100000 bytes\n    cbor.WriteTo(stream);\n    return stream.ToBytes();\n\nTo check whether a byte array representing a CBOR object might exhibit this problem, check whether the array contains the byte 0xd8 followed immediately by either 0x19 or 0x1d. This check catches all affected CBOR objects but may catch some non-affected CBOR objects (notably integers and byte strings).\n\n### References\n\nSee the Wikipedia article [Billion laughs attack](https://en.wikipedia.org/wiki/Billion_laughs_attack) and the related issue in [Kubernetes](https://github.com/kubernetes/kubernetes/issues/83253).\n\n### For more information\n\nIf you have any questions or comments about this advisory, open an issue in [the CBOR repository](https://github.com/peteroupc/cbor-java).\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "com.upokecenter:cbor"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/peteroupc/CBOR-Java/security/advisories/GHSA-mm44-wc5p-wqhq"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/peteroupc/CBOR-Java"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-07-07T16:45:07Z",
    "nvd_published_at" : null
  }
}