Vulnerabilities in pkg:pypi/scancodeio

PACKAGE
Advisory Identifier: GHSA-6xcx-gx7r-rccj
Advisory Summary

CVE-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.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/scancodeio

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/scancodeio. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-6xcx-gx7r-rccj CVE-2023-40024 MODERATE Scancode.io Reflected Cross-Site Scripting (XSS) in license endpoint
GHSA-2ggp-cmvm-f62f CVE-2023-39523 MODERATE ScanCode.io command injection in docker image fetch process

CVE-2023-40024 at a Glance

CVE Identifier CVE-2023-40024
GHSA Identifier GHSA-6xcx-gx7r-rccj
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Scancodeio
Package Ecosystem PyPI
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
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-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.

scancodeio fixed: 32.5.2
pip install scancodeio>=32.5.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 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

### Summary In 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. ### Details In 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. ```python def license_details_view(request, key): """ Display all available information about a given license `key` followed by the full license text. """ licenses = get_licenses() try: data = saneyaml.dump(licenses[key].to_dict()) text = licenses[key].text except KeyError: return HttpResponseNotFound(f"License {key} not found.") # Leads to cross-site scripting when key is malicious javascript return HttpResponse(f"<pre>{data}</pre><hr><pre>{text}</pre>") ``` ### PoC 1. Access following endpoint on scancode.io instance: http://localhost/license/%3Cscript%3Ealert(document.cookie);%3C/script%3E/ ### Impact Attackers 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.

CVE-2023-40024 Affected Scancodeio Versions

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

References

Frequently Asked Questions

What is CVE-2023-40024?
CVE-2023-40024 is a security vulnerability in Scancodeio involving Scancode.io Reflected Cross-Site Scripting (XSS) in license endpoint under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Scancodeio versions are affected?
Affected versions include releases prior to 32.5.2 across affected packages: scancodeio.
What version fixes CVE-2023-40024?
Upgrading to 32.5.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is scancodeio affected?
Yes, scancodeio is affected in releases prior to 32.5.2. Upgrade your dependency to 32.5.2 or later.
What is the CVSS score of CVE-2023-40024?
CVE-2023-40024 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2023-40024?
CVE-2023-40024 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (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.).
How can I check PyPI dependencies for CVE-2023-40024?
Run the dependency tree command: 'pip show scancodeio'. 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-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"
  }
}