Skip to content

Replace unmaintained dependency image-size with active CVEs (CVSS 7.5) #12231

Closed

Description

@rainecheck

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

MDX Loader pulls in image-size. This dependency is now archived, see https://github.com/image-size/image-size#tired-maintainer-doesnt-want-your-slop

Two active CVES: CVE-2025-71329, CVE-2025-71330
CVE CWE: 835

See https://joshua.hu/image-size-infinite-loop-dos-vulnerabilities for practical info.

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.

Activity

  1. added
    bug
    status: needs triage
    on Jul 7, 2026
  2. Oliver-ke commented on Jul 7, 2026

    @Oliver-ke

    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

  3. 1012ayush commented on Jul 7, 2026

    @1012ayush

    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!

  4. slorber commented on Jul 9, 2026

    @slorber
    Collaborator

    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-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.

  5. tats-u commented on Aug 12, 2026

    @tats-u
    Contributor

    For pnpm users:

    audit:
      ignore:
        - GHSA-w3rx-r6r6-pgpr # image-size is abandoned and published built pages themselves won't be affected
        - GHSA-5p2g-fcmc-qvqq # ditto
    
  6. 6543 commented on Aug 17, 2026

    @6543
    Contributor

    for anyone looking, i did edit pnpm-workspace.yaml by adding:

     overrides:
    +  image-size: 'npm:image-size-next@^2.1.1'
    
  7. kennym commented on Aug 25, 2026

    @kennym

    Working plan, as an alternative to #12235: draft PR #12388.

    #12235 swapped image-size for image-dimensions. That is the wrong shape:

    • image-dimensions has no SVG support. Markdown SVGs would lose width/height. That is the real user-facing break.
    • Error handling differs (throw vs undefined).
    • No escape hatch for formats the new default will not cover.

    Proposed design (same hook pattern as #11283):

    • Add optional siteConfig.markdown.hooks.measureImage({ imagePath }) => {width?, height?} | null.
    • Default: SVG via a small local width/height/viewBox parser; raster via image-dimensions; on failure log and return null (no throw/catch).
    • Remove image-size completely.
    • Document that BMP/ICO/TIFF/PSD/JXL/ICNS are no longer auto-measured unless the site provides a custom hook.

    Draft implementation: #12388

    Question: is preserving SVG enough for a 3.x fix, or is dropping the long-tail formats v4-only?

  8. kennym commented on Aug 27, 2026

    @kennym
  9. MithunMck commented on Sep 1, 2026

    @MithunMck

    Is this fixed ?

  10. kennym commented on Sep 1, 2026

    @kennym

    Is this fixed ?

    not yet, but I have proposed a fix. Pending review

  11. MithunMck commented on Sep 1, 2026

    @MithunMck

    Is this fixed ?

    not yet, but I have proposed a fix. Pending review

    Till then, can we use the resolution for image-next . Something like this. "image-size": "npm:image-size-next@2.1.0"

  12. slorber commented on Sep 7, 2026

    @slorber
    Collaborator

    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.

    Image
    • 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.
  13. removed
    status: needs triage
    on Sep 18, 2026
  14. slorber commented on Sep 18, 2026

    @slorber
    Collaborator

    Upgrade your dependencies.

    2.0.4 should contain the security patch and our Docusaurus v3 semver range allows that version.

  15. aonamrata commented on Sep 28, 2026

    @aonamrata

    Upgrade your dependencies.

    2.0.4 should contain the security patch and our Docusaurus v3 semver range allows that version.

    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 🤔

  16. slorber commented on Sep 29, 2026

    @slorber
    Collaborator

    There is not need for any release, the semver range we use allow the upgrade (^2.0.2 allows 2.0.4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions