ghsa-xph5-278p-26qx
Vulnerability from github
Description
Vulnerability Overview
The project's OIDC redirect handling logic constructs the host and protocol of the final redirect URL based on the X-Forwarded-Host or Host headers and the X-Forwarded-Proto value. In deployments where a reverse proxy forwards client-supplied X-Forwarded-* headers to the origin as-is, or where the origin trusts them without validation, an attacker can inject an arbitrary host and trigger an open redirect that sends users to a malicious domain.
Vulnerable Code Analysis
```bash const internalRedirectUrlString = await oidcService.getInteractionResult(uid, result); log('OIDC Provider internal redirect URL string: %s', internalRedirectUrlString);
let finalRedirectUrl; try { finalRedirectUrl = correctOIDCUrl(request, new URL(internalRedirectUrlString)); } catch { finalRedirectUrl = new URL(internalRedirectUrlString); log('Warning: Could not parse redirect URL, using as-is: %s', internalRedirectUrlString); }
return NextResponse.redirect(finalRedirectUrl, { headers: request.headers, status: 303, }); ```
https://github.com/lobehub/lobe-chat/blob/aa841a3879c30142720485182ad62aa0dbd74edc/src/app/(backend)/oidc/consent/route.ts#L113-L127
PoC
curl Example
bash
curl -i 'http://localhost:3210/oidc/callback/desktop?code=abc&state=test123' \
-H 'X-Forwarded-Host: google.com' \
-H 'X-Forwarded-Proto: https'
Impact
- It can force users to redirect to untrusted external domains, leading to subsequent attacks such as phishing, credential harvesting, and session fixation.
- It can disrupt the OAuth/OIDC flow user experience by redirecting users to malicious domains disguised as legitimate pages (even though this path doesn't directly include tokens, it can be exploited for social engineering attacks through redirect chains).
- The impact can be amplified when redirect chains are combined with other vulnerabilities such as CSP bypass or cache poisoning.
{ "affected": [ { "package": { "ecosystem": "npm", "name": "@lobehub/chat" }, "ranges": [ { "events": [ { "introduced": "0" }, { "fixed": "1.130.1" } ], "type": "ECOSYSTEM" } ] } ], "aliases": [ "CVE-2025-59426" ], "database_specific": { "cwe_ids": [ "CWE-601" ], "github_reviewed": true, "github_reviewed_at": "2025-09-24T21:34:10Z", "nvd_published_at": "2025-09-25T14:15:45Z", "severity": "MODERATE" }, "details": "### **Description**\n\n---\n\n\u003e Vulnerability Overview\n\u003e \n\nThe project\u0027s OIDC redirect handling logic constructs the host and protocol of the final redirect URL based on the X-Forwarded-Host or Host headers and the X-Forwarded-Proto value. In deployments where a reverse proxy forwards client-supplied X-Forwarded-* headers to the origin as-is, or where the origin trusts them without validation, an attacker can inject an arbitrary host and trigger an open redirect that sends users to a malicious domain.\n\n\u003e Vulnerable Code Analysis\n\u003e \n\n```bash\nconst internalRedirectUrlString = await oidcService.getInteractionResult(uid, result);\nlog(\u0027OIDC Provider internal redirect URL string: %s\u0027, internalRedirectUrlString);\n\nlet finalRedirectUrl;\ntry {\n finalRedirectUrl = correctOIDCUrl(request, new URL(internalRedirectUrlString));\n} catch {\n finalRedirectUrl = new URL(internalRedirectUrlString);\n log(\u0027Warning: Could not parse redirect URL, using as-is: %s\u0027, internalRedirectUrlString);\n}\n\nreturn NextResponse.redirect(finalRedirectUrl, {\n headers: request.headers,\n status: 303,\n});\n```\n\nhttps://github.com/lobehub/lobe-chat/blob/aa841a3879c30142720485182ad62aa0dbd74edc/src/app/(backend)/oidc/consent/route.ts#L113-L127\n\n### PoC\n\n---\n\n\u003e curl Example\n\u003e \n\n```bash\ncurl -i \u0027http://localhost:3210/oidc/callback/desktop?code=abc\u0026state=test123\u0027 \\\n -H \u0027X-Forwarded-Host: google.com\u0027 \\\n -H \u0027X-Forwarded-Proto: https\u0027\n```\n\n\u003cimg width=\"1504\" height=\"304\" alt=\"image\" src=\"https://github.com/user-attachments/assets/b71d937d-7be2-49db-8f3d-e07371912800\" /\u003e\n\n\n### Impact\n\n---\n\n- It can force users to redirect to untrusted external domains, leading to subsequent attacks such as phishing, credential harvesting, and session fixation.\n- It can disrupt the OAuth/OIDC flow user experience by redirecting users to malicious domains disguised as legitimate pages (even though this path doesn\u0027t directly include tokens, it can be exploited for social engineering attacks through redirect chains).\n- The impact can be amplified when redirect chains are combined with other vulnerabilities such as CSP bypass or cache poisoning.", "id": "GHSA-xph5-278p-26qx", "modified": "2025-09-26T16:28:58Z", "published": "2025-09-24T21:34:10Z", "references": [ { "type": "WEB", "url": "https://github.com/lobehub/lobe-chat/security/advisories/GHSA-xph5-278p-26qx" }, { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-59426" }, { "type": "WEB", "url": "https://github.com/lobehub/lobe-chat/commit/70f52a3c1fadbd41a9db0e699d1e44d9965de445" }, { "type": "PACKAGE", "url": "https://github.com/lobehub/lobe-chat" }, { "type": "WEB", "url": "https://github.com/lobehub/lobe-chat/blob/aa841a3879c30142720485182ad62aa0dbd74edc/src/app/(backend)/oidc/consent/route.ts#L113-L127" } ], "schema_version": "1.4.0", "severity": [ { "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N", "type": "CVSS_V3" } ], "summary": "lobe-chat has an Open Redirect" }
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.