LiteDB may deserialize bad JSON on object type using _type
Impact
LiteDB 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.
If your end-user can send to your app a plain JSON string, deserialization can load an unsafe object to fit in your model.
Patches
Version >= 5.0.13 add some basic fixes to avoid this, but is not 100% guaranteed when using Object type
Next major version will contains a allow-list to select what king of Assembly can be loaded
Workarounds
- Avoid users send to your app a JSON string to be direct insert/update into database
- Avoid use classes with
Objecttype - try use an interface when possible
If your app send a plain JSON string to be insert/update into database, prefer this:
// Bad
public class Customer {
public int Id { get; set; }
public string Name { get; set; }
public Object AnyData { get; set; } // <= Avoid use `Object` base type
}
// Good
public class Customer {
public int Id { get; set; }
public string Name { get; set; }
public IDictionary<string, string> AnyData { get; set; } // Will accept only key/value strings
}
References
See this workaround fix on this commit:
https://github.com/mbdavid/LiteDB/commit/4382ff4dd0dd8b8b16a4e37dfd29727c5f70f93f
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| .NET (NuGet) | LiteDB | < 5.0.13 | 5.0.13 |
References
- https://github.com/mbdavid/LiteDB/security/advisories/GHSA-3x49-g6rc-c284
- https://nvd.nist.gov/vuln/detail/CVE-2022-23535
- https://github.com/mbdavid/LiteDB/commit/4382ff4dd0dd8b8b16a4e37dfd29727c5f70f93f
- https://github.com/mbdavid/LiteDB/commit/d72c6774e6a13de2cfcd7d477d3575efeb75c8f2
- https://github.com/mbdavid/LiteDB
- https://github.com/mbdavid/LiteDB/releases/tag/v5.0.13
- CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H- Weakness (CWE)
CWE-502- Platform
- .NET (NuGet)
- Package
LiteDB- Disclosed
- 24.02.2023
- Updated
- 11.10.2026 11:22
Sources and licenses
OSV / GitHub Advisory Database - GHSA-3x49-g6rc-c284 - CC BY 4.0
Vulnerability history: LiteDB
All published vulnerabilities of this package (.NET (NuGet)), newest first. Shows whether this is a one-off slip or a package that needs watching.
This is the only known vulnerability of this package.
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.