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
Expand Up @@ -10,7 +10,7 @@
public final class ShellSyntaxChecker {
private ShellSyntaxChecker() {}
private static final List<String> SEPARATORS = Arrays.asList(
" ", "\t", "\n", ";", "&", "|", "(", ")", "<", ">"
" ", "\t", "\n", ";", "&", "|", "(", ")", "<", ">", "\r", "\f"
);

public static boolean containsShellSyntax(String command, String userInput) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,18 @@ void testItFlagsCommaInLoop() {
"for (( i=0, j=10; i<j; i++, j-- ))"
);
}

@Test
void testCarriageReturnAsSeparator() {
// \r (carriage return) as separator before dangerous command
assertIsShellInjection("ls\rrm", "rm");
assertIsShellInjection("echo test\rrm -rf /", "rm");
}

@Test
void testFormFeedAsSeparator() {
// \f (form feed) as separator before dangerous command
assertIsShellInjection("ls\frm", "rm");
assertIsShellInjection("echo test\frm -rf /", "rm");
}
}