CVE-2022-2111: Inventree Unrestricted Attachment Upload Vulnerability

HIGH
Advisory Identifier: GHSA-fr2w-mp56-g4xp
CVSS 8.8
CWE-434
Published
Advisory Summary

CVE-2022-2111 is a HIGH (CVSS 8.8) unrestricted attachment upload vulnerability (CWE-434: Unrestricted Upload of File with Dangerous Type) affecting Inventree libraries in the PyPI ecosystem. The issue involves unrestricted attachment upload. Remediation is available by upgrading affected packages to version 0.7.2.

CVE-2022-2111 at a Glance

CVE Identifier CVE-2022-2111
GHSA Identifier GHSA-fr2w-mp56-g4xp
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-434: Unrestricted Upload of File with Dangerous Type
Affected Product Inventree
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2022-2111

To remediate this vulnerability, upgrade all affected Inventree dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

inventree fixed: 0.7.2
pip install inventree>=0.7.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show inventree

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2022-2111, inspect your installed packages using pip:

pip show inventree

Analyze the terminal output to locate any version of Inventree in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.7.2), your application is affected.

Note: The pip show inventree command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-434: Unrestricted Upload of File with Dangerous Type, where the product allows the upload or transfer of dangerous file types that are automatically processed within its environment. In Inventree, 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

### Impact InvenTree allows unrestricted upload of files as attachments to various database fields. Potentially dangerous files (such as HTML files containing malicious javascript) can be uploaded, and (when opened by the user) run the malicious code directly in the users browser. ![image](https://user-images.githubusercontent.com/10080325/173549827-af2d7a5c-1359-4d68-a920-dfdd0ccc882e.png) *Note that the upload of malicious files must be performed by an authenticated user account* ### Solution The solution for this vulnerability is to ensure that attachment files are downloaded to the local machine before opening, rather than opening the file in the current browser context. ### Patches - The issue is addressed in the upcoming 0.8.0 release - This fix will also be back-ported to the 0.7.x branch, applied to the 0.7.2 release ### Workarounds Users can alleviate risk of opening malicious files by right-clicking on the attachment link and selecting "Save link as" ![image](https://user-images.githubusercontent.com/10080325/173550035-2de4bf01-f0d3-4be8-ac45-6fbcf66a95e7.png) This minimizes risk (e.g. of XSS attacks) by opening the HTML file from the users computer ### References https://huntr.dev/bounties/a0e5c68e-0f75-499b-bd7b-d935fb8c0cd1/ ### For more information If you have any questions or comments about this advisory: * Open an issue in [github](http://github.com/inventree/inventree) * Email us at [security@inventree.org](mailto:security@inventree.org)

CVE-2022-2111 Affected Inventree Versions

1 component(s)
Fixed Versions:
0.7.2
Product / Package Ecosystem Affected Versions Fixed Version
inventree
PyPI
< 0.7.2
0.7.2

References

Frequently Asked Questions

What is CVE-2022-2111?
CVE-2022-2111 is a security vulnerability in Inventree involving Unrestricted Attachment Upload under CWE-434: Unrestricted Upload of File with Dangerous Type.
Which Inventree versions are affected?
Affected versions include releases prior to 0.7.2 across affected packages: inventree.
What version fixes CVE-2022-2111?
Upgrading to 0.7.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is inventree affected?
Yes, inventree is affected in releases prior to 0.7.2. Upgrade your dependency to 0.7.2 or later.
What is the CVSS score of CVE-2022-2111?
CVE-2022-2111 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2022-2111?
CVE-2022-2111 is classified under CWE-434: Unrestricted Upload of File with Dangerous Type (The product allows the upload or transfer of dangerous file types that are automatically processed within its environment.).
How can I check PyPI dependencies for CVE-2022-2111?
Run the dependency tree command: 'pip show inventree'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-fr2w-mp56-g4xp",
  "modified" : "2022-06-29T21:47:25Z",
  "published" : "2022-06-17T01:16:55Z",
  "aliases" : [ "CVE-2022-2111" ],
  "summary" : "Unrestricted Attachment Upload",
  "details" : "### Impact\n\nInvenTree allows unrestricted upload of files as attachments to various database fields. Potentially dangerous files (such as HTML files containing malicious javascript) can be uploaded, and (when opened by the user) run the malicious code directly in the users browser.\n\n![image](https://user-images.githubusercontent.com/10080325/173549827-af2d7a5c-1359-4d68-a920-dfdd0ccc882e.png)\n\n*Note that the upload of malicious files must be performed by an authenticated user account*\n\n### Solution\n\nThe solution for this vulnerability is to ensure that attachment files are downloaded to the local machine before opening, rather than opening the file in the current browser context.\n\n### Patches\n\n- The issue is addressed in the upcoming 0.8.0 release\n- This fix will also be back-ported to the 0.7.x branch, applied to the 0.7.2 release\n\n### Workarounds\n\nUsers can alleviate risk of opening malicious files by right-clicking on the attachment link and selecting \"Save link as\"\n\n![image](https://user-images.githubusercontent.com/10080325/173550035-2de4bf01-f0d3-4be8-ac45-6fbcf66a95e7.png)\n\nThis minimizes risk (e.g. of XSS attacks) by opening the HTML file from the users computer\n\n### References\n\nhttps://huntr.dev/bounties/a0e5c68e-0f75-499b-bd7b-d935fb8c0cd1/\n\n### For more information\nIf you have any questions or comments about this advisory:\n\n* Open an issue in [github](http://github.com/inventree/inventree)\n* Email us at [security@inventree.org](mailto:security@inventree.org)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "inventree"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.7.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/inventree/InvenTree/security/advisories/GHSA-fr2w-mp56-g4xp"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-2111"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/inventree/inventree/commit/26bf51c20a1c9b3130ac5dd2e17649bece5ff84f"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/inventree/inventree-python"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.dev/bounties/a0e5c68e-0f75-499b-bd7b-d935fb8c0cd1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-434" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-17T01:16:55Z",
    "nvd_published_at" : "2022-06-17T13:15:00Z"
  }
}