Skip to content

fix(playlist): sanitize playlist names to prevent path traversal via '/'#1004

Open
berettavexee wants to merge 1 commit into
nathom:devfrom
berettavexee:fix/playlist-path-traversal
Open

fix(playlist): sanitize playlist names to prevent path traversal via '/'#1004
berettavexee wants to merge 1 commit into
nathom:devfrom
berettavexee:fix/playlist-path-traversal

Conversation

@berettavexee

@berettavexee berettavexee commented Jun 19, 2026

Copy link
Copy Markdown

Summary

  • Playlist names containing / were passed directly to clean_filepath(), which preserves slashes as path separators, causing unintended subdirectory creation and potential path traversal outside the download root.
  • Apply clean_filename() before clean_filepath() in both PendingPlaylist.resolve() and PendingLastfmPlaylist.resolve() to replace / with -.

Root cause

clean_filename() replaces / with - before sanitizing. clean_filepath() calls sanitize_filepath() which intentionally preserves / as a path separator (needed for multi-level folder templates). Playlist folder names are single components and must go through clean_filename() first.

Albums were already safe: AlbumMetadata.format_folder_path() passes albumartist and title through clean_filename() before template expansion.

Test plan

  • Download a playlist whose name contains / (e.g. Best of 80s/90s) — confirm it creates a single folder named Best of 80s-90s instead of nested Best of 80s/90s/
  • Download a last.fm playlist — same check
  • Existing test suite passes (pytest)

🤖 Generated with Claude Code

Playlist names containing '/' were passed directly to clean_filepath(),
which preserves slashes as path separators, creating unintended
subdirectories. Apply clean_filename() first to replace '/' with '-'.

Affects PendingPlaylist.resolve() and PendingLastfmPlaylist.resolve().
Albums were already safe: format_folder_path() passes albumartist and
title through clean_filename() before template expansion.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant