GitHub Advisoryadvisory · NuGet
GHSA-3x49-g6rc-c284 LiteDB may deserialize bad JSON on object type using _type
CRITICAL
Official page ↗
- Aliases
- CVE-2022-23535
- Ecosystem
- NuGet
- Packages
- LiteDB
- Severity
- Critical
- CVSS vector
- CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
- Weaknesses
- CWE-502
- Reviewed
- 2023-02-24
Affected packages
• NuGet LiteDB: < 5.0.13 → fixed in 5.0.13
Description
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 `Object` type - 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; } // AnyData { get; set; } // Will accept only key/value strings
}
```
References
See this workaround fix on this commit:
https://github.com/mbdavid/LiteDB/commit/4382ff4dd0dd8b8b16a4e37dfd29727c5f70f93f
Related
Alias · CVE (1)
- CVE-2022-23535 LiteDB is a small, fast and lightweight .NET NoSQL embedded database. vulnerability
Weakness · CWE (1)
- CWE-502 Deserialization of Untrusted Data weakness
References
- https://github.com/mbdavid/LiteDB/security/advisories/GHSA-3x49-g6rc-c284 web
- https://nvd.nist.gov/vuln/detail/CVE-2022-23535 advisory
- https://github.com/mbdavid/LiteDB/commit/4382ff4dd0dd8b8b16a4e37dfd29727c5f70f93f web
- https://github.com/mbdavid/LiteDB/commit/d72c6774e6a13de2cfcd7d477d3575efeb75c8f2 web
- https://github.com/mbdavid/LiteDB package
- https://github.com/mbdavid/LiteDB/releases/tag/v5.0.13 web