mirror of
https://github.com/storytold/artcraft-services.git
synced 2026-11-19 08:53:03 +01:00
## What was wrong The support-tool's `kinovi_web generate_video` command caches media in `/tmp/media_files` by default, and `artcraft_client::download_media_file` writes downloads into it. - Another local user could pre-create that shared directory and plant entries. `fs::File::create` follows a planted symlink, so a download could create or truncate any file the operator can write. - `find_cached_file` followed symlinks when picking up cached files, so a planted link could make the operator read, and upload, a private file. - In directory mode the filename came from the media token unchanged, so a token containing `/` or `..` could write outside the directory. ## What changed - The default cache is now `~/.cache/storyteller-support-tool/media_files`, created with mode 0700. Any cache directory (default or `--download_path`) must be a real directory with no group/other permission bits, or the command stops with a `chmod 700` hint. An owner-only directory belonging to someone else is unreadable to us, so this rules out foreign-controlled caches without a uid lookup. - Cached entries are inspected with `symlink_metadata` and must be regular files. - `download_media_file` removes any existing destination entry (a symlink is removed, not followed) and creates the file with `create_new`. The token and extension in derived filenames are limited to `[A-Za-z0-9_-]`. ## Checks - Run: `cargo test -p artcraft_client download_media_file` (4 passed, incl. a traversal-token case); `cargo test -p support-tool download_dir_tests` (1 passed: 0700 accepted, 0777 and a symlinked dir rejected).