Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

Potential fix for code scanning alert no. 636: URL redirection from remote source (#7760)

sriram veeraghanta8d354b3eb2cd
diff --git a/apps/api/plane/utils/path_validator.py b/apps/api/plane/utils/path_validator.py
index ba81e9cabf..aad28239fe 100644
--- a/apps/api/plane/utils/path_validator.py
+++ b/apps/api/plane/utils/path_validator.py
@@ -3,18 +3,20 @@ from urllib.parse import urlparse
def validate_next_path(next_path: str) -> str:
- """Validates that next_path is a valid path and extracts only the path component."""
+ """Validates that next_path is a safe relative path for redirection."""
+ # Browsers interpret backslashes as forward slashes. Remove all backslashes.
+ next_path = next_path.replace("\\", "")
parsed_url = urlparse(next_path)
- # Ensure next_path is not an absolute URL
+ # Block absolute URLs or anything with scheme/netloc
if parsed_url.scheme or parsed_url.netloc:
next_path = parsed_url.path # Extract only the path component
- # Ensure it starts with a forward slash (indicating a valid relative path)
- if not next_path.startswith("/"):
+ # Must start with a forward slash and not be empty
+ if not next_path or not next_path.startswith("/"):
return ""
- # Ensure it does not contain dangerous path traversal sequences
+ # Prevent path traversal
if ".." in next_path:
return ""