| |
| * @name Check for CWE-22 in codeql-eg-TarSlip |
| * @description |
| * @kind problem |
| * @problem.severity warning |
| * @id custom-cpp/cwe-22-codeql-eg-TarSlip |
| */ |
|
|
| import python |
| import semmle.python.dataflow.new.DataFlow |
| import semmle.python.dataflow.new.TaintTracking |
|
|
| from DataFlow::CfgNode src, CallNode call, |
| DataFlow::CfgNode sink |
|
|
| where |
| |
| src.asCfgNode() = Value::named("tarfile.open").getACall() |
| and |
|
|
| |
| (sink.asCfgNode() = call.getFunction().(AttrNode).getObject("extractall") |
| or |
| sink.asCfgNode() = call.getFunction().(AttrNode).getObject("extract") ) |
|
|
| |
| |
| and |
| TaintTracking::localTaint( src , sink ) |
|
|
| |
| and |
| not exists (If if_stmt| |
| if_stmt.getASubStatement().contains( call.getNode() ) |
| ) |
|
|
| select call, "cwe-22: "+call.toString()+ " at line "+ call.getLocation().getStartLine()+ |
| " is a tar extraction call that is unchecked" |
| |