CVE-2023-40024: Scancodeio Cross-Site Scripting Vulnerability
MODERATECVE-2023-40024 is a MODERATE (CVSS 6.1) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Scancodeio libraries in the PyPI ecosystem. The issue involves scancode.io reflected cross-site scripting (xss) in license endpoint. Remediation is available by upgrading affected packages to version 32.5.2.
CVE-2023-40024 at a Glance
Security Impact
CVSS: 6.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).
How to Fix CVE-2023-40024
To remediate this vulnerability, upgrade all affected Scancodeio dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install scancodeio>=32.5.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show scancodeio
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2023-40024, inspect your installed packages using pip:
pip show scancodeio
Analyze the terminal output to locate any version of Scancodeio in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 32.5.2), your application is affected.
Note: The pip show scancodeio command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Scancodeio, 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
CVE-2023-40024 Affected Scancodeio Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
scancodeio
|
PyPI |
< 32.5.2
|
32.5.2
|
References
Frequently Asked Questions
What is CVE-2023-40024?
Which Scancodeio versions are affected?
What version fixes CVE-2023-40024?
Is scancodeio affected?
What is the CVSS score of CVE-2023-40024?
What CWE is associated with CVE-2023-40024?
How can I check PyPI dependencies for CVE-2023-40024?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-6xcx-gx7r-rccj",
"modified" : "2023-08-21T19:33:39Z",
"published" : "2023-08-15T20:04:49Z",
"aliases" : [ "CVE-2023-40024" ],
"summary" : "Scancode.io Reflected Cross-Site Scripting (XSS) in license endpoint",
"details" : "### Summary\nIn the `/license/` endpoint, the detailed view key is not properly validated and sanitized, which can result in a potential cross-site scripting (XSS) vulnerability when attempting to access a detailed license view that does not exist.\n\n### Details\nIn the `/license/` endpoint, the `license_details_view` function is vulnerable to a potential cross-site scripting (XSS) attack due to inadequate validation and sanitization of the `key` parameter. This vulnerability arises when attempting to access a key with malicious javascript.\n\n```python\ndef license_details_view(request, key):\n \"\"\"\n Display all available information about a given license `key` followed by\n the full license text.\n \"\"\"\n licenses = get_licenses()\n try:\n data = saneyaml.dump(licenses[key].to_dict())\n text = licenses[key].text\n except KeyError:\n return HttpResponseNotFound(f\"License {key} not found.\") # Leads to cross-site scripting when key is malicious javascript\n return HttpResponse(f\"<pre>{data}</pre><hr><pre>{text}</pre>\")\n```\n\n\n### PoC\n1. Access following endpoint on scancode.io instance: http://localhost/license/%3Cscript%3Ealert(document.cookie);%3C/script%3E/\n\n### Impact\nAttackers can exploit the vulnerability to inject malicious scripts into the response generated by the `license_details_view` function. When unsuspecting users visit the page, their browsers will execute the injected scripts, leading to unauthorized actions, session hijacking, or stealing sensitive information.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "scancodeio"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "32.5.2"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 32.5.1"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nexB/scancode.io/security/advisories/GHSA-6xcx-gx7r-rccj"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-40024"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nexB/scancode.io"
}, {
"type" : "WEB",
"url" : "https://github.com/nexB/scancode.io/blob/dd7769fbc97c84545579cebf1dc4838214098a11/CHANGELOG.rst#v3252-2023-08-14"
}, {
"type" : "WEB",
"url" : "https://github.com/nexB/scancode.io/releases/tag/v32.5.2"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2023-08-15T20:04:49Z",
"nvd_published_at" : "2023-08-14T20:15:12Z"
}
}