CVE-2024-37895: @lobehub/chat Lobe Chat API Key Leak Vulnerability

MODERATE
Advisory Identifier: GHSA-p36r-qxgx-jq2v
CVSS 5.7
CWE-918 CWE-200
Published
Advisory Summary

CVE-2024-37895 is a MODERATE (CVSS 5.7) lobe chat api key leak vulnerability (CWE-918: Server-Side Request Forgery (SSRF)) affecting @lobehub/chat libraries in the npm ecosystem. The issue involves lobe chat api key leak. Remediation is available by upgrading affected packages to version 0.162.25.

CVE-2024-37895 at a Glance

CVE Identifier CVE-2024-37895
GHSA Identifier GHSA-p36r-qxgx-jq2v
Severity MODERATE
CVSS v3.1 Base Score 5.7
CWE Classification CWE-918: Server-Side Request Forgery (SSRF)
Affected Product @lobehub/chat
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:N/A:N).

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

How to Fix CVE-2024-37895

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

@lobehub/chat fixed: 0.162.25
npm install @lobehub/chat@0.162.25
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 @lobehub/chat

How to Check if You Are Affected

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

npm ls @lobehub/chat

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

Note: The npm ls @lobehub/chat 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-918: Server-Side Request Forgery (SSRF), where the web server receives a url or similar request from an upstream component and retrieves the contents of this url, but it does not sufficiently ensure that the request is being sent to the expected destination. In @lobehub/chat, 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 If an attacker can successfully authenticate through SSO/Access Code, they can obtain the real backend API Key by modifying the base URL to their own attack URL on the frontend and setting up a server-side request. ### Details The attack process is described above. ![image](https://github.com/lobehub/lobe-chat/assets/36695271/df5e0c3c-af28-45c3-959f-182cc9d06680) ### PoC Frontend: 1. Pass basic authentication (SSO/Access Code). 2. Set the Base URL to a private attack address. 3. Configure the request method to be a server-side request. 4. At the self-set attack address, retrieve the API Key information from the request headers. Backend: 1. The LobeChat version allows setting the Base URL. 2. There is no outbound traffic whitelist. ### Impact All community version LobeChat users using SSO/Access Code authentication, tested on version 0.162.13.

CVE-2024-37895 Affected @lobehub/chat Versions

1 component(s)
Fixed Versions:
0.162.25
Product / Package Ecosystem Affected Versions Fixed Version
@lobehub/chat
npm
< 0.162.25
0.162.25

References

Frequently Asked Questions

What is CVE-2024-37895?
CVE-2024-37895 is a security vulnerability in @lobehub/chat involving Lobe Chat API Key Leak under CWE-918: Server-Side Request Forgery (SSRF).
Which @lobehub/chat versions are affected?
Affected versions include releases prior to 0.162.25 across affected packages: @lobehub/chat.
What version fixes CVE-2024-37895?
Upgrading to 0.162.25 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @lobehub/chat affected?
Yes, @lobehub/chat is affected in releases prior to 0.162.25. Upgrade your dependency to 0.162.25 or later.
What is the CVSS score of CVE-2024-37895?
CVE-2024-37895 has a CVSS v3.1 base score of 5.7 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2024-37895?
CVE-2024-37895 is classified under CWE-918: Server-Side Request Forgery (SSRF) (The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.).
How can I check npm dependencies for CVE-2024-37895?
Run the dependency tree command: 'npm ls @lobehub/chat'. 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-p36r-qxgx-jq2v",
  "modified" : "2024-06-17T22:28:41Z",
  "published" : "2024-06-17T22:28:41Z",
  "aliases" : [ "CVE-2024-37895" ],
  "summary" : "Lobe Chat API Key Leak",
  "details" : "### Summary\n\nIf an attacker can successfully authenticate through SSO/Access Code, they can obtain the real backend API Key by modifying the base URL to their own attack URL on the frontend and setting up a server-side request.\n\n### Details\n\nThe attack process is described above.\n\n![image](https://github.com/lobehub/lobe-chat/assets/36695271/df5e0c3c-af28-45c3-959f-182cc9d06680)\n\n### PoC\n\nFrontend:\n1. Pass basic authentication (SSO/Access Code).\n2. Set the Base URL to a private attack address.\n3. Configure the request method to be a server-side request.\n4. At the self-set attack address, retrieve the API Key information from the request headers.\n\nBackend:\n1. The LobeChat version allows setting the Base URL.\n2. There is no outbound traffic whitelist.\n\n### Impact\n\nAll community version LobeChat users using SSO/Access Code authentication, tested on version 0.162.13.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@lobehub/chat"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.162.25"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/lobehub/lobe-chat/security/advisories/GHSA-p36r-qxgx-jq2v"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-37895"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/lobehub/lobe-chat"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200", "CWE-918" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-06-17T22:28:41Z",
    "nvd_published_at" : "2024-06-17T20:15:13Z"
  }
}