enkilee opened a new issue, #2625: URL: https://github.com/apache/rocketmq-dashboard/issues/2625
Problem
DashboardController 接收用户可控的 date 参数,未做任何校验直接拼接到文件路径,导致路径遍历:攻击者可传入 ../../xxx
读取数据目录之外的任意 .json 文件。
Evidence
调用链中 date 全程无校验:
DashboardController.broker(@RequestParam String date) //
用户输入,无校验
→ DashboardServiceImpl.queryBrokerData(date) // 透传
→ DashboardCollectServiceImpl.getBrokerCache(date)
new File(dataLocationPath + date + ".json") // ←
直接拼接,无校验
Fix
在路径构造的边界(DashboardCollectServiceImpl,所有调用方的必经点)增加白名单校验:
•新增 DATE_PATTERN = \d{4}-\d{2}-\d{2}(与项目文档约定的 yyyy-MM-dd 格式一致)
•新增 checkDateParam():date 为 null/空或格式不匹配时抛 ServiceException(-1, ...)(由现有
GlobalExceptionHandler 统一转为 JSON 错误响应)
•getBrokerCache() 和 getTopicCache() 入口各调用一次。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
