# GHSA-3v33-3wmw-3785: yt-dlp has dependency on potentially malicious third-party code in Douyu extractors

> Attackers could execute malicious code via a compromised CDN fallback in Douyu extractors if PhantomJS is installed and primary CDN fails.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 8 Jul 2024

## What is GHSA-3v33-3wmw-3785?

GHSA-3v33-3wmw-3785 is a vulnerability in yt-dlp, published on 8 Jul 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

### Impact
yt-dlp's DouyuTV and DouyuShow extractors used a `cdn.bootcdn.net` URL as a fallback for fetching a component of the crypto-js JavaScript library. When the Douyu extractor is used, yt-dlp extracts this JavaScript code and attempts to execute it externally using [PhantomJS](https://github.com/ariya/phantomjs). `bootcdn.net` is owned by the bad actor responsible for the [Polyfill JS supply chain attack](https://sansec.io/research/polyfill-supply-chain-attack) that has been ongoing since at least June 2023. While there is no evidence that PhantomJS has been targeted by or is vulnerable to any attacks carried out by the Polyfill JS actor, there is the possibility that malicious JavaScript code may have been downloaded/cached by yt-dlp or executed by PhantomJS.

In order for this potential vulnerability to be exploited by any hypothetical attack, all 3 of the following conditions must be met:
1. The user has PhantomJS installed on their system.
2. The user passes a `douyu.com` or `douyutv.com` URL to yt-dlp as input, or passes a URL that redirects to one of these domains.
3. `cdnjs.cloudflare.com` is unavailable or blocked at the time of extraction, necessitating the usage of the `cdn.bootcdn.net` fallback; or it had been unavailable during a previous run of the Douyu extractor and JavaScript code from `cdn.bootcdn.net` had been cached to disk.

### Patches
yt-dlp version 2024.07.07 fixes this issue by removing the URL pointing to the malicious CDN and by invalidating any Douyu extractor cache data created by unpatched versions of yt-dlp.

### Workarounds
It is recommended to upgrade yt-dlp to version 2024.07.07 as soon as possible.

For users not able to upgrade:
- Avoid using the Douyu extractors (`--ies default,-douyutv,-douyushow`)
- Uninstall (or do not install) PhantomJS

### Acknowledgement
Thanks to @LeSuisse for [reporting this](https://github.com/yt-dlp/yt-dlp/pull/10347) promptly after `bootcdn.net` was discovered to be under control of the same bad actor behind the `polyfill.io` supply chain attack.

### References
- https://github.com/yt-dlp/yt-dlp/commit/6075a029dba70a89675ae1250e7cdfd91f0eba41
- https://sansec.io/research/polyfill-supply-chain-attack

## Which versions are affected by GHSA-3v33-3wmw-3785?

2 open source packages ship an affected version, including yt-dlp.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `yt-dlp` | PyPI | From 2023.09.24 | 2024.07.07 |
| `yt-dlp` | PyPI | From 2023.09.24 | 2024.07.07 |

## How do I fix GHSA-3v33-3wmw-3785?

Upgrade yt-dlp to 2024.07.07 or later.

## Is GHSA-3v33-3wmw-3785 being exploited?

There is no known exploitation of GHSA-3v33-3wmw-3785 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-3v33-3wmw-3785 and fix it if it is affected.

What it is: GHSA-3v33-3wmw-3785 is a vulnerability in yt-dlp, published on 8 Jul 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-3v33-3wmw-3785 in the wild and no public exploit code.

Affected packages and fixed versions:
- yt-dlp (PyPI): affected from 2023.09.24; fixed in 2024.07.07
- yt-dlp (PyPI): affected from 2023.09.24; fixed in 2024.07.07

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-3v33-3wmw-3785/ (Markdown: https://insights.sbomify.com/GHSA-3v33-3wmw-3785/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-3v33-3wmw-3785

---
From sbomify Insights: https://insights.sbomify.com/GHSA-3v33-3wmw-3785/
Summaries are generated and may contain mistakes; the official description above is the record.
