# CVE-2024-22207: Default swagger-ui configuration exposes all files in the module

> Default configuration exposes all module files via HTTP routes, allowing attackers to read sensitive source code or configuration files.

- **Severity:** Medium 5.3 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 15 Jan 2024
- **Updated:** 17 Jun 2025
- **Also known as:** GHSA-62jr-84gf-wmg4

## What is CVE-2024-22207?

CVE-2024-22207 is a medium-severity vulnerability in fastify-swagger-ui, published on 15 Jan 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

fastify-swagger-ui is a Fastify plugin for serving Swagger UI.  Prior to 2.1.0, the default configuration of `@fastify/swagger-ui` without `baseDir` set will lead to all files in the module's directory being exposed via http routes served by the module.  The vulnerability is fixed in v2.1.0. Setting the `baseDir` option can also work around this vulnerability.

Weakness: CWE-1188 (Initialization of a Resource with an Insecure Default)

## Which versions are affected by CVE-2024-22207?

2 open source packages ship an affected version, including @fastify/swagger-ui. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@fastify/swagger-ui` | npm | From 2.0.0 | 2.1.0 |
| `@fastify/swagger-ui` | npm | From 2.0.0 | 2.1.0 |

Products: Smartbear Swagger Ui.

## How do I fix CVE-2024-22207?

Upgrade @fastify/swagger-ui to 2.1.0 or later.

## Is CVE-2024-22207 being exploited?

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

Public exploit code:

- Fastify Swagger-UI - Information Disclosure (nuclei): http/cves/2024/CVE-2024-22207.yaml

## Other vulnerabilities in fastify-swagger-ui

- [CVE-2018-25031](https://insights.sbomify.com/CVE-2018-25031/): Spoofing attack in swagger-ui (medium 4.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-22207 and fix it if it is affected.

What it is: CVE-2024-22207 is a medium-severity vulnerability in fastify-swagger-ui, published on 15 Jan 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-22207 exists.

Affected packages and fixed versions:
- @fastify/swagger-ui (npm): affected from 2.0.0; fixed in 2.1.0
- @fastify/swagger-ui (npm): affected from 2.0.0; fixed in 2.1.0

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

## Sources

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

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