CVE-2022-23495: Github.com/ipfs/go merkledag Go-merkledag's ProtoNode May Be Modified Vulnerability
HIGHCVE-2022-23495 is a HIGH (CVSS 7.5) go-merkledag's protonode may be modified vulnerability (CWE-755: Improper Handling of Exceptional Conditions) affecting Github.com/ipfs/go merkledag libraries in the Go ecosystem. The issue involves go-merkledag's protonode may be modified such that common method calls may panic. Remediation is available by upgrading affected packages to version 0.8.1.
CVE-2022-23495 at a Glance
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).
How to Fix CVE-2022-23495
To remediate this vulnerability, upgrade all affected Github.com/ipfs/go merkledag 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/ipfs/go-merkledag to 0.8.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/ipfs/go-merkledag
How to Check if You Are Affected
To determine whether your application is affected by CVE-2022-23495, inspect your project dependencies for Github.com/ipfs/go merkledag:
inspect dependencies for github.com/ipfs/go-merkledag
Analyze the terminal output to locate any version of Github.com/ipfs/go merkledag in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.8.1), 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-755: Improper Handling of Exceptional Conditions, where the product does not handle or incorrectly handles an exceptional condition. In Github.com/ipfs/go merkledag, 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-2022-23495 Affected Github.com/ipfs/go merkledag Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/ipfs/go-merkledag
|
Go |
≥ 0.4.0
< 0.8.1
|
0.8.1
|
References
Frequently Asked Questions
What is CVE-2022-23495?
Which Github.com/ipfs/go merkledag versions are affected?
What version fixes CVE-2022-23495?
Is github.com/ipfs/go-merkledag affected?
What is the CVSS score of CVE-2022-23495?
What CWE is associated with CVE-2022-23495?
How can I check Go dependencies for CVE-2022-23495?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-x39j-h85h-3f46",
"modified" : "2022-12-09T15:21:18Z",
"published" : "2022-12-08T16:12:26Z",
"aliases" : [ "CVE-2022-23495" ],
"summary" : "go-merkledag's ProtoNode may be modified such that common method calls may panic",
"details" : "### Impact\n\nA `ProtoNode` may be modified in such a way as to cause various encode errors which will trigger a panic on common method calls that don't allow for error returns.\n\nA `ProtoNode` should only be able to encode to valid DAG-PB, attempting to encode invalid DAG-PB forms will result in an error from the codec. Manipulation of an existing (newly created or decoded) `ProtoNode` using the modifier methods did not account for certain states that would place the `ProtoNode` into an unencodeable form.\n\nDue to conformance with the [`github.com/ipfs/go-block-format#Block`](https://pkg.go.dev/github.com/ipfs/go-block-format#Block) and [`github.com/ipfs/go-ipld-format#Node`](https://pkg.go.dev/github.com/ipfs/go-ipld-format#Node) interfaces, certain methods, which internally require a re-encode if state has changed, will panic due to the inability to return an error.\n\nAdditionally, use of the `ProtoNode#SetCidBuilder()` method to set a non-functioning `CidBuilder` (such as one that refers to a multihash where an implementation of that hash function is not available) may cause the same methods to panic as a new CID is required but cannot be created.\n\n### Patches\n\nReleases involving fixes for this issue are [v0.8.0](https://github.com/ipfs/go-merkledag/releases/tag/v0.8.0) and [v0.8.1](https://github.com/ipfs/go-merkledag/releases/tag/v0.8.1). The recommended minimum version is **v0.8.1**.\n\n* Additional checks are performed on `ProtoNode` state changes to avoid the possibility of creating unencodeable forms, errors are returned where this is the case.\n* The builder passed in to `SetCidBuilder()` is inspected to attempt to determine if it is usable to generate CIDs, otherwise an error is returned.\n* The panics have been removed and replaced with default values (empty byte slice for `RawData()` and a default zero-bytes DAG-PB CID for methods involving CIDs).\n\n### Workarounds\n\nThese workarounds are available when using impacted versions to avoid panic conditions, and may be generally appropriate in order to provide meaningful feedback to users and avoid generating bad, or unexpected encoded data:\n\n* Sanitise inputs when allowing user-input to set a new `CidBuilder` on a `ProtoNode`.\n* Sanitise `Tsize` (`Link#Size`) values such that they are a reasonable byte-size for sub-DAGs where derived from user-input.\n\n### References\n\n* https://github.com/ipfs/kubo/issues/9297\n* https://github.com/ipfs/go-merkledag/issues/90\n* https://github.com/ipfs/go-merkledag/releases/tag/v0.8.0\n* https://github.com/ipfs/go-merkledag/pull/91\n* https://github.com/ipfs/go-merkledag/pull/92\n* https://github.com/ipfs/go-merkledag/pull/93\n* https://github.com/ipfs/go-merkledag/releases/tag/v0.8.1\n\n\n### Credit\n\nThanks to [@mrd0ll4r](https://github.com/mrd0ll4r) for reporting the original error to Kubo!",
"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" : "Go",
"name" : "github.com/ipfs/go-merkledag"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.4.0"
}, {
"fixed" : "0.8.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/ipfs/go-merkledag/security/advisories/GHSA-x39j-h85h-3f46"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-23495"
}, {
"type" : "WEB",
"url" : "https://github.com/ipfs/go-merkledag/issues/90"
}, {
"type" : "WEB",
"url" : "https://github.com/ipfs/kubo/issues/9297"
}, {
"type" : "WEB",
"url" : "https://github.com/ipfs/go-merkledag/pull/91"
}, {
"type" : "WEB",
"url" : "https://github.com/ipfs/go-merkledag/pull/92"
}, {
"type" : "WEB",
"url" : "https://github.com/ipfs/go-merkledag/pull/93"
}, {
"type" : "WEB",
"url" : "https://en.wikipedia.org/wiki/Directed_acyclic_graph"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/ipfs/go-merkledag"
}, {
"type" : "WEB",
"url" : "https://github.com/ipfs/go-merkledag/releases/tag/v0.8.0"
}, {
"type" : "WEB",
"url" : "https://github.com/ipfs/go-merkledag/releases/tag/v0.8.1"
}, {
"type" : "WEB",
"url" : "https://pkg.go.dev/vuln/GO-2022-1155"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-252", "CWE-755" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-12-08T16:12:26Z",
"nvd_published_at" : "2022-12-08T22:15:00Z"
}
}