
CVE-2026-30691: Stored Cross-Site Scripting (XSS) in @cyntler/react-doc-viewer
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
[Suggested description]
Cross-Site Scripting (XSS) vulnerability in @cyntler/react-doc-viewer v1.17.1 allows remote attackers to execute arbitrary JavaScript via a crafted .txt file. The TXTRenderer component fails to sanitize file content and explicitly casts raw data as a ReactNode.
[Additional Information]
"The TXTRenderer is used by default for any text-based files. Since the library is widely used in React applications to preview user-uploaded content, this vulnerability poses a significant risk for applications that do not strictly validate file contents before passing them to the viewer."
[Vulnerability Type] Cross Site Scripting (XSS)
[Vendor of Product] cyntler
[Affected Product Code Base] @cyntler/react-doc-viewer - 1.17.1
[Affected Component] src/renderers/txt/index.tsx
[Attack Type] Remote
[Impact Code execution] true
[Impact Information Disclosure] true
[Attack Vectors]
"An attacker must provide a specially crafted .txt file containing malicious HTML or JavaScript code. When the victim opens this file using the DocViewer component, the script executes in their browser."
[Reference] https://github.com/cyntler/react-doc-viewer/issues/317
[Discoverer] Walid Riouah
Use CVE-2026-30691.
-----BEGIN PGP SIGNATURE-----
-----END PGP SIGNATURE-----
存储型跨站脚本 (XSS) 漏洞已在 @cyntler/react-doc-viewer 包 (v1.17.1) 中被发现。该漏洞存在于 TXTRenderer 组件中,该组件通过将 .txt 文件的原始文件内容显式转换为 ReactNode 进行渲染,而未经任何事先的清理或实体转义。
在 src/renderers/txt/index.tsx 中:
{currentDocument?.fileData as ReactNode}
要复现该漏洞,创建一个名为 exploit.txt 的文件,包含以下显式脚本载荷,并将其加载到文档查看器组件中:
<h1 style="color: red;">Vulnerable!</h1>
<script>alert('XSS_SUCCESS'); document.body.style.background='red';</script>
<img src=x onerror="console.log('XSS_Executed_Successfully')">
攻击者可以在受害者浏览器上下文中执行任意 JavaScript。这可能导致:
在渲染之前,使用像 DOMPurify 这样的 HTML 清理库来清理动态文本输入,或者避免将原始字符串输入不安全地转换为 ReactNode 对象:
import DOMPurify from 'dompurify';
const sanitizedHTML = DOMPurify.sanitize(currentDocument?.fileData);
return <div dangerouslySetInnerHTML={{ __html: sanitizedHTML }} />;
公告由 Walid Riouah(网络安全研究员与红队成员)整理