Skip to content

fix(security): restrict youtube-audio to YouTube hostnames - #16

Merged
carochacs merged 1 commit into
mainfrom
claude/next-issues-jt1j4f
Aug 18, 2026
Merged

fix(security): restrict youtube-audio to YouTube hostnames#16
carochacs merged 1 commit into
mainfrom
claude/next-issues-jt1j4f

Conversation

@carochacs

Copy link
Copy Markdown
Collaborator

The route handed a caller-supplied URL straight to yt_dlp, which falls
back to its generic extractor for anything it doesn't recognize — that
extractor can fetch essentially any web page server-side, an SSRF shape
with no scheme/host restriction. The UI only ever offers "paste a
YouTube URL" (screen.html), so add _is_youtube_url() and reject any
request whose scheme isn't http/https or whose host isn't a real
youtube.com/youtu.be hostname with 400, before yt_dlp ever sees the URL.

Closes #14.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

The route handed a caller-supplied URL straight to yt_dlp, which falls
back to its generic extractor for anything it doesn't recognize — that
extractor can fetch essentially any web page server-side, an SSRF shape
with no scheme/host restriction. The UI only ever offers "paste a
YouTube URL" (screen.html), so add _is_youtube_url() and reject any
request whose scheme isn't http/https or whose host isn't a real
youtube.com/youtu.be hostname with 400, before yt_dlp ever sees the URL.

Closes #14.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Kh8gR75zYwFUT3crRoEbH
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 57f1908b-a499-4d1a-a3ae-7ff57fd1a0bf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This PR fixes an SSRF vulnerability in the youtube-audio endpoint (issue #14). The route previously passed caller-supplied URLs to yt_dlp without validation, allowing yt_dlp's generic extractor to fetch arbitrary pages server-side.

  • SSRF guard (_is_youtube_url) — Adds a whitelist-based hostname validator at routes.py:1047-1066 using urlparse. Checks scheme (http/https) and hostname against a frozenset of known YouTube hostnames. Pure string validation, no network access.
  • Route guard — Applies _is_youtube_url as an early-return in the youtube_audio handler at routes.py:6757-6758, returning 400 before yt_dlp ever sees the URL.
  • Comprehensive tests — New tests/test_youtube_audio_url.py (74 lines) covers valid YouTube URLs, non-YouTube hosts (including 169.254.169.254 cloud metadata), lookalike domains, userinfo confusion (youtube.com@evil.example), non-HTTP schemes, and malformed input.
  • Version bump and changelogplugin.json bumped to 1.8.3, security entry added to CHANGELOG.md.

Pullfrog  | View workflow run | Using Big Pickle (free) | 𝕏

@carochacs
carochacs merged commit 5645102 into main Aug 18, 2026
5 checks passed
@carochacs
carochacs deleted the claude/next-issues-jt1j4f branch August 18, 2026 11:54
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.

[Security][Medium] youtube-audio route is SSRF-shaped (arbitrary URL fetched server-side)

2 participants