Skip to content

Add System.shell command injection #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions lib/sobelow/ci/system.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Sobelow.CI.System do
@moduledoc """
# Command Injection in `System.cmd`
# Command Injection via `System`

This submodule of the `CI` module checks for Command Injection
vulnerabilities through usage of the `System.cmd` function.
Expand All @@ -12,7 +12,7 @@ defmodule Sobelow.CI.System do
$ mix sobelow -i CI.System
"""
@uid 2
@finding_type "CI.System: Command Injection in `System.cmd`"
@finding_type "CI.System: Command Injection via `System` function"

use Sobelow.Finding

Expand All @@ -22,9 +22,17 @@ defmodule Sobelow.CI.System do
Finding.init(@finding_type, meta_file.filename, confidence)
|> Finding.multi_from_def(fun, parse_def(fun))
|> Enum.each(&Print.add_finding(&1))

Finding.init(@finding_type, meta_file.filename, confidence)
|> Finding.multi_from_def(fun, parse_def_shell(fun))
|> Enum.each(&Print.add_finding(&1))
end

def parse_def(fun) do
Parse.get_fun_vars_and_meta(fun, 0, :cmd, [:System])
end

def parse_def_shell(fun) do
Parse.get_fun_vars_and_meta(fun, 0, :shell, [:System])
end
end