CVE-2022-23535: LiteDB LiteDB May Deserialize Bad JSON Vulnerability
CRITICALCVE-2022-23535 is a CRITICAL (CVSS 9.8) litedb may deserialize bad json vulnerability (CWE-502: Deserialization of Untrusted Data) affecting LiteDB libraries in the NuGet ecosystem. The issue involves litedb may deserialize bad json on object type using _type. Remediation is available by upgrading affected packages to version 5.0.13.
CVE-2022-23535 at a Glance
Security Impact
CVSS: 9.8
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:H/I:H/A:H).
How to Fix CVE-2022-23535
To remediate this vulnerability, upgrade all affected LiteDB 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 LiteDB to 5.0.13
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for LiteDB
How to Check if You Are Affected
To determine whether your application is affected by CVE-2022-23535, inspect your project dependencies for LiteDB:
inspect dependencies for LiteDB
Analyze the terminal output to locate any version of LiteDB in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.0.13), 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-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In LiteDB, 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-23535 Affected LiteDB Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
LiteDB
|
NuGet |
< 5.0.13
|
5.0.13
|
References
Frequently Asked Questions
What is CVE-2022-23535?
Which LiteDB versions are affected?
What version fixes CVE-2022-23535?
Is LiteDB affected?
What is the CVSS score of CVE-2022-23535?
What CWE is associated with CVE-2022-23535?
How can I check NuGet dependencies for CVE-2022-23535?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-3x49-g6rc-c284",
"modified" : "2023-03-06T22:00:24Z",
"published" : "2023-02-24T16:22:50Z",
"aliases" : [ "CVE-2022-23535" ],
"summary" : "LiteDB may deserialize bad JSON on object type using _type",
"details" : "### Impact\nLiteDB use a special field in JSON documents to cast diferent types from `BsonDocument` do POCO classes. When instance of an object are not the same of class, `BsonMapper` use a special field `_type` string info with full class name with assembly to be loaded and fit in your model.\nIf your end-user can send to your app a plain JSON string, deserialization can load an unsafe object to fit in your model.\n\n### Patches\nVersion >= 5.0.13 add some basic fixes to avoid this, but is not 100% guaranteed when using `Object` type\nNext major version will contains a allow-list to select what king of Assembly can be loaded\n\n### Workarounds\n- Avoid users send to your app a JSON string to be direct insert/update into database\n- Avoid use classes with `Object` type - try use an interface when possible\n\nIf your app send a plain JSON string to be insert/update into database, prefer this:\n```\n// Bad\npublic class Customer {\n public int Id { get; set; }\n public string Name { get; set; }\n public Object AnyData { get; set; } // <= Avoid use `Object` base type\n}\n\n// Good\npublic class Customer {\n public int Id { get; set; }\n public string Name { get; set; }\n public IDictionary<string, string> AnyData { get; set; } // Will accept only key/value strings\n}\n\n```\n\n### References\nSee this workaround fix on this commit:\n\nhttps://github.com/mbdavid/LiteDB/commit/4382ff4dd0dd8b8b16a4e37dfd29727c5f70f93f\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "NuGet",
"name" : "LiteDB"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "5.0.13"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/mbdavid/LiteDB/security/advisories/GHSA-3x49-g6rc-c284"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-23535"
}, {
"type" : "WEB",
"url" : "https://github.com/mbdavid/LiteDB/commit/4382ff4dd0dd8b8b16a4e37dfd29727c5f70f93f"
}, {
"type" : "WEB",
"url" : "https://github.com/mbdavid/LiteDB/commit/d72c6774e6a13de2cfcd7d477d3575efeb75c8f2"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/mbdavid/LiteDB"
}, {
"type" : "WEB",
"url" : "https://github.com/mbdavid/LiteDB/releases/tag/v5.0.13"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-502" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2023-02-24T16:22:50Z",
"nvd_published_at" : "2023-02-24T23:15:00Z"
}
}