π‘οΈ Sentinel: [CRITICAL] Fix path traversal in file retrieval API#69
π‘οΈ Sentinel: [CRITICAL] Fix path traversal in file retrieval API#69thirdeyenation wants to merge 1 commit intomainfrom
Conversation
Resolved an arbitrary file read vulnerability where `/api_files_get` improperly constructed absolute paths from client-provided paths without boundary checks. Ensured the final absolute path stays inside the application base directory `base_dir + os.sep`. Added `sentinel.md` journal entry. Co-authored-by: thirdeyenation <133812267+thirdeyenation@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. |
π¨ Severity: CRITICAL
π‘ Vulnerability:
The
api/api_files_get.pyendpoint processed client-providedpathsto retrieve files. If a path didn't explicitly match internal prefixes (/a0/), it was considered an external path. The application fetched it directly without verifying that the resolved absolute path resided within the intended application root directory. This allowed attackers to use path traversal techniques (../../../../etc/passwd) or absolute paths (/etc/passwd) to read arbitrary files off the server host file system.π― Impact:
An unauthenticated or minimally authenticated attacker could arbitrarily read any file on the system that the application has read permissions for, leading to the exposure of highly sensitive files like configurations, system files, environment variables, or private SSH keys.
π§ Fix:
Added a robust containment check validating that
os.path.abspath(external_path)string-starts withos.path.abspath(files.get_base_dir())+os.sep. If an attempt fails this check, it raises a warning and skips the file without crashing, securely bounding all subsequent accesses to within the intended bounds.β Verification:
An internal test script successfully proved that the original implementation would allow traversal strings or root absolute paths to bypass restrictions, while the patched version safely triggers a "Path traversal attempt blocked" warning and rejects the illegal access.
PR created automatically by Jules for task 10233127162581519055 started by @thirdeyenation