back to article If you're using Polyfill.io code on your site – like 100,000+ are – remove it immediately

The polyfill.io domain is being used to infect more than 100,000 websites with malicious code after what's said to be a Chinese organization bought the domain earlier this year, researchers have said. Multiple security firms sounded the alarm on Tuesday, warning organizations whose websites use any JavaScript code from the …

  1. tinpinion

    Integrity

    Firefox 43 and Chrome 45 started supporting this thing called Subresource Integrity back in 2015 (Edge and Safari joined the party in 2018). Basically, use a specially-formatted hash in the 'integrity' attribute of the 'script' HTML tag. It allows scripts coming from third-party CDNs to be ignored if they're modified.

    While I've just learned about it today myself, I can only hope that folks who do this for a living have a bit more of an ear to the ground for such revolutionary advances in security technologies as these.

    1. claimed Silver badge

      Re: Integrity

      This is what I come to El Reg for. Thank you, this is a fab tip!

    2. Brewster's Angle Grinder Silver badge

      I've just had a look at polyfill.io: and they only offer links to the major version. So the link given for version 3.111.0 is <site>/v3/polyfill.min.js So they could legitimately patch the script, without notifying you, and the url wouldn't change but the hash would now be different. Your site would instantly break without notification. (Or not, because these days it's only Safari being fused to iOS that causes compatibility problems.)

      SRI is really for protecting one's own scripts from being mangled by someone at the hosting end when hosted on a third party server. You can apply them to third party scripts on a CDN, but you've got have a fixed link to the exact version, and be confident it won't be tweaked behind your back - breaking the hash.

      1. Phil O'Sophical Silver badge

        So they could legitimately patch the script, without notifying you, and the url wouldn't change but the hash would now be different.

        Isn't that the whole idea? The script was changed and so is not the one that you (presumably) tested your site with, so you no longer pull in the changed script, for security.

        Whether it was "legitimately" patched or not is irrelevant, since you cannot know if the change was legitimate or not. It's a change and therefore a security risk until you've tested it and accepted the new version. If you can't keep up with testing changes, then download a known safe version & host it yourself.

      2. tinpinion

        I'd point out that a CDN could also legitimately patch the script with a version which isn't API-compatible and my site would also instantly break without notification. (Or it would become buggy for no discernible reason.)

        The literature around SRI, such as Frederik Braun's (a co-editor of the draft) "A CDN that can not XSS you: Using Subresource Integrity" strongly suggests that untrustworthy CDNs are the target of the technology rather than untrustworthy web hosting companies. I don't disagree that it could be useful in ensuring that one's own code hasn't been altered. I find it strange to think that a hosting company wouldn't have access to both the document and its first-party resources, but I'm practically a lay-person when it comes to paying others to host content.

        I'd personally rather face a broken website than allow one to be taken over by a supply chain attack, and that applies doubly when I'm the user of a site rather than someone involved in running it. I would consider it unconscionable for a bank's website to be using a third-party CDN for script dependencies without using this technology, for instance.

        1. CowHorseFrog Silver badge

          Exactly which means you shouldnt use 3rd party hosted anything.

    3. Sora2566 Silver badge

      Re: Integrity

      The entire point of Polyfill.io was that it would only serve up the polyfills that you *needed*, by checking your browser versions. So it returning different scripts to different people was by design.

      1. tinpinion
        Pint

        Re: Integrity

        Oh, that's cool!

        I think it's a rubbish design from an auditability perspective, but it's definitely a neat idea.

    4. Anonymous Coward
      Anonymous Coward

      Re: Integrity

      > this thing called Subresource Integrity

      As Sora2566 pointed out, SRI won't work for the polyfill ("original as intended", not the dodgy version) stuff - it is specifically *designed* to return different content to different User-Agents, that's exactly the whole purpose of polyfill - i.e. for Firefox 1.0 and Firefox 2.0 and Chrome 2.0 and Safari 3.0 (all version numbers mentioned here are made-up) different content is returned to cater for missing functionality in those various browsers.

      So therefore the *single* polyfill URL will have differing SRI hashes and so SRI can't be used.

    5. CowHorseFrog Silver badge

      Re: Integrity

      The solution you describe is a solution to a problem that shouldnt exist. Host the scripts yourself, and there is one les problem. Please dont tell me the CDN is free, because its just not worth adding ONE more risk just to save basically nothing.

      There are many ways to save traffic using a third party random cdn is not one of them.

      1. tinpinion
        Thumb Up

        Re: Integrity

        I self-host everything, but I don't get visitors to my sites who aren't in my immediate geographical area.

        CDNs are usually used to reduce load times by efficiently distributing resources from servers hosted more locally to visitors, and provide the benefit of allowing cached copies of those resources to be stored on the client device if multiple websites use the same URLs to access them.

        While I agree with your philosophy, I disagree with your assessment of the tangible benefits of CDNs.

        1. CowHorseFrog Silver badge

          Re: Integrity

          I didnt deny there are benefits to using a CDN.. im simply pointing out they introduce a risk which is too costly to any business when bad shite happens, and we have an example here thaat is unnacceptable.

          Everything in life is a balancing game its not worth risking this damage just too save 100ms in load time.

          Let me rephrase the question do you want to save 100ms loading that page if it costs half your info being sold all over the internet cuasing untold lost time resolving problems with banks and god knows who else for the rest of your life on a regular basis ?

    6. DanAU

      Re: Integrity

      The issue is that polyfill .io serves different JS per browser, so it's incompatible with SRI hashes. The solution is to either self-host it, or bundle the polyfills yourself. It's usually sufficient to have two JS bundles: One for old browsers (with all the polyfills required for the oldest browsers your app supports) and one for modern browsers (only polyfills required by browsers released in the last year or so).

  2. Joe W Silver badge

    That's why I hate java script

    I'm really not impressed. Websites should stop pulling in JS code from all over the internet. I get it, no need to reinvent all kinds of wheels lest we make them triangular, I'm all for code reuse. But dynamically pulling in stuff from places that could just become malicious over night is inexcusable. What was the discussion a couple of days back? Getting a sort of "food safety" standard for IT? Yeah, this is such a great example for it. Just as when preparing meals you need to make sure the ingredients are actually safe. So is there a possibility of getting anybody on the hook for poisoning your IT system because they employed lazy sods as web developers? Like getting compensation when the pre-packaged meal I (theoretically would) buy from a supermarket made me sick (more than usual) because some f**kwit thought it would be waaay cheaper to buy the green, worm riddled meat, and in a curry you would never taste that, just add enough chilli.

    I have to admit I have never seen the polyfill.io domain, and I do block all JS per default and need to enable it on a case-by-case basis (and this has lead to me avoiding certain websites - you want scripts from more than 20 different places? What for?!). Really educational...

    1. Ken Hagan Gold badge

      Re: That's why I hate java script

      "I'm all for code reuse."

      Me too, but the safe way to do it is to take a copy, check that it works, and then serve it from your own site.

      Simply pulling it in by reference "so that you can benefit from any fixes they make in future" is simply asking for something like this to happen. It's placing the reputation of your site into the hands of someone who probably doesn't know who you are and certainly doesn't have a commercial reason to care, except possibly being slightly miffed that you are using their bandwidth.

      1. SVD_NL Silver badge

        Re: That's why I hate java script

        I think it has to do with people (or web devs) generally not seeing websites as a piece of software, even though it is.

        You need the same security procedures: source control/change management, supply chain management, etc.

        Just the bare minimum would've prevented most issues here...

      2. Anonymous Coward
        Anonymous Coward

        Re: That's why I hate java script

        I tell juniors that it is fine to find and copy code, but

        A. Make sure you understand it, so if needed you can fix it

        B. Put a reference to the site/repo/whatever/url Does not matter if that has vanished since

        1. CowHorseFrog Silver badge

          Re: That's why I hate java script

          If you have to copy then your already broken... even if you are copying your code from your own company because tomorrow there will be dozens of copies of the same thing and that code will be broken or require a change... and naturally not all copies will be updated.

          The proper solution is to refactor not copy.

        2. _olli

          Re: That's why I hate java script

          Sound generally like a fair advice.

          However, in case your team should develop modern Web applications, creating even a rather simple React app pulls literally thousands of 3rd party open-source packages as dependencies, sub-dependencies and sub-sub-sub dependencies into your codebase from the npm (etc) online repositories.

          Good luck reviewing and knowing what all those thousand+ packages contain. From security perspective that development model is badly screwed.

          1. CowHorseFrog Silver badge

            Re: That's why I hate java script

            Your very true, its amazing how many places claim to be secure, and wont let you buy a pencil unless is from a secure provider and yet they open their legs and let thousands of unknown penises via npm etc.

    2. sabroni Silver badge
      Boffin

      Re: That's why I hate java script

      It's not realty anything to do with JS.

      The problem is a lack of respect for the same origin policy.

      Why does my browser want to run scripts from googletagmanager.com when the browser bar clearly shows that I'm visiting theregister.com?

      It's not the langauge of the payload that is the problem.

      1. find users who cut cat tail

        Re: That's why I hate java script

        Strict same origin rules will lead to morons automatically updating ‘first-party’ resources on the server from random places on the internet. If you think no one will do that because it is too insane, you are clearly new to IT…

        1. anonymous cat herder
          Windows

          Re: That's why I hate java script

          Just because everyone has done it for years doesn't make it right. 100,000 lemmings can't be wrong.,..

          1. find users who cut cat tail

            Re: That's why I hate java script

            I'm not saying it is right. I am just too old and cynical to not see the unintended – but quite predictable – consequences.

        2. Elongated Muskrat Silver badge

          Re: That's why I hate java script

          If they do that, then they are taking (legal) responsibility for the content of that script. On their heads be it.

      2. Dan 55 Silver badge

        Re: That's why I hate java script

        It's not realty anything to do with JS.

        I couldn't disagree more, JS and slapdash go hand-in-hand, even more so than elsewhere in IT.

        1. sabroni Silver badge
          Facepalm

          Re: I couldn't disagree more,

          Well, you could try and back that up with a reason I guess.....

          1. Dan 55 Silver badge
            1. sabroni Silver badge
              Facepalm

              Re: I defer to Douglas Crockford

              So nothing that you can actually explain then.....

      3. Elongated Muskrat Silver badge

        Re: That's why I hate java script

        Why does my browser want to run scripts from googletagmanager.com when the browser bar clearly shows that I'm visiting theregister.com?

        That's easy - I have NoScript installed, and that domain is forbidden to serve up scripts to my browser, so it doesn't. I've yet to encounter a site that is broken as a result.

        1. Michael Wojcik Silver badge

          Re: That's why I hate java script

          Agreed. Since the only purpose of googletagmanager is to spy on users, blocking it is a no-brainer. Along with googleanalytics and doubleclick — harmful garbage that exists on far too many sites. (And no, I don't buy the "we need analytics to serve you better" crap.)

          1. Dave559

            Re: That's why I hate java script

            There is a legitimate use for analytics, provided that the system used is trustworthy and is locally-hosted to protect user privacy (eg, locally hosted Matomo), and as long as the data that you get from this actually is reviewed periodically and actions are taken to improve the site content, layout, UI, etc, as a result. But sadly I suspect it is mostly the case that far too many sites mindlessly insert the Google Analprobe endoscope and all the rest of 'teh frEe sTufFz' because "all the other clueless web monkeys are doing it", and the site owner "thinks" it would be useful, but then rarely or never actually looks at it… «sigh»

            1. CowHorseFrog Silver badge

              Re: That's why I hate java script

              THe benefits far outweight the cost.

            2. Elongated Muskrat Silver badge

              Re: That's why I hate java script

              I don't buy the "site improvement" stuff. There are plenty of successful design idioms out there, and you don't need to track your users to copy them.

              Conversely, how often do you see a site do a complete layout redesign? How many sites spewing google analytics at you do this, ever?

              I think the answers to those questions would enlighten you to how much of a bullshit factor applies to this argument.

        2. CowHorseFrog Silver badge

          Re: That's why I hate java script

          But its an impossible task to blacklist all the bad guys just like its impossible to whitelist al lthe good guys.

      4. CowHorseFrog Silver badge

        Re: That's why I hate java script

        NO.

        The problem is if youa rent 1000% sure it safe and can be trusted you shouldnt be randomly pulling shite from random cdn...

        Its just not worth it.

  3. Mage Silver badge
    Flame

    Third party scripts

    I don't think I use any third party sites on my websites. Sometimes accidentally "remote google fonts" due to theme developers being stupid. I edit that out when I spot it.

    I've been saying 25 years that it's stupid using 3rd party sites for content. Adverts and analytics should be served from same host too, or at least a server run by the same organisation.

    My main reason for script or ad blockers isn't to block adverts but malware. More use today than AV for floppies or CDs.

    1. Anonymous Coward
      Anonymous Coward

      Re: Third party scripts

      Hear hear. I'd be fine with ads, but running third-party code from people paying to get it run on random people's computers? No thanks!

      1. Elongated Muskrat Silver badge

        Re: Third party scripts

        I'd say the same, but with the provision that I'm not fine with ads that are intrusive. If I don't want to look at your ad, it's my choice, and forcing me to do so doesn't endear me to the product you are trying to flog to me.

        I'm looking at you, unskippable 30 second video ads for the same thing EVERY SINGLE TIME, complete with loud sound, and tiny, teeny, microscopic close buttons on mobile apps.

        1. Michael Wojcik Silver badge

          Re: Third party scripts

          Right. Magazine-style advertisements are fine, as far as I'm concerned. Anything with "multimedia" — animation, video, noise — is not fine. Anything that blocks actual content is not fine. Anything deceptive — made to look like something other than an advertisement — is not fine.

          1. Elongated Muskrat Silver badge

            Re: Third party scripts

            Exactly. Add to that anything that wants to run a script to show you an advert, because that's pretty much the number 1 malware vector.

            I'd say that probably 99% of adverts out there cross at least one of these red lines, and that's why I block them all, both in the browser, and at the network level at home by blocking advertising domains.

  4. waldo kitty
    Facepalm

    Tip of the Day

    remember to look at your whitelists! many have added the polyfill.io domains to their NoScript whitelist... pretty sure there are other whitelists it will be found on, too...

    1. Snake Silver badge

      Re: Tip of the Day

      NoScript now blocks polyfill.io on its badware risk list, just tried it. Problem is that most of us have allowed polyfill for a while now even, so how much risk were we exposed to? I usually do NOT allow polyfill on NoScript but a few websites do refuse to run unless you allow it, so this does *not* make me happy. I just blocked the domain on the entire office network.

    2. Elongated Muskrat Silver badge

      Re: Tip of the Day

      Yeah, I've corrected the browsers on my work machines, will do so on my home machines when I finish work, and also add to the Pi-Hole.

  5. that one in the corner Silver badge

    Quick Robin, to the Bat-PiHole

    Just check polyfill.io and bootcss.com are being blacklisted - done.

  6. heyrick Silver badge
    Facepalm

    And yet the online advertisers (and the sites beholden to the shiny) seem to think it's their god given right to expect you to run who knows what from who knows where out of their 764 "partners".

    Remote scripts should be utterly disallowed, the only exception being for up to two specific domains mentioned in the DNS lookup for the primary domain (so as to allow stuff like CDNs).

    Pulling random crap from all over, who'da thought that would go wrong. See icon.

  7. Sparsely the Lion
    FAIL

    LLM's

    > If you're using Polyfill.io code on your site – like 100,000+ are – remove it immediately

    Will the purveyor's of LLMs ensure that content from Polyfill.io is removed from their models or is the damage now done and Copilot et al will generate code that has the backdoor to China already built in?

    [ I apologise for breaking GodwAIn's law - sooner or later in a thread a post is either written by or references AI ]

    1. Anonymous Coward
      Anonymous Coward

      Re: LLM's

      "Backdoor to China" If China was really doing this, do you think it would be that easy to trace ownership back to China? People are so gullible, it's incredible. Fear mongering and w@rmongering seem to work every time. Real life is not a hollywood movie.

  8. Anonymous Coward
    Anonymous Coward

    Most antiviruses do not flag it

    Only 5 out of 95 security vendors flagged Polyfill.io as malicious:

    https://www.virustotal.com/gui/url/396bdc661d3b8225040b87b5d703b5afff4f0fe67e22254a106fac9d62ba3a3c

    1. Theodore.S

      Re: Most antiviruses do not flag it

      On the other hand, it is already blocked in uBlock Origin.

  9. Bebu
    Windows

    Obvious?

    I would have thought where an entity was demonstrably engaged in illegitimate or unlawful activities such as this, the urgent forced surrender of the DNS domain would be entirely justified.

    The idea of downloading any old excrement from arbitrary sites on the internet and shoveling it into your clients' browsers (or have their browsers do this at your site's behest) must rank with some of the world's worst ideas.

    While clever and powerfuI I was never comfortable with anything like ECMA-Script messing with a browser's DOM.

    1. Dyson Lu

      Re: Obvious?

      "the urgent forced surrender of the DNS domain would be entirely justified."

      Because this is a false flag? Think about it.

  10. CowHorseFrog Silver badge

    Third party anything in a browser ia. recipe for problems... first advertising and heres another highlight, third party js.

  11. Missing Semicolon Silver badge
    FAIL

    Laziness

    I never understood how web designers thought it was reasonable to treat external hosting of JS libraries on infrastructure that they don't own and don't pay for as some kind of public utility. People just slap in references to jquery or Bootstrap or whatever from random CDNs without a second thought.

    These are big sites, run by "proper" companies/organisations. How are they so unprofessional?

    1. elaar

      Re: Laziness

      "People just slap in references to jquery or Bootstrap or whatever from random CDNs without a second thought."

      Most people use a large, reliable CDN, that specifically offers this as a public service, using SRI in a secure way. What's the issue with that?

      1. Missing Semicolon Silver badge

        Re: Laziness

        How much do they pay? Nothing? Then they are freeloading, and also putting their work at risk of "sorry, sunsetting support kthxby!".

        It's just mad that commercial organisations can just leech bandwidth from public service infrastructure. And get surprised when it stops working.

    2. Ken Shabby Bronze badge

      Re: Laziness

      Because they outsource to the cheapest supplier possible and claim they are not responsible.

  12. Anonymous Coward
    Anonymous Coward

    Saw this on my Techmeme feed. Lots of social media threads and news articles, for this type of news. The word "Chinese" is in the headline and/or in the very first paragraph of the article. This tells me it's a false flag. But people will gladly fall for the fear and war mongering every time. They have been subject to pavlovian programming for generations.

    1. Anonymous Coward
      Anonymous Coward

      Found the wumao.

  13. Michael Strorm Silver badge

    What you did with the URL...

    ...I saw that, 80s boy. :-)

  14. Anonymous Coward
    Anonymous Coward

    Anybody

    Pulling scripts from domains that they do not own for their shitty website, is an idiot, pure and simple, no ifs, no buts

    But seeing as the majority do this I can only be led to the conclusion that the world is full of idiots.

    Wait…. I already know this to be true just by people watching

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like