Skip to content

Commit 87508ae

Browse files
committed
add \r and \f as dangerous shell characters
this is in case the command == the user input
1 parent d68ead2 commit 87508ae

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

aikido_zen/vulnerabilities/shell_injection/contains_shell_syntax.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
"\n",
3131
"\t",
3232
"~",
33+
"\r",
34+
"\f",
3335
]
3436

3537
commands = [

aikido_zen/vulnerabilities/shell_injection/detect_shell_injection_test.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,35 @@ def test_it_flags_comma_in_loop():
394394
done""",
395395
"for (( i=0, j=10; i<j; i++, j-- ))",
396396
)
397+
398+
399+
def test_carriage_return_in_user_input_is_flagged():
400+
is_shell_injection("ls \rrm", "\rrm")
401+
is_shell_injection("ls \rrm -rf", "\rrm -rf")
402+
403+
404+
def test_form_feed_in_user_input_is_flagged():
405+
is_shell_injection("ls \frm", "\frm")
406+
is_shell_injection("ls \frm -rf", "\frm -rf")
407+
408+
409+
def test_carriage_return_in_user_input_is_flagged_when_userinput_is_command():
410+
is_shell_injection("sleep\r10", "sleep\r10")
411+
is_shell_injection("shutdown\r-h\rnow", "shutdown\r-h\rnow")
412+
413+
414+
def test_form_feed_in_user_input_is_flagged_when_userinput_is_command():
415+
is_shell_injection("sleep\f10", "sleep\f10")
416+
is_shell_injection("shutdown\f-h\fnow", "shutdown\f-h\fnow")
417+
418+
419+
def test_carriage_return_as_separator_between_commands():
420+
is_shell_injection("ls\rrm", "rm")
421+
is_shell_injection("echo test\rrm -rf /", "rm")
422+
is_shell_injection("rm\rls", "rm")
423+
424+
425+
def test_form_feed_as_separator_between_commands():
426+
is_shell_injection("ls\frm", "rm")
427+
is_shell_injection("echo test\frm -rf /", "rm")
428+
is_shell_injection("rm\fls", "rm")

0 commit comments

Comments
 (0)