Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Validate proposed file extensions #32830

Merged
merged 3 commits into from
Jul 2, 2024

Conversation

dirkf
Copy link
Contributor

@dirkf dirkf commented Jul 2, 2024

Boilerplate: yt-dlp/own code, fix ## Please follow the guide below
  • You will be asked some questions, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])
  • Use Preview tab to see how your pull request will actually look like

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • I am the original author of this code and I am willing to release it under Unlicense, except for code from yt-dlp for which this or the below has already been asserted
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

This PR adds validation of file extensions processed by yt-dl

  1. against a white-list of expected extensions (unpublicised --no-check-extensions disables this, CLI only)
  2. to exclude path separators in a site-supplied extension that could enable path traversal under vulnerable OSes (Windows, eg).

The PR is derived from https://github.com/yt-dlp/yt-dlp-ghsa-79w7-vh3h-8g4j/pull/1.

Thanks:

@dirkf dirkf changed the title Ghsa 79w7 vh3h 8g4j [core] Validate proposed file extensions Jul 2, 2024
@dirkf dirkf merged commit 37cea84 into ytdl-org:master Jul 2, 2024
14 checks passed
@dirkf dirkf deleted the ghsa-79w7-vh3h-8g4j branch July 2, 2024 14:39
@eyaler
Copy link

eyaler commented Jul 5, 2024

@dirkf saving a video file without an extension is a practice which may be used for having a format-agnostic filename. this change breaks multiple scripts with this behavior. please consider reverting the behavior to allow no extension

@dirkf
Copy link
Contributor Author

dirkf commented Jul 5, 2024

Please open a support issue showing an example with verbose log and explaining what you think should happen instead.

Possible work-arounds for CLI:

  • use --exec ... to rename away an unwanted extension
  • use --no-check-extensions

For API, try similar approaches to that in e15101c (__init__.py) or the equivalent in yt-dlp (_UnsafeExtensionError.sanitize_extension = lambda x, **kw: x).

dirkf added a commit to dirkf/youtube-dl that referenced this pull request Jul 7, 2024
github-actions bot added a commit to hellopony/youtube-dl that referenced this pull request Jul 8, 2024
* https://github.com/ytdl-org/youtube-dl:
  [core] Fix PR ytdl-org#32830 for fixed extensionless output template
  [YandexMusic] Save track version in the title field
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.

2 participants