Prevent terminal symlink traversal via recursive grep
This commit is contained in:
@@ -256,7 +256,9 @@ def validate_arguments(program: str, arguments: list[str], cwd: Path) -> list[st
|
||||
return ["-n", args[1], *[path_argument(value, cwd) for value in args[2:]]]
|
||||
|
||||
if program == "grep":
|
||||
allowed = {"-c", "-E", "-F", "-i", "-l", "-n", "-r", "-R"}
|
||||
# GNU grep -R follows symlinks. Only -r is permitted because it skips
|
||||
# directory symlinks and therefore preserves the visible-root boundary.
|
||||
allowed = {"-c", "-E", "-F", "-i", "-l", "-n", "-r"}
|
||||
result = []
|
||||
index = 0
|
||||
while index < len(args) and args[index].startswith("-"):
|
||||
|
||||
Reference in New Issue
Block a user