CVE-2023-32686: Kiwitcms Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-x7c2-7wvg-jpx7
CVSS 5.4
CWE-434 CWE-79
Published
Advisory Summary

CVE-2023-32686 is a MODERATE (CVSS 5.4) cross-site scripting vulnerability (CWE-434: Unrestricted Upload of File with Dangerous Type) affecting Kiwitcms libraries in the PyPI ecosystem. The issue involves kiwitcms vulnerable to stored xss via unrestricted files upload. Remediation is available by upgrading affected packages to version 12.3.

CVE-2023-32686 at a Glance

CVE Identifier CVE-2023-32686
GHSA Identifier GHSA-x7c2-7wvg-jpx7
Severity MODERATE
CVSS v3.1 Base Score 5.4
CWE Classification CWE-434: Unrestricted Upload of File with Dangerous Type
Affected Product Kiwitcms
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.4

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:R/S:C/C:L/I:L/A:N).

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

How to Fix CVE-2023-32686

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

kiwitcms fixed: 12.3
pip install kiwitcms>=12.3
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 kiwitcms

How to Check if You Are Affected

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

pip show kiwitcms

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

Note: The pip show kiwitcms 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 Kiwitcms, 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 Kiwi TCMS allows users to upload attachments to test plans, test cases, etc. Earlier versions of Kiwi TCMS had introduced upload validators in order to prevent potentially dangerous files from being uploaded, see [GHSA-fwcf-753v-fgcj](https://github.com/kiwitcms/Kiwi/security/advisories/GHSA-fwcf-753v-fgcj) and Content-Security-Policy definition to prevent cross-site-scripting attacks, see [GHSA-2wcr-87wf-cf9j](https://github.com/kiwitcms/Kiwi/security/advisories/GHSA-2wcr-87wf-cf9j). The upload validation checks were not robust enough which left the possibility of an attacker to circumvent them and upload a potentially dangerous file. Exploting this flaw a combination of files could be uploaded so that they work together to circumvent the existing Content-Security-Policy and allow execution of arbitrary JavaScript in the browser. ### Patches - File upload validation code has been improved - Kiwi TCMS will now force `Content-Type: text/plain` when serving uploaded files ### Workarounds 1) Force the Content-Type header via a custom Django middleware, see `ExtraHeadersMiddleware` in https://github.com/kiwitcms/Kiwi/blob/master/tcms/core/middleware.py#L23 and/or 2) Force the Content-Type header via Nginx overrides, see `location /uploads/` in https://github.com/kiwitcms/Kiwi/blob/master/etc/nginx.conf ### References Disclosed by [Antonio Spataro](https://huntr.dev/bounties/db75275f-8bcd-482b-ae12-feff660d4794) and [ek1ng](https://huntr.dev/bounties/46d5b535-bdff-4b98-8691-a907591fcf10/). Additional credits to [Ahmed Rabeaa Mosa](https://huntr.dev/bounties/cbc2676a-90ff-457f-9cdc-2a7981f960f3/).

CVE-2023-32686 Affected Kiwitcms Versions

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

References

Frequently Asked Questions

What is CVE-2023-32686?
CVE-2023-32686 is a security vulnerability in Kiwitcms involving kiwitcms vulnerable to stored XSS via unrestricted files upload under CWE-434: Unrestricted Upload of File with Dangerous Type.
Which Kiwitcms versions are affected?
Affected versions include releases prior to 12.3 across affected packages: kiwitcms.
What version fixes CVE-2023-32686?
Upgrading to 12.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is kiwitcms affected?
Yes, kiwitcms is affected in releases prior to 12.3. Upgrade your dependency to 12.3 or later.
What is the CVSS score of CVE-2023-32686?
CVE-2023-32686 has a CVSS v3.1 base score of 5.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2023-32686?
CVE-2023-32686 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-2023-32686?
Run the dependency tree command: 'pip show kiwitcms'. 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-x7c2-7wvg-jpx7",
  "modified" : "2023-06-02T22:22:57Z",
  "published" : "2023-05-22T19:39:46Z",
  "aliases" : [ "CVE-2023-32686" ],
  "summary" : "kiwitcms vulnerable to stored XSS via unrestricted files upload",
  "details" : "### Impact\nKiwi TCMS allows users to upload attachments to test plans, test cases, etc. Earlier versions of Kiwi TCMS had introduced upload validators in order to prevent potentially dangerous files from being uploaded, see [GHSA-fwcf-753v-fgcj](https://github.com/kiwitcms/Kiwi/security/advisories/GHSA-fwcf-753v-fgcj) and Content-Security-Policy definition to prevent cross-site-scripting attacks, see [GHSA-2wcr-87wf-cf9j](https://github.com/kiwitcms/Kiwi/security/advisories/GHSA-2wcr-87wf-cf9j).\n\nThe upload validation checks were not robust enough which left the possibility of an attacker to circumvent them and upload a potentially dangerous file. Exploting this flaw a combination of files could be uploaded so that they work together to circumvent the existing Content-Security-Policy and allow execution of arbitrary JavaScript in the browser.\n\n### Patches\n- File upload validation code has been improved\n- Kiwi TCMS will now force `Content-Type: text/plain`  when serving uploaded files\n\n### Workarounds\n\n1) Force the Content-Type header via a custom Django middleware, see `ExtraHeadersMiddleware` in https://github.com/kiwitcms/Kiwi/blob/master/tcms/core/middleware.py#L23 and/or\n2) Force the Content-Type header via Nginx overrides, see `location /uploads/` in https://github.com/kiwitcms/Kiwi/blob/master/etc/nginx.conf\n\n### References\nDisclosed by [Antonio Spataro](https://huntr.dev/bounties/db75275f-8bcd-482b-ae12-feff660d4794) and [ek1ng](https://huntr.dev/bounties/46d5b535-bdff-4b98-8691-a907591fcf10/). Additional credits to [Ahmed Rabeaa Mosa](https://huntr.dev/bounties/cbc2676a-90ff-457f-9cdc-2a7981f960f3/).\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "kiwitcms"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "12.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/kiwitcms/Kiwi/security/advisories/GHSA-2wcr-87wf-cf9j"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/kiwitcms/Kiwi/security/advisories/GHSA-fwcf-753v-fgcj"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/kiwitcms/Kiwi/security/advisories/GHSA-x7c2-7wvg-jpx7"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-32686"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/kiwitcms/Kiwi"
  }, {
    "type" : "WEB",
    "url" : "https://kiwitcms.org/blog/kiwi-tcms-team/2023/05/22/kiwi-tcms-123"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-434", "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-05-22T19:39:46Z",
    "nvd_published_at" : "2023-05-27T04:15:25Z"
  }
}