Fix path traversal issue detection, the alias folder also needs to end with / for path traversal to happen

This commit is contained in:
Alexandre Aubin 2019-03-20 20:32:30 +01:00 committed by Alexandre Aubin
parent acc32c9796
commit 16bb33b884

View file

@ -196,7 +196,7 @@ class App():
for line in locationblock[1]:
instruction = line[0]
if instruction == "alias":
yield location
yield (location, line)
elif isinstance(instruction, list) and instruction and instruction[0] == "location":
yield from find_location_with_alias(instruction)
else:
@ -205,8 +205,9 @@ class App():
def find_path_traversal_issue(nginxconf):
for block in nginxconf:
for location in find_location_with_alias(block):
if not location.endswith("/"):
for location, alias in find_location_with_alias(block):
alias_path = alias[-1]
if not location.endswith("/") and alias_path.endswith("/"):
yield location
for location in find_path_traversal_issue(nginxconf):