Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ predicate isMybatisXmlOrAnnotationSqlInjection(
.matches("${" + annotation.getValue("value").(CompileTimeConstantExpr).getStringValue() +
"%}") and
annotation.getType() instanceof TypeParam and
ma.getAnArgument() = node.asExpr()
ma.getAnArgument() = node.asExpr() and
annotation.getTarget() = ma.getMethod().getParameter(node.asExpr().(Argument).getParameterPos())
)
or
// MyBatis default parameter sql injection vulnerabilities.the default parameter form of the method is arg[0...n] or param[1...n].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
edges
| MybatisSqlInjection.java:62:19:62:43 | name : String | MybatisSqlInjection.java:63:35:63:38 | name : String |
| MybatisSqlInjection.java:63:35:63:38 | name : String | MybatisSqlInjectionService.java:48:19:48:29 | name : String |
| MybatisSqlInjection.java:94:21:94:45 | name : String | MybatisSqlInjection.java:95:37:95:40 | name : String |
| MybatisSqlInjection.java:95:37:95:40 | name : String | MybatisSqlInjectionService.java:76:21:76:31 | name : String |
| MybatisSqlInjection.java:99:21:99:44 | age : String | MybatisSqlInjection.java:100:37:100:39 | age : String |
| MybatisSqlInjection.java:100:37:100:39 | age : String | MybatisSqlInjectionService.java:80:21:80:30 | age : String |
| MybatisSqlInjectionService.java:48:19:48:29 | name : String | MybatisSqlInjectionService.java:50:23:50:26 | name : String |
| MybatisSqlInjectionService.java:50:3:50:9 | hashMap [post update] [<map.value>] : String | MybatisSqlInjectionService.java:51:27:51:33 | hashMap |
| MybatisSqlInjectionService.java:50:23:50:26 | name : String | MybatisSqlInjectionService.java:50:3:50:9 | hashMap [post update] [<map.value>] : String |
| MybatisSqlInjectionService.java:76:21:76:31 | name : String | MybatisSqlInjectionService.java:77:29:77:32 | name |
| MybatisSqlInjectionService.java:80:21:80:30 | age : String | MybatisSqlInjectionService.java:81:29:81:31 | age |
nodes
| MybatisSqlInjection.java:62:19:62:43 | name : String | semmle.label | name : String |
| MybatisSqlInjection.java:63:35:63:38 | name : String | semmle.label | name : String |
| MybatisSqlInjection.java:94:21:94:45 | name : String | semmle.label | name : String |
| MybatisSqlInjection.java:95:37:95:40 | name : String | semmle.label | name : String |
| MybatisSqlInjection.java:99:21:99:44 | age : String | semmle.label | age : String |
| MybatisSqlInjection.java:100:37:100:39 | age : String | semmle.label | age : String |
| MybatisSqlInjectionService.java:48:19:48:29 | name : String | semmle.label | name : String |
| MybatisSqlInjectionService.java:50:3:50:9 | hashMap [post update] [<map.value>] : String | semmle.label | hashMap [post update] [<map.value>] : String |
| MybatisSqlInjectionService.java:50:23:50:26 | name : String | semmle.label | name : String |
| MybatisSqlInjectionService.java:51:27:51:33 | hashMap | semmle.label | hashMap |
| MybatisSqlInjectionService.java:76:21:76:31 | name : String | semmle.label | name : String |
| MybatisSqlInjectionService.java:77:29:77:32 | name | semmle.label | name |
| MybatisSqlInjectionService.java:80:21:80:30 | age : String | semmle.label | age : String |
| MybatisSqlInjectionService.java:81:29:81:31 | age | semmle.label | age |
subpaths
#select
| MybatisSqlInjectionService.java:51:27:51:33 | hashMap | MybatisSqlInjection.java:62:19:62:43 | name : String | MybatisSqlInjectionService.java:51:27:51:33 | hashMap | MyBatis annotation SQL injection might include code from $@ to $@. | MybatisSqlInjection.java:62:19:62:43 | name | this user input | SqlInjectionMapper.java:33:2:33:54 | Select | this SQL operation |
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public String badSelect(@RequestParam String name) {
public void badDelete(@RequestParam String name) {
mybatisSqlInjectionService.badDelete(name);
}

@GetMapping(value = "badUpdate")
public void badUpdate(@RequestParam String name) {
mybatisSqlInjectionService.badUpdate(name);
Expand All @@ -89,4 +89,14 @@ public void badUpdate(@RequestParam String name) {
public void badInsert(@RequestParam String name) {
mybatisSqlInjectionService.badInsert(name);
}

@GetMapping(value = "good2")
public void good2(@RequestParam String name, @RequestParam Integer age) {
mybatisSqlInjectionService.good2(name, age);
}

@GetMapping(value = "good3")
public void good3(@RequestParam String age) {
mybatisSqlInjectionService.good3(age);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,12 @@ public void badUpdate(String input) {
public void badInsert(String input) {
sqlInjectionMapper.badInsert(input);
}

public void good2(String name, Integer age){
sqlInjectionMapper.good2(name, age);
}

public void good3(String age){
sqlInjectionMapper.good3(age);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,33 @@ public interface SqlInjectionMapper {

//using providers
@SelectProvider(
type = MyBatisProvider.class,
method = "badSelect"
type = MyBatisProvider.class,
method = "badSelect"
)
String badSelect(String input);

@DeleteProvider(
type = MyBatisProvider.class,
method = "badDelete"
type = MyBatisProvider.class,
method = "badDelete"
)
void badDelete(String input);

@UpdateProvider(
type = MyBatisProvider.class,
method = "badUpdate"
type = MyBatisProvider.class,
method = "badUpdate"
)
void badUpdate(String input);

@InsertProvider(
type = MyBatisProvider.class,
method = "badInsert"
type = MyBatisProvider.class,
method = "badInsert"
)
void badInsert(String input);

@Select("select * from user_info where name = #{name} and age = ${age}")
String good2(@Param("name") String name, Integer age);

@Select("select * from user_info where age = #{age}")
String good3(@Param("age") String age);

}