T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/LrcApi/api/source.py:65- Finding
Unauthenticated Arbitrary Local File Disclosure
- Content
View full analysis
', endpoint='file_viewer_endpoint') @v1_bp.route('/file/', endpoint='file_viewer_endpoint') @require_auth_decorator(permission='r') def file_viewer(filename): ALLOWED_EXTENSIONS = ('.mp3', '.flac', '.wav', '.ape', '.ogg', '.m4a', '.aac', '.wma', '.mp4', '.m4p', '.m4b', 'txt', 'lrc', 'webp', 'jpg', 'jpeg', 'png', 'bmp', 'gif', 'webp', 'svg', 'ico', 'mp4', 'webm', 'mkv', 'avi', 'mov', 'wmv', 'flv', 'f4v', 'f4p', 'f4a', 'f4b', 'm4v', 'm4r', 'm4p', 'm4b',) if filename.lower().endswith(ALLOWED_EXTENSIONS): try: return send_from_directory(os.path.dirname(filename), os.path.basename(filename)) except FileNotFoundError: abort(404) ``` The relevant authentication behavior is: ```python if not args("auth"): if permission == 'r': return 1 ``` The default configuration sets authentication to an empty value: ```python DEFAULT_DATA = { "server": { "ip": "*", "port": 28883 }, "auth": "", ``` ### Technical Analysis The route accepts a complete filesystem path from the URL and splits it into an attacker-controlled directory and basename. `send_from_directory()` prevents traversal outside the directory supplied to it, but that protection is ineffective because the directory itself is attacker-controlled. The extension check is not a safe authorization boundary. It permits numerous extensions, including `txt`, `lrc`, images, video, and audio formats. It also omits leading periods from several entries, ...[truncated 1307 chars]- Remediation
View remediation
