Описание
New API has Potential XSS in its MarkdownRenderer component
Summary
A potential unsafe operation occurs in component MarkdownRenderer.jsx, allowing for Cross-Site Scripting(XSS) when the model outputs items containing <script> tag.
Details
Line 212-231 of MarkdownRenderer.jsx is unsafe, it use dangerouslySetInnerHTML to preview html the model generates. This can trigger malcious scripts.
PoC
A simple way to exploit that is to ask the model in the playground, with prompt: "请帮我写个脚本,跳转到google", and then the browser will navigate to the google.com without user interference.
Impact
Potential malcious activity to the user using playground, if the model api is altered to output unintended codes.
Also, users may not be easily rid the exploit, since the record of the chat containing XSS script is stored, once opening the page later, the script will be re-triggered.
Potential Workaround
The preview may be placed in an iframe sandbox, dangerous html strings should be purified before rendering.
The reply generated for test is as below:
这是一个为您编写的单页 HTML 文件。它使用了两种方式来实现跳转,以确保在任何情况下都能工作:
- JavaScript (
window.location.replace):这是最常用且高效的方法,它会立即跳转,并且不会保留当前页面在浏览器历史记录中(这样用户按“后退”键不会回到这个跳转页)。 - HTML Meta Refresh:作为后备方案。如果用户的浏览器禁用了 JavaScript,这个标签会在 1 秒后将用户带往 Google。
- 手动链接:页面中显示了一个备用链接,以防自动跳转被拦截或失效。
您可以直接保存以下代码为 .html 文件并在浏览器中打开。
Acknowledgments
QuantumNous would like to thank TechnologyStar for the early notification of this potential vulnerability via AI-assisted tools, and small-lovely-cat for providing additional context and an initial patch. The final fix was developed and verified by the maintainers to ensure full compatibility with the project's architecture.
Пакеты
github.com/QuantumNous/new-api
< 0.10.8-alpha.9
0.10.8-alpha.9
Связанные уязвимости
New API is a large language mode (LLM) gateway and artificial intelligence (AI) asset management system. Prior to version 0.10.8-alpha.9, a potential unsafe operation occurs in component `MarkdownRenderer.jsx`, allowing for Cross-Site Scripting(XSS) when the model outputs items containing `<script>` tag. Version 0.10.8-alpha.9 fixes the issue.
Уязвимость компонента MarkdownRenderer.jsx системы управления большими языковыми моделями (LLM) New API, позволяющая нарушителю проводить атаки межсайтового скриптинга