fix(mdx-loader): replace image-size with measureImage hook - #12388
fix(mdx-loader): replace image-size with measureImage hook#12388kennym wants to merge 2 commits into
Conversation
image-size is archived and carries unpatched DoS CVEs. Measure SVG locally and raster formats via image-dimensions, with an optional markdown.hooks.measureImage escape hatch.
|
Hi @kennym! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@slorber @Josh-Cena any feedback here? |
|
+1 |
|
@slorber @Josh-Cena sorry for following up again, but what is the hold up? It's been 5 business days without a word. We have a security SLA and this issue currently drags it down. |
|
bump |
…urity PRs The two remaining Dependabot alerts are both image-size 2.0.2, pulled in by @docusaurus/mdx-loader. Neither has a patched version and neither ever will: 2.0.2 is the last release (April 2025) and the upstream repository was archived in June 2026, a week before the advisories were published. The Docusaurus pull request that replaces the dependency (facebook/docusaurus#12388) is still open, and the only alternative on npm is a one-month-old fork with a single unknown maintainer, which is a worse trade for code that runs in CI. So the honest fix is a written mitigation rather than a version bump. site's Readme now records where image-size runs (mdx-loader's transformImage remark plugin, at build time only), why the two infinite-loop bugs are unreachable here (the only images measured are the PNG/JPEG/SVG files committed to this repository, and none of ICNS, JXL or HEIF is among them), what the worst case actually is (a hung `npm run build`, triggered by someone who can already push to the repository) and the three changes that would make it exploitable. Dependabot: the site entry now also groups security updates. `groups` applies to version updates only unless `applies-to: security-updates` is set, which is why a single Docusaurus advisory chain arrived as five separate pull requests. Nothing in site/ is published to npm, so one grouped PR is the right unit of review for it. The root, examples and github-actions entries are untouched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
@slorber @Josh-Cena friendly bump |
I'm sorry but this is how OSS works 🤷♂️
Even if I merged this today, this is not really the plan for release in v3.x as a patch release. The image-size vulnerabilities are only theoretical DoS vulnerabilities, not really impactful. You can safely ignore them. We don't particularly want to release a breaking change in v3 for a vulnerability that is reported by broken security tooling (https://overreacted.io/npm-audit-broken-by-design/) and that nobody encounters in practice. If you really care about a fix for a theoretical thing, it remains possible to ship it on your own and make it available for the community:
Edit: an alternative to alias already exists. Not vetted; use this carefully. The maintainer has only ever published this package, so you must be cautious and check what's actually distributed (not just on GitHub, the actual code that runs) |
Pre-flight checklist
Motivation
@docusaurus/mdx-loaderdepends on archivedimage-size@^2.0.2(CVE-2025-71329 / CVE-2025-71330). There is no published patched release.#12235 replaced it with
image-dimensionsonly. That drops SVG (unsupported by that library) and has no escape hatch for long-tail formats.This draft follows the
markdown.hookspattern from #11283:siteConfig.markdown.hooks.measureImage({ imagePath }).width/height/viewBoxparser; raster viaimage-dimensions; on failure log and returnnull(no throw/catch).image-sizecompletely.Question for maintainers: is preserving SVG enough for a 3.x
fix, or is dropping the long-tail formats v4-only?Test Plan
pnpm exec vitest run packages/docusaurus-mdx-loader/src/remark/transformImage packages/docusaurus/src/server/__tests__/configValidation.test.ts(Node 24)measureImageoverride, config validationuser.test.tsandadmin/scripts/resizeImage.jsno longer importimage-sizeTest links
Deploy preview: https://deploy-preview-12388--docusaurus-2.netlify.app/
Docs:
website/docs/api/docusaurus.config.js.mdx(markdown.hooks.measureImage)Related issues/PRs
siteConfig.markdown.hooks, deprecatesiteConfig.onBrokenMarkdownLinks#11283