# CVE-2023-39523: ScanCode.io command injection in docker image fetch process

> Attackers can inject malicious commands via the docker_reference parameter in ScanCode.io, leading to code execution on the server.

- **Severity:** Medium 6.8 (`CVSS:3.1/AV:A/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 7 Aug 2023
- **Updated:** 3 Oct 2024
- **Also known as:** GHSA-2ggp-cmvm-f62f, PYSEC-2026-1904

## What is CVE-2023-39523?

CVE-2023-39523 is a medium-severity command injection vulnerability in nexB scancode.io, published on 7 Aug 2023. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

ScanCode.io is a server to script and automate software composition analysis with ScanPipe pipelines. Prior to version 32.5.1, the software has a possible command injection vulnerability in the docker fetch process as it allows to append malicious commands in the `docker_reference` parameter.

In the function `scanpipe/pipes/fetch.py:fetch_docker_image` the parameter `docker_reference` is user controllable. The `docker_reference` variable is then passed to the vulnerable function `get_docker_image_platform`.  However, the `get_docker_image_plaform` function constructs a shell command with the passed `docker_reference`. The `pipes.run_command` then executes the shell command without any prior sanitization, making the function vulnerable to command injections. A malicious user who is able to create or add inputs to a project can inject commands. Although the command injections are blind and the user will not receive direct feedback without logs, it is still possible to cause damage to the server/container. The vulnerability appears for example if a malicious user adds a semicolon after the input of `docker://;`, it would allow appending malicious commands.

Version 32.5.1 contains a patch for this issue. The `docker_reference` input should be sanitized to avoid command injections and, as a workaround, one may avoid creating commands with user controlled input directly.

Weakness: CWE-77 (Improper Neutralization of Special Elements used in a Command)

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

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.1 |
| `scancodeio` | PyPI | All versions | 32.5.1 |
| `scancodeio` | PyPI | All versions | 32.5.1 |

Products: Nexb Scancode.io.

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

Upgrade scancodeio to 32.5.1 or later.

## Is CVE-2023-39523 being exploited?

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

## Other vulnerabilities in nexB scancode.io

- [CVE-2023-40024](https://insights.sbomify.com/CVE-2023-40024/): Reflected Cross-Site Scripting (XSS) in scancode.io license endpoint (medium 5.4)

## Fix prompt for AI coding agents

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

What it is: CVE-2023-39523 is a medium-severity command injection vulnerability in nexB scancode.io, published on 7 Aug 2023. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-39523 exists.

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

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-39523/ (Markdown: https://insights.sbomify.com/CVE-2023-39523/index.md)
```

## Sources

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

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