# CVE-2023-40024: Reflected Cross-Site Scripting (XSS) in scancode.io license endpoint

> Attackers can inject malicious scripts via the license endpoint, leading to session hijacking or data theft for users of ScanCode.io.

- **Severity:** Medium 5.4 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 14 Aug 2023
- **Updated:** 2 Oct 2024
- **Also known as:** GHSA-6xcx-gx7r-rccj, PYSEC-2026-1905

## What is CVE-2023-40024?

CVE-2023-40024 is a medium-severity cross-site scripting vulnerability in nexB scancode.io, published on 14 Aug 2023. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

ScanCode.io is a server to script and automate software composition analysis pipelines. 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. Attackers can exploit this 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. This issue has been addressed in release `32.5.2`. Users are advised to upgrade. There are no known workarounds for this vulnerability.

Weakness: CWE-79 (Improper Neutralization of Input During Web Page Generation)

## Which versions are affected by CVE-2023-40024?

3 open source packages ship an affected version, including scancodeio. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `scancodeio` | PyPI | All versions | 32.5.2 |
| `scancodeio` | PyPI | All versions | 32.5.2 |
| `scancodeio` | PyPI | All versions | 32.5.2 |

Products: Nexb Scancode.io.

## How do I fix CVE-2023-40024?

Upgrade scancodeio to 32.5.2 or later.

## Is CVE-2023-40024 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-40024 exists.

## Other vulnerabilities in nexB scancode.io

- [CVE-2023-39523](https://insights.sbomify.com/CVE-2023-39523/): ScanCode.io command injection in docker image fetch process (medium 6.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-40024 and fix it if it is affected.

What it is: CVE-2023-40024 is a medium-severity cross-site scripting vulnerability in nexB scancode.io, published on 14 Aug 2023. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-40024 exists.

Affected packages and fixed versions:
- scancodeio (PyPI): affected all versions; fixed in 32.5.2
- scancodeio (PyPI): affected all versions; fixed in 32.5.2
- scancodeio (PyPI): affected all versions; fixed in 32.5.2

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-40024/ (Markdown: https://insights.sbomify.com/CVE-2023-40024/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-40024
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-40024
- OSV: https://osv.dev/vulnerability/CVE-2023-40024

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-40024/
Summaries are generated and may contain mistakes; the official description above is the record.
