CVE-2024-22207: @fastify/swagger ui Default Swagger-ui Configuration Exposes All Vulnerability

MODERATE
Advisory Identifier: GHSA-62jr-84gf-wmg4
CVSS 5.3
CWE-1188
Published
Advisory Summary

CVE-2024-22207 is a MODERATE (CVSS 5.3) default swagger-ui configuration exposes all vulnerability (CWE-1188: Initialization of a Resource with an Insecure Default) affecting @fastify/swagger ui libraries in the npm ecosystem. The issue involves default swagger-ui configuration exposes all files in the module. Remediation is available by upgrading affected packages to version 2.1.0.

CVE-2024-22207 at a Glance

CVE Identifier CVE-2024-22207
GHSA Identifier GHSA-62jr-84gf-wmg4
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-1188: Initialization of a Resource with an Insecure Default
Affected Product @fastify/swagger ui
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

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:N/S:U/C:L/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2024-22207

To remediate this vulnerability, upgrade all affected @fastify/swagger ui dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@fastify/swagger-ui fixed: 2.1.0
npm install @fastify/swagger-ui@2.1.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @fastify/swagger-ui

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-22207, inspect your project dependencies using npm:

npm ls @fastify/swagger-ui

Analyze the terminal output to locate any version of @fastify/swagger ui in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.1.0), your application is affected.

Note: The npm ls @fastify/swagger-ui command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1188: Initialization of a Resource with an Insecure Default, where the product initializes or sets a resource with a default that is intended to be changed by the product's installer, administrator, or maintainer, but the default is not secure. In @fastify/swagger ui, 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

### Impact 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. ### Patches Update to v2.1.0 ### Workarounds Use the `baseDir` option ### References [HackerOne report ](https://hackerone.com/reports/2312369).

CVE-2024-22207 Affected @fastify/swagger ui Versions

1 component(s)
Fixed Versions:
2.1.0
Product / Package Ecosystem Affected Versions Fixed Version
@fastify/swagger-ui
npm
≥ 2.0.0
< 2.1.0
2.1.0

References

Frequently Asked Questions

What is CVE-2024-22207?
CVE-2024-22207 is a security vulnerability in @fastify/swagger ui involving Default swagger-ui configuration exposes all files in the module under CWE-1188: Initialization of a Resource with an Insecure Default.
Which @fastify/swagger ui versions are affected?
Affected versions include releases prior to 2.1.0 across affected packages: @fastify/swagger-ui.
What version fixes CVE-2024-22207?
Upgrading to 2.1.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @fastify/swagger-ui affected?
Yes, @fastify/swagger-ui is affected in releases prior to 2.1.0. Upgrade your dependency to 2.1.0 or later.
What is the CVSS score of CVE-2024-22207?
CVE-2024-22207 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2024-22207?
CVE-2024-22207 is classified under CWE-1188: Initialization of a Resource with an Insecure Default (The product initializes or sets a resource with a default that is intended to be changed by the product's installer, administrator, or maintainer, but the default is not secure.).
How can I check npm dependencies for CVE-2024-22207?
Run the dependency tree command: 'npm ls @fastify/swagger-ui'. 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-62jr-84gf-wmg4",
  "modified" : "2024-02-16T15:30:26Z",
  "published" : "2024-01-16T15:24:41Z",
  "aliases" : [ "CVE-2024-22207" ],
  "summary" : "Default swagger-ui configuration exposes all files in the module",
  "details" : "### Impact\n\nThe 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.\n\n### Patches\n\nUpdate to v2.1.0\n\n### Workarounds\n\nUse  the `baseDir` option\n\n### References\n\n[HackerOne report\n](https://hackerone.com/reports/2312369).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@fastify/swagger-ui"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.1.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/fastify/fastify-swagger-ui/security/advisories/GHSA-62jr-84gf-wmg4"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-22207"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fastify/fastify-swagger-ui/commit/13d799a2c5f14d3dd5b15892e03bbcbae63ee6f7"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/fastify/fastify-swagger-ui"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20240216-0002"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1188" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-01-16T15:24:41Z",
    "nvd_published_at" : "2024-01-15T16:15:13Z"
  }
}