This repository has been archived by the owner on Oct 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial SQL injection for springframework
- Loading branch information
Niko
committed
Apr 12, 2021
1 parent
5362d06
commit e29736e
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.joern.scanners.java; | ||
|
||
import io.joern.scanners._ | ||
import io.shiftleft.semanticcpg.language._ | ||
import io.shiftleft.console._ | ||
import io.shiftleft.macros.QueryMacros._ | ||
import io.shiftleft.dataflowengineoss.language._ | ||
import io.shiftleft.dataflowengineoss.queryengine.EngineContext | ||
|
||
// The queries are tied to springframework | ||
object SQLInjection extends QueryBundle { | ||
|
||
implicit val resolver: ICallResolver = NoResolve | ||
|
||
@q | ||
def sqlInjection()(implicit context: EngineContext): Query = | ||
Query.make( | ||
name = "SQL injection", | ||
author = Crew.niko, | ||
title = | ||
"SQL injection: A parameter is used in an insecure database API call.", | ||
description = | ||
""" | ||
|An attacker controlled parameter is used in an insecure database API call. | ||
| | ||
|If the parameter is not validated and sanitized, this is a SQL injection. | ||
|""".stripMargin, | ||
score = 5, | ||
withStrRep({ cpg => | ||
def source = | ||
cpg.method | ||
.where(_.methodReturn.evalType( | ||
"org.springframework.web.servlet.ModelAndView")) | ||
.parameter | ||
|
||
def sinks = cpg.method.name("query").parameter.order(1) | ||
|
||
// sinks where the first argument is reachable by a source | ||
sinks.reachableBy(source).l | ||
}), | ||
tags = List(QueryTags.sqli, QueryTags.sqlInjection) | ||
) | ||
} |