首先我們了解下這個(gè)漏洞是什么?
MyBatis-Plus TenantPlugin 是 MyBatis-Plus 的一個(gè)為多租戶場(chǎng)景而設(shè)計(jì)的插件,可以在 SQL 中自動(dòng)添加租戶 ID 來實(shí)現(xiàn)數(shù)據(jù)隔離功能。
MyBatis-Plus TenantPlugin 3.5.3.1及之前版本由于 TenantHandler#getTenantId 方法在構(gòu)造 SQL 表達(dá)式時(shí)默認(rèn)情況下未對(duì) tenant(租戶)的 ID 值進(jìn)行過濾,當(dāng)程序啟用了 TenantPlugin 并且 tenant(租戶)ID 可由外部用戶控制時(shí),攻擊者可利用該漏洞進(jìn)行 sql 注入,接管程序的數(shù)據(jù)庫或向操作系統(tǒng)發(fā)送惡意命令。用戶可通過對(duì)租戶 ID 進(jìn)行過濾緩解此漏洞。
影響版本 <3.5.1
解決辦法
1.不啟用tenantId
2.必須使用tenantId的話,加過濾器,對(duì)tenantId做處理
Test Version: 3.4.2
com.example.demo.config.MybatisPlusConfig
?
?文章來源地址http://www.zghlxwxcb.cn/news/detail-733224.html
com.example.demo.common.TenantHolder
?
?
Interface for testing:?/user?tid=
?will returns a specified tenant data record.
com.example.demo.controller.HelloController
?
?
db:
CREATE TABLE `users` (
`id` int(32) NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
`tenant_id` varchar(64) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
Test interface using blank parameters:
http://localhost:8080/user?tid=
?
?
Use?' or 1=1 and '123'='123
?to perform sql injection and get all the data?
文章來源:http://www.zghlxwxcb.cn/news/detail-733224.html
?
到了這里,關(guān)于MybatisPlus存在 sql 注入漏洞(CVE-2023-25330)解決辦法的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!