CVE-2023-6245: Candid Candid Infinite Decoding Loop Through Vulnerability

HIGH
Advisory Identifier: GHSA-7787-p7x6-fq3j
CVSS 7.5
CWE-400 CWE-835 CWE-1288
Published
Advisory Summary

CVE-2023-6245 is a HIGH (CVSS 7.5) candid infinite decoding loop through vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Candid libraries in the crates.io ecosystem. The issue involves candid infinite decoding loop through specially crafted payload. Remediation is available by upgrading affected packages to version 0.9.10.

CVE-2023-6245 at a Glance

CVE Identifier CVE-2023-6245
GHSA Identifier GHSA-7787-p7x6-fq3j
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Candid
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 7.5

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

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

How to Fix CVE-2023-6245

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

candid fixed: 0.9.10
Upgrade candid to 0.9.10
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 candid

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-6245, inspect your project dependencies for Candid:

inspect dependencies for candid

Analyze the terminal output to locate any version of Candid in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.9.10), 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-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Candid, 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 Candid library causes a Denial of Service while parsing a specially crafted payload with `empty` data type. For example, if the payload is `record { * ; empty }` and the canister interface expects `record { * }` then the rust candid decoder treats `empty` as an extra field required by the type. The problem with type `empty` is that the candid rust library wrongly categorizes `empty` as a recoverable error when skipping the field and thus causing an infinite decoding loop. Canisters using affected versions of candid are exposed to denial of service by causing the decoding to run indefinitely until the canister traps due to reaching maximum instruction limit per execution round. Repeated exposure to the payload will result in degraded performance of the canister. For asset canister users, `dfx` versions `>= 0.14.4` to `<= 0.15.2-beta.0` ships asset canister with an affected version of candid. #### Unaffected - Rust canisters using candid `< 0.9.0` or `>= 0.9.10` - Rust canister interfaces of type other than `record { * }` - Motoko based canisters - dfx (for asset canister) `<= 0.14.3` or `>= 0.15.2` ### Patches The issue has been patched in `0.9.10`. All rust based canisters on candid versions `>= 0.9.0` must upgrade their candid versions to `>= 0.9.10` and deploy their canisters to mainnet as soon as possible. ### Workarounds There is no workaround for canisters using the affected versions of candid other than upgrading to patched version. ### References - [dfinity/candid/pull/478](https://github.com/dfinity/candid/pull/478) - [Candid Library Reference](https://internetcomputer.org/docs/current/references/candid-ref) - [Candid Specification](https://github.com/dfinity/candid/blob/master/spec/Candid.md) - [Internet Computer Specification](https://internetcomputer.org/docs/current/references/ic-interface-spec)

CVE-2023-6245 Affected Candid Versions

1 component(s)
Fixed Versions:
0.9.10
Product / Package Ecosystem Affected Versions Fixed Version
candid
crates.io
≥ 0.9.0
< 0.9.10
0.9.10

References

Frequently Asked Questions

What is CVE-2023-6245?
CVE-2023-6245 is a security vulnerability in Candid involving Candid infinite decoding loop through specially crafted payload under CWE-400: Uncontrolled Resource Consumption.
Which Candid versions are affected?
Affected versions include releases prior to 0.9.10 across affected packages: candid.
What version fixes CVE-2023-6245?
Upgrading to 0.9.10 (or the latest patched release for your respective branch) resolves the vulnerability.
Is candid affected?
Yes, candid is affected in releases prior to 0.9.10. Upgrade your dependency to 0.9.10 or later.
What is the CVSS score of CVE-2023-6245?
CVE-2023-6245 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2023-6245?
CVE-2023-6245 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check crates.io dependencies for CVE-2023-6245?
Run the dependency tree command: 'inspect dependencies for candid'. 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-7787-p7x6-fq3j",
  "modified" : "2023-12-08T19:52:40Z",
  "published" : "2023-12-08T15:23:22Z",
  "aliases" : [ "CVE-2023-6245" ],
  "summary" : "Candid infinite decoding loop through specially crafted payload",
  "details" : "### Impact\n\nThe Candid library causes a Denial of Service while parsing a specially crafted payload with `empty` data type. For example, if the payload is `record { * ; empty }` and  the canister interface expects `record { * }` then the rust candid decoder treats `empty` as an extra field required by the type.  The problem with type `empty` is that the candid rust library wrongly categorizes `empty` as a recoverable error when skipping the field and thus causing an infinite decoding loop. \n\nCanisters using affected versions of candid are exposed to denial of service by causing the decoding to run indefinitely until the canister traps due to reaching maximum instruction limit per execution round. Repeated exposure to the payload will result in degraded performance of the canister.\n\nFor asset canister users, `dfx` versions `>= 0.14.4` to `<= 0.15.2-beta.0` ships asset canister with an affected version of candid.\n\n#### Unaffected \n- Rust canisters using candid `< 0.9.0` or `>= 0.9.10` \n- Rust canister interfaces of type other than `record { * }`\n- Motoko based canisters\n- dfx (for asset canister) `<= 0.14.3` or `>= 0.15.2`\n\n\n### Patches\n\nThe issue has been patched in `0.9.10`. All rust based canisters on candid versions `>= 0.9.0` must upgrade their candid versions to `>= 0.9.10` and deploy their canisters to mainnet as soon as possible. \n\n### Workarounds\n\nThere is no workaround for canisters using the affected versions of candid other than upgrading to patched version.\n\n### References\n-  [dfinity/candid/pull/478](https://github.com/dfinity/candid/pull/478)\n-  [Candid Library Reference](https://internetcomputer.org/docs/current/references/candid-ref)\n-  [Candid Specification](https://github.com/dfinity/candid/blob/master/spec/Candid.md)\n-  [Internet Computer Specification](https://internetcomputer.org/docs/current/references/ic-interface-spec)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "candid"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.9.0"
      }, {
        "fixed" : "0.9.10"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/dfinity/candid/security/advisories/GHSA-7787-p7x6-fq3j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-6245"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dfinity/candid/pull/478"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dfinity/candid/commit/b233dbc2d2bcc79c9fc574dd5968269df680b073"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/dfinity/candid"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dfinity/candid/blob/master/spec/Candid.md"
  }, {
    "type" : "WEB",
    "url" : "https://internetcomputer.org/docs/current/references/candid-ref"
  }, {
    "type" : "WEB",
    "url" : "https://internetcomputer.org/docs/current/references/ic-interface-spec"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2023-0073.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1288", "CWE-400", "CWE-835" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-12-08T15:23:22Z",
    "nvd_published_at" : "2023-12-08T15:15:08Z"
  }
}