🛡️ Sentinel: [HIGH] Fix path traversal via symbolic links#773
🛡️ Sentinel: [HIGH] Fix path traversal via symbolic links#773
Conversation
Updated path validation functions (`resolve_workspace_path`, `ensure_within_root`) to use `os.path.realpath` instead of `os.path.abspath`. This ensures that malicious symlinks pointing outside the designated workspace or root directories are correctly identified and blocked. Also added tests to explicitly cover symlink traversal scenarios. Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Updated path validation functions (`resolve_workspace_path`, `ensure_within_root`) to use `os.path.realpath` instead of `os.path.abspath`. This ensures that malicious symlinks pointing outside the designated workspace or root directories are correctly identified and blocked. Also fixed CI errors related to abstract methods in serp_providers by implementing `search_raw` in ApifyProvider and DataForSEOProvider. Also added tests to explicitly cover symlink traversal scenarios. Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
Updated path validation functions (`resolve_workspace_path`, `ensure_within_root`) to use `os.path.realpath` instead of `os.path.abspath`. This ensures that malicious symlinks pointing outside the designated workspace or root directories are correctly identified and blocked. Also fixed CI errors related to abstract methods in serp_providers by implementing `search_raw` in ApifyProvider and DataForSEOProvider. Also added tests to explicitly cover symlink traversal scenarios. Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
Updated path validation functions (`resolve_workspace_path`, `ensure_within_root`) to use `os.path.realpath` instead of `os.path.abspath`. This ensures that malicious symlinks pointing outside the designated workspace or root directories are correctly identified and blocked. Also fixed CI errors related to abstract methods in serp_providers by implementing `search_raw` in ApifyProvider and DataForSEOProvider. Also added tests to explicitly cover symlink traversal scenarios. Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
🚨 Severity: HIGH
💡 Vulnerability: Symbolic Link Traversal (Path Traversal variant). Previously, path validation methods like
resolve_workspace_pathandensure_within_rootrelied onos.path.abspath. This meant that if a malicious user or process created a symlink within the workspace that pointed to a sensitive system directory (e.g.,/etc), subsequent access via that symlink would be permitted, effectively bypassing the directory restriction.🎯 Impact: An attacker could read, download, or write files to unauthorized locations outside the user's intended workspace or root directory by traversing symbolic links.
🔧 Fix: Replaced
os.path.abspathwithos.path.realpathinsrc/nodetool/io/path_utils.py,src/nodetool/api/file.py, andsrc/nodetool/api/workspace.py.realpathfully resolves all symbolic links before the bounds check, guaranteeing the ultimate destination file resides within the permitted directory. Added a corresponding unit test to verify this behaviour.✅ Verification: Ensure tests pass via
pytest tests/common/test_path_utils.py tests/api/test_file_api.py tests/api/test_workspace_api.py.PR created automatically by Jules for task 15674737945818819123 started by @georgi