Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* `rsync` has been added to the list of commands which may evaluate its parameters as a shell command.
6 changes: 4 additions & 2 deletions go/ql/lib/semmle/go/frameworks/SystemCommandExecutors.qll
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ private class ShellOrSudoExecution extends SystemCommandExecution::Range, DataFl

override DataFlow::Node getCommandName() { result = this.getAnArgument() }

override predicate doubleDashIsSanitizing() { shellCommand.getStringValue().matches("%git") }
override predicate doubleDashIsSanitizing() {
shellCommand.getStringValue().matches("%" + ["git", "rsync"])
}
}

private class SystemCommandExecutors extends SystemCommandExecution::Range, DataFlow::CallNode {
Expand Down Expand Up @@ -126,7 +128,7 @@ private string getASudoCommand() {
"fakeroot", "fakeroot-sysv", "su", "fakeroot-tcp", "fstab-decode", "jrunscript", "nohup",
"parallel", "find", "pkexec", "sg", "sem", "runcon", "sudoedit", "runuser", "stdbuf",
"system", "timeout", "xargs", "time", "awk", "gawk", "mawk", "nawk", "doas", "git", "access",
"vsys", "userv", "sus", "super"
"vsys", "userv", "sus", "super", "rsync"
]
}

Expand Down
12 changes: 12 additions & 0 deletions go/ql/test/query-tests/Security/CWE-078/ArgumentInjection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import (
"net/http"
"os/exec"
)

func handler2(req *http.Request) {
path := req.URL.Query()["path"][0]
cmd := exec.Command("rsync", path, "/tmp")
cmd.Run()
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
edges
| ArgumentInjection.go:9:10:9:16 | selection of URL : pointer type | ArgumentInjection.go:10:31:10:34 | path |
| CommandInjection.go:9:13:9:19 | selection of URL : pointer type | CommandInjection.go:10:22:10:28 | cmdName |
| GitSubcommands.go:10:13:10:19 | selection of URL : pointer type | GitSubcommands.go:12:31:12:37 | tainted |
| GitSubcommands.go:10:13:10:19 | selection of URL : pointer type | GitSubcommands.go:13:31:13:37 | tainted |
Expand All @@ -25,6 +26,8 @@ edges
| SanitizingDoubleDash.go:105:15:105:37 | slice literal [array] : string | SanitizingDoubleDash.go:106:24:106:31 | arrayLit |
| SanitizingDoubleDash.go:105:30:105:36 | tainted : string | SanitizingDoubleDash.go:105:15:105:37 | slice literal [array] : string |
nodes
| ArgumentInjection.go:9:10:9:16 | selection of URL : pointer type | semmle.label | selection of URL : pointer type |
| ArgumentInjection.go:10:31:10:34 | path | semmle.label | path |
| CommandInjection.go:9:13:9:19 | selection of URL : pointer type | semmle.label | selection of URL : pointer type |
| CommandInjection.go:10:22:10:28 | cmdName | semmle.label | cmdName |
| GitSubcommands.go:10:13:10:19 | selection of URL : pointer type | semmle.label | selection of URL : pointer type |
Expand Down Expand Up @@ -55,6 +58,7 @@ nodes
| SanitizingDoubleDash.go:152:24:152:30 | tainted | semmle.label | tainted |
subpaths
#select
| ArgumentInjection.go:10:31:10:34 | path | ArgumentInjection.go:9:10:9:16 | selection of URL : pointer type | ArgumentInjection.go:10:31:10:34 | path | This command depends on a $@. | ArgumentInjection.go:9:10:9:16 | selection of URL | user-provided value |
| CommandInjection.go:10:22:10:28 | cmdName | CommandInjection.go:9:13:9:19 | selection of URL : pointer type | CommandInjection.go:10:22:10:28 | cmdName | This command depends on a $@. | CommandInjection.go:9:13:9:19 | selection of URL | user-provided value |
| GitSubcommands.go:12:31:12:37 | tainted | GitSubcommands.go:10:13:10:19 | selection of URL : pointer type | GitSubcommands.go:12:31:12:37 | tainted | This command depends on a $@. | GitSubcommands.go:10:13:10:19 | selection of URL | user-provided value |
| GitSubcommands.go:13:31:13:37 | tainted | GitSubcommands.go:10:13:10:19 | selection of URL : pointer type | GitSubcommands.go:13:31:13:37 | tainted | This command depends on a $@. | GitSubcommands.go:10:13:10:19 | selection of URL | user-provided value |
Expand Down