Polyfill.io is no longer considered safe and should be removed

Created on 6 March 2024, 11 months ago
Updated 15 July 2024, 7 months ago

Problem/Motivation

Pollyfill.io has been sold to a chinese company and has reportedly started modifying the files that are sent back. The library is now considered unsafe and is usually not needed in modern browsers.

Proposed resolution

Remove External IntersectionObserver polyfill from leaflet.libraries.yml and replace with another solution. There is reason to believe there is an extreme threat and the original builders of pollyfill.io have warned to immediately remove the library.

https://twitter.com/triblondon/status/1761852117579427975

📌 Task
Status

Fixed

Version

10.2

Component

Code

Created by

🇦🇫Afghanistan drupalam

Live updates comments and jobs are added and updated live.
  • Security

    It is used for security vulnerabilities which do not need a security advisory. For example, security issues in projects which do not have security advisory coverage, or forward-porting a change already disclosed in a security advisory. See Drupal’s security advisory policy for details. Be careful publicly disclosing security vulnerabilities! Use the “Report a security vulnerability” link in the project page’s sidebar. See how to report a security issue for details.

Sign in to follow issues

Comments & Activities

  • Issue created by @drupalam
  • Status changed to Fixed 11 months ago
  • 🇮🇹Italy itamair

    Latest Leaflet 10.2.12 release indeed (already) fixed this security issue,
    changing the reference to the Polyfill.io library by pointing to the https://polyfill-fastly.io/ domain
    as discussed and suggested here: https://security.drupal.org/node/180274

    Please also look the related Advisory for this Leaflet security issue: https://security.drupal.org/node/180276

  • 🇦🇫Afghanistan drupalam

    I can still see it being used in version 10.2.12

    https://git.drupalcode.org/project/leaflet/-/blob/10.2.x/leaflet.librari...

    # External IntersectionObserver polyfill
    intersection_observer:
    remote: https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver

  • 🇩🇰Denmark ressa Copenhagen

    It does look like there's still a link left to polyfill.io.

    @itamair. Thanks for the links to the security issue, but I get this message:

    Access denied

    You are not authorized to access this page.

    • itamair committed bf23620c on 10.2.x
      Further/final ref adjustment on Fix Leaflet security on Polyfill.io...
  • 🇮🇹Italy itamair

    Thanks @ressa ... your contribution is always super valuable and pertinent.
    I fixed your lates remark in the lates commit, that will be part of the next Leaflet 10.2.x release.

    Here under is the description of the security issue and correspondent workaround suggested here: https://security.drupal.org/node/180274

    This module has a potentially malicious 3rd party JS vulnerability.

    You can see this vulnerability by:
    1. Enabling the module
    2. polyfill.min.js is included via the polyfill.io domain.

    "As of February 24, 2024, cdn.polyfill.io, the domain hosting the polyfill.io JavaScript library, has been acquired by a Chinese company named Funnull. Polyfill.io is a widely used JavaScript library integrated into many of the world's most well known web applications. All polyfill.io traffic is now pointing to the Baishan Cloud CDN (https://www.baishancloud.com/)."

    https://polykill.io/
    https://github.com/polyfillpolyfill/polyfill-service/issues/2834

    Both Fastly and CloudFlare have provided temporary fixes for this issue
    https://blog.cloudflare.com/polyfill-io-now-available-on-cdnjs-reduce-yo...
    https://polyfill-fastly.io/

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • 🇺🇸United States greggles Denver, Colorado, USA

    Comment #3 links to https://security.drupal.org/node/180276 which was a private issue (that will remain private) where there was discussion and it was agreed this could be handled in public.

  • 🇬🇧United Kingdom mcdruid 🇬🇧🇪🇺
  • 🇩🇰Denmark ressa Copenhagen

    Thanks Drupal security team for looking into this, and @itamair for removing this third-party library. For now polyfill-fastly.io looks safe, but what happens if Fastly is bought up and closed, goes bankrupt, or something else ... and the domain is squatted in two years time, just like polyfill.io was?

    Currently on the "Policy on 3rd party assets on Drupal.org > Third party libraries" page it says:

    Having third party libraries that are hosted elsewhere on the Internet in the Drupal.org repo is strongly discouraged. Instead, if the library in question is available under GPLv2+, or has a “GPL-friendly” license (see note below), you may use one of the methods described on the community documentation page titled “ Including 3rd party libraries ”.

    From https://www.drupal.org/node/422996#libraries

    As I see it, it could make it simpler for module maintainers like @itamair, if it wasn't strongly discouraged to include a small library such as the Polyfill library (200 kB) in the Leaflet module ... This would reduce the risk, with little downside.

  • 🇬🇧United Kingdom mcdruid 🇬🇧🇪🇺

    Yeah it's a balance, and I don't think there's a clear "right answer" at present.

    Putting a static copy of the library in the module mitigates supply chain risk, but on the other hand if/when a vulnerability is found and fixed in the (upstream) library... we then need to find all copies of it everywhere and update them (or backport the fix).

    Which problem is worse?

    Referencing dependencies with tools like composer (and perhaps npm in the future?) has the advantage that it makes automated auditing easier (dependabot etc..) and potentially sites can update themselves without relying on Drupal projects doing new releases (that's subject to appropriate constraints being in place, and everyone's interpretation of semver agreeing etc.. etc..)

  • 🇩🇰Denmark ressa Copenhagen

    I agree, it's a balancing act -- but the wording is very much in favor of using third-parties:

    Having third party libraries that are hosted elsewhere on the Internet in the Drupal.org repo is strongly discouraged.

    This wording could be relaxed a bit, to something like this:

    Third party libraries hosted elsewhere on the Internet can be included in the Drupal.org repo, though it's not recommended.

    I also agree with this:

    Putting a static copy of the library in the module mitigates supply chain risk, but on the other hand if/when a vulnerability is found and fixed in the (upstream) library... we then need to find all copies of it everywhere and update them (or backport the fix).

    It might not be an option, due to licensing, or some other structural blocker I am not aware of -- but the Drupal community could make a handful of Composer packages for the most popular JavaScript libraries, so that a module maintainer could require drupal/javascript-polyfill and always get the latest, safest version. NPM is an option, though I do prefer Composer if it's possible, since that's already used by everyone and well known. I am sure this has been discussed at length in other issues :-)

  • 🇳🇱Netherlands lmeurs

    Probably good to mention, polyfill.js only seems to get loaded when using Lazy Loading (map_lazy_load), see https://git.drupalcode.org/search?search=intersection_observer&nav_sourc....

  • 🇮🇹Italy itamair

    Hi folks @here!

    According to the all above discussion and worth inputs, and to the fact that the IntersectionObserver polyfill library is only loaded in case of Leaflet Lazy Loading, and effectively used in case of very old Browsers (that natively don't support the IntersectionObserver API),
    I decided to local embed the remote/External IntersectionObserver polyfill library into the Leaflet module,
    so to avoid any future security and reliability issue related to Polyfill.io js library.

    The new just deployed leaflet 10.2.19 release is indeed embedding the remote/External IntersectionObserver polyfill library into the Leaflet module itself.

    Hopeful and confident that this makes a lot of sense (and improves/fixes module security issues on all of this)
    Please feel free to open a new follow-up issue for any new issues related to any of this ...

  • 🇩🇰Denmark ressa Copenhagen

    Thanks @itamair, including the IntersectionObserver polyfill library in the Leaflet module seems like the pragmatic solution in this case, for the reasons you outline.

  • 🇦🇺Australia oceanic Melbourne, Victoria

    I have Leaflet 10.2.19 installed, and I know the IntersectionObserver polyfill JS file is now locally included, but I'm still seeing a link to this remote repo:

    # Local IntersectionObserver polyfill
    intersection_observer:
      remote: https://github.com/polyfillpolyfill/polyfill-service/blob/main/polyfill-libraries/3.110.1/IntersectionObserver/raw.js
      version: 3.110.1
      license:
        name: MIT License
        url: https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
        gpl-compatible: true
      js:
        'js/polyfill/polifillIntersectionObserver.js': { minified: true }

    ... github.com/polyfillpolyfill/polyfill-service which is flagged byGitHub as:

    "This repository contains malicious content that may cause technical harms. We have decided to preserve this content for security research purposes. Please exercise CAUTION when clicking links, downloading releases, or otherwise interacting with this repository."

    So, should that be removed from the module too?

  • 🇮🇹Italy itamair

    Ok ... totally done (and kind of fed-up) with this polyfill.io library drama,
    I deployed a new Leaflet 10.2.20 version that
    removes injection of polyfill/IntersectionObserver js library all the way
    , for backward support to very old browsers
    and adds IntersectionObserver Browser Compatibility check disclaimer in the View and Formatter settings (https://git.drupalcode.org/project/leaflet/-/commit/a6d53ccc14c8a7500aeb...)

    because:

    Issue (double) closed!

  • 🇩🇰Denmark ressa Copenhagen

    It always feels good to clean up, and get rid of old stuff, which is probably not needed anyway. So something good came out of this in the end. Thanks @itamair.

Production build 0.71.5 2024