You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Replace unmaintained dependency image-size with active CVEs (CVSS 7.5) #12231
I image there will be an alternative fork out there somewhere, or another util that could be used.
Reproducible demo
No response
Steps to reproduce
$ yarn why image-size
yarn why v1.22.22
[1/4] 🤔 Why do we have the module "image-size"...?
[2/4] 🚚 Initialising dependency graph...
[3/4] 🔍 Finding dependency...
[4/4] 🚡 Calculating file sizes...
=> Found "image-size@2.0.2"
info Reasons this module exists
- "@docusaurus#core#@docusaurus#mdx-loader" depends on it
- Hoisted from "@docusaurus#core#@docusaurus#mdx-loader#image-size"
info Disk size without dependencies: "748KB"
info Disk size with unique dependencies: "748KB"
info Disk size with transitive dependencies: "748KB"
info Number of shared dependencies: 0
Expected behavior
Less CVEs in my pipelines ;(
Actual behavior
2 CVEs in my pipeline :(
Your environment
Self-service
I'd be willing to fix this bug myself.
Reacted by Eugene, Maksim Cherkasov, Vladyslav-Chychykalo, Richard Hagen, Olav Rønnestad Birkeland, Alexander Corradini, Mike Cantrell, David Keller, Paul Hawxby, Mati Kepa and 4 more
I'm happy to work on this. Can it be assigned to me?
The plan is to replace image-size with a maintained, lightweight dimension reader as well as doing proper regression tests
Hi @Oliver-ke, I saw your comment and wanted to let you know that I have already implemented this fix in PR #12235.
I’ve replaced image-size with image-dimensions, updated the loader logic to use a secure buffer-based approach, and verified it with the project's test suite. Since the fix is already submitted and passing checks, you might want to save your time for other issues—but please feel free to take a look at the PR if you're interested in the implementation!
Although I understand it's annoying to get CVE warnings, these are usually harmless for us because a DoS due to a malicious image can only affect the build, not your live website. And you are normally in control of all image inputs, so you can only DoS yourself by adding a malicious image to your Git repo. If an attacker has access to your Git repo, you have more important problems to solve in the first place.
I'm ok to consider swapping the image-size lib. However, other libs such as image-dimensions behave differently, so this will be a breaking change, and the impact of this swap must be analyzed first and minimized for our community.
If you are not ready to do this analysis and provide a non-disruptive rollout plan, don't submit a vide-coded PR, because the majority of the work is not the code swap itself, but the impact analysis and rollout plan.
If the impact is important, and it could annoy users, a possible solution would be to do the swap the default lib, and expose a siteConfig.markdown.hooks.measureImage() hook. Users could still fall back to the former image-size lib if they really need to.
for anyone looking, i did edit pnpm-workspace.yaml by adding:
overrides:
image-size: 'npm:image-size-next@^2.1.1'
This likely works, but I would be extremely cautious for a few reasons:
The npm user is not a widely known maintainer, and has ever published a single package, the one you recommend using.
The GitHub user of the fork has opened hundreds of issues suggesting this alternative package, probably using automation and IA.
Hackers are getting increasingly cleaver to compromise JS developers. If I were one, this is the strategy I would use: take over an unmaintained package, ask thousands of developers to install it with an unpinned version, make it look legit, then release a compromised version.
TLDR: to solve a theoretical vulnerability, you may introduce a much bigger supply chain security issue.
My recommendation:
At the minimum, pin the dependency to an exact version so that you don't get a malicious update.
Check the code on npm for that version before downloading it. Or make it pass through a security scanner (Socket doesn't report anything for image-size-next@2.1.1)
Eventually, create your own fork of image-size, and release it under your organization's npm account. You may eventually cherry-pick the code from image-size-next if it's good and solve the problems.
Reacted by Karl Horky, Tobias Wild, Fares Azzabi, Anders Swanson, Fabián Heredia Montiel and Oliver Franzen
Activity
Oliver-ke commentedon Jul 7, 2026
I'm happy to work on this. Can it be assigned to me?
The plan is to replace image-size with a maintained, lightweight dimension reader as well as doing proper regression tests
1012ayush commentedon Jul 7, 2026
Hi @Oliver-ke, I saw your comment and wanted to let you know that I have already implemented this fix in PR #12235.
I’ve replaced image-size with image-dimensions, updated the loader logic to use a secure buffer-based approach, and verified it with the project's test suite. Since the fix is already submitted and passing checks, you might want to save your time for other issues—but please feel free to take a look at the PR if you're interested in the implementation!
slorber commentedon Jul 9, 2026
Although I understand it's annoying to get CVE warnings, these are usually harmless for us because a DoS due to a malicious image can only affect the build, not your live website. And you are normally in control of all image inputs, so you can only DoS yourself by adding a malicious image to your Git repo. If an attacker has access to your Git repo, you have more important problems to solve in the first place.
It's similar to ReDoS CVEs: those do not really affect us compared to projects with a server runtime.
See also: https://overreacted.io/npm-audit-broken-by-design/
I'm ok to consider swapping the image-size lib. However, other libs such as
image-dimensionsbehave differently, so this will be a breaking change, and the impact of this swap must be analyzed first and minimized for our community.If you are not ready to do this analysis and provide a non-disruptive rollout plan, don't submit a vide-coded PR, because the majority of the work is not the code swap itself, but the impact analysis and rollout plan.
If the impact is important, and it could annoy users, a possible solution would be to do the swap the default lib, and expose a
siteConfig.markdown.hooks.measureImage()hook. Users could still fall back to the formerimage-sizelib if they really need to.tats-u commentedon Aug 12, 2026
For pnpm users:
6543 commentedon Aug 17, 2026
for anyone looking, i did edit
pnpm-workspace.yamlby adding:kennym commentedon Aug 25, 2026
Working plan, as an alternative to #12235: draft PR #12388.
#12235 swapped
image-sizeforimage-dimensions. That is the wrong shape:image-dimensionshas no SVG support. Markdown SVGs would lose width/height. That is the real user-facing break.throwvsundefined).Proposed design (same hook pattern as #11283):
siteConfig.markdown.hooks.measureImage({ imagePath }) => {width?, height?} | null.width/height/viewBoxparser; raster viaimage-dimensions; on failure log and returnnull(no throw/catch).image-sizecompletely.Draft implementation: #12388
Question: is preserving SVG enough for a 3.x
fix, or is dropping the long-tail formats v4-only?ci: restore the npm audit gate around the unpatchable image-size advi…
kennym commentedon Aug 27, 2026
@slorber wdyt? #12231 (comment)
MithunMck commentedon Sep 1, 2026
Is this fixed ?
kennym commentedon Sep 1, 2026
not yet, but I have proposed a fix. Pending review
MithunMck commentedon Sep 1, 2026
Till then, can we use the resolution for image-next . Something like this.
"image-size": "npm:image-size-next@2.1.0"fix(deps): bump qs, fast-uri, nanoid and js-yaml to resolve Dependabo…
chore(deps): ignore abandoned image-size advisories (#41)
slorber commentedon Sep 7, 2026
This likely works, but I would be extremely cautious for a few reasons:
The npm user is not a widely known maintainer, and has ever published a single package, the one you recommend using.
The GitHub user of the fork has opened hundreds of issues suggesting this alternative package, probably using automation and IA.
TLDR: to solve a theoretical vulnerability, you may introduce a much bigger supply chain security issue.
My recommendation:
image-size, and release it under your organization's npm account. You may eventually cherry-pick the code fromimage-size-nextif it's good and solve the problems.Fix security vulnerabilities across all install roots
slorber commentedon Sep 18, 2026
Upgrade your dependencies.
2.0.4 should contain the security patch and our Docusaurus v3 semver range allows that version.
website: drop image-size-next fork, use upstream image-size 2.0.4
aonamrata commentedon Sep 28, 2026
Thank you!!! Is there a released version for it? https://www.npmjs.com/package/@docusaurus/core > 3.10.2 • Public • Published 3 months ago
is not the new one 🤔
slorber commentedon Sep 29, 2026
There is not need for any release, the semver range we use allow the upgrade (
^2.0.2allows2.0.4)