GHSA-3X49-G6RC-C284

Vulnerability from github – Published: 2023-02-24 16:22 – Updated: 2023-03-06 22:00
VLAI
Summary
LiteDB may deserialize bad JSON on object type using _type
Details

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; } // <= 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

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "NuGet",
        "name": "LiteDB"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "5.0.13"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2022-23535"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-502"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2023-02-24T16:22:50Z",
    "nvd_published_at": "2023-02-24T23:15:00Z",
    "severity": "CRITICAL"
  },
  "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 \u003e= 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; } // \u003c= 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\u003cstring, string\u003e 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",
  "id": "GHSA-3x49-g6rc-c284",
  "modified": "2023-03-06T22:00:24Z",
  "published": "2023-02-24T16:22:50Z",
  "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"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "LiteDB may deserialize bad JSON on object type using _type"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.

Loading…

Loading…

Loading…

Related by attack behaviour

Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.


Loading…