Skip to content

Commit 752e550

Browse files
Merge pull request #268 from AikidoSec/fix-different-separators-in-command-injection
Adds more shell separators for injection check
2 parents 5248486 + 57d155f commit 752e550

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

agent_api/src/main/java/dev/aikido/agent_api/vulnerabilities/shell_injection/ShellSyntaxChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
public final class ShellSyntaxChecker {
1111
private ShellSyntaxChecker() {}
1212
private static final List<String> SEPARATORS = Arrays.asList(
13-
" ", "\t", "\n", ";", "&", "|", "(", ")", "<", ">"
13+
" ", "\t", "\n", ";", "&", "|", "(", ")", "<", ">", "\r", "\f"
1414
);
1515

1616
public static boolean containsShellSyntax(String command, String userInput) {

agent_api/src/test/java/vulnerabilities/shell_injection/ShellInjectionDetectorTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,18 @@ void testItFlagsCommaInLoop() {
434434
"for (( i=0, j=10; i<j; i++, j-- ))"
435435
);
436436
}
437+
438+
@Test
439+
void testCarriageReturnAsSeparator() {
440+
// \r (carriage return) as separator before dangerous command
441+
assertIsShellInjection("ls\rrm", "rm");
442+
assertIsShellInjection("echo test\rrm -rf /", "rm");
443+
}
444+
445+
@Test
446+
void testFormFeedAsSeparator() {
447+
// \f (form feed) as separator before dangerous command
448+
assertIsShellInjection("ls\frm", "rm");
449+
assertIsShellInjection("echo test\frm -rf /", "rm");
450+
}
437451
}

0 commit comments

Comments
 (0)