All vulnerabilities

Servers and applications

GHSA-53fc-329q-9fmc

Reflected XSS via 'lang' cookie attribute - '$&' replacement-pattern expansion defeats quote escaping

Severity
Medium 5.4
Published
17 Nov 2026
Last changed
17 Nov 2026
Added to UpHeron
17 Nov 2026
Fixed in
0.8.8
Weakness
Cross-site scripting (CWE-79)
Attack
Over the network · No login needed · Needs someone to click or open something
Attacker can
Read some data · Change some data
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N
Sources
Project advisories (GitHub)

Description

The unauthenticated SPA served by GET /index.html (and by the SPA catch-all for every unmatched path, e.g. GET /) reflects attacker-controlled request data into the lang="…" attribute of the root element. The value is taken from the lang request cookie, falling back to the first value of the Accept-Language request header.

The reflected value is used as the replacement argument of String.prototype.replace:

api/server/index.js:239-242 api/server/experimental.js:421-424

The only sanitisation is " → ". That escaping is applied before the string is handed to replace() as the replacement, and the JavaScript engine then expands $-substitution patterns in the replacement after the escaping ran. Supplying $& re-inserts the literal matched text lang="en-US" — double quotes included — reintroducing the exact characters the sanitiser was meant to remove, without the attacker's payload ever containing a quote. $` likewise expands (it injects the text preceding the match, i.e. <!doctype html>).

From LibreChat-AI/LibreChat's security advisory. Shortened; the full text is there.

Affected software

SoftwareAffected versions
LibreChatServers and applications · github:librechat-ai/librechat
  • Every version before 0.8.8

About LibreChat

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

From its GitHub repository.
Docker Hub pulls
669,094Docker Hub, 15 Nov 2026
GitHub stars
47,138GitHub, 15 Nov 2026
Forks
9,706GitHub, 15 Nov 2026
License
MITGitHub
First published on GitHub
12 Feb 2023GitHub

References