Skip to content

Commit 99c8b29

Browse files
committed
add sink
1 parent b873285 commit 99c8b29

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

java/ql/src/experimental/Security/CWE/CWE-089/MyBatisMapperXmlSqlInjectionLib.qll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,22 @@ predicate isSqlInjection(DataFlow::Node node, XMLElement xmle) {
103103
xmle.getTextValue().trim().matches("%${%") and
104104
mc.getArgument(i) = node.asExpr()
105105
)
106+
or
107+
// MyBatis Mapper method string type sql injection vulnerabilities.
108+
// e.g. MyBatis Mapper method: `void test(String name);` and MyBatis Mapper XML file:`select id,name from test where name like '%${value}%'`
109+
exists(MyBatisMapperSqlOperation mbmxe, MyBatisMapperSql mbms, MethodAccess mc |
110+
mbmxe.getMapperMethod() = mc.getMethod()
111+
|
112+
(
113+
mbmxe.getAChild*() = xmle
114+
or
115+
mbmxe.getInclude().getRefid() = mbms.getId() and
116+
mbms.getAChild*() = xmle
117+
) and
118+
mc.getMethod().getAParamType() instanceof TypeString and
119+
mc.getMethod().getNumberOfParameters() = 1 and
120+
not mc.getMethod().getAParameter().hasAnnotation() and
121+
xmle.getTextValue().trim().matches("%${%") and
122+
mc.getAnArgument() = node.asExpr()
123+
)
106124
}

0 commit comments

Comments
 (0)