Merge pull request #5606 from erik-krogh/shellInput

Approved by esbena
This commit is contained in:
CodeQL CI
2021-04-07 14:30:31 +01:00
committed by GitHub
3 changed files with 41 additions and 0 deletions

View File

@@ -190,6 +190,27 @@ module UnsafeShellCommandConstruction {
override DataFlow::Node getAlertLocation() { result = this }
}
/**
* A joined path (`path.{resolve/join}(..)`) that is later executed as a shell command.
* Joining a path is similar to string concatenation that automatically inserts slashes.
*/
class JoinedPathEndingInCommandExecutionSink extends Sink {
DataFlow::MethodCallNode joinCall;
SystemCommandExecution sys;
JoinedPathEndingInCommandExecutionSink() {
this = joinCall.getAnArgument() and
joinCall = DataFlow::moduleMember("path", ["resolve", "join"]).getACall() and
joinCall = isExecutedAsShellCommand(DataFlow::TypeBackTracker::end(), sys)
}
override string getSinkType() { result = "Path concatenation" }
override SystemCommandExecution getCommandExecution() { result = sys }
override DataFlow::Node getAlertLocation() { result = this }
}
/**
* A sanitizer like: "'"+name.replace(/'/g,"'\\''")+"'"
* Which sanitizes on Unix.