What We Learned From the Polyfill Attack

Поділитися
Вставка
  • Опубліковано 4 лип 2024
  • Key takeaways from the Polyfill.io CDN attack
    💬 Topics:
    - What is the Polyfill attack;
    - Advantages of CDNs;
    - CDNs vs NPM;
    - Node & JSR;
    🥇 Become a Member - / @awesome-coding
    ✉️ Join the Newsletter - newsletter.awesome.club/
    📖 Blog Article - www.awesome.club/blog/2024/wh...

КОМЕНТАРІ • 66

  • @aLfRemArShMeLlOw
    @aLfRemArShMeLlOw 28 днів тому +61

    I didn't need to get my mother and my node modules folder roasted in the first 30 seconds!

  • @ozgurg0
    @ozgurg0 28 днів тому +42

    Some additional security practices:
    - If you're going to use a CDN, do not remove the integrity attribute. If the CDN does not provide this value, do not use that CDN.
    - If you're going to use npm, use exact versions.

    • @zettca
      @zettca 28 днів тому +6

      If you have a lock file, you're already using exact versions.
      Exact versions in package.json suck. Just don't bump them mindlessly

    • @SummerSC2
      @SummerSC2 27 днів тому +1

      @@zettca Why exact versions in package.json suck tho ?

    • @zettca
      @zettca 27 днів тому +1

      @@SummerSC2
      - harder to upgrade and vuln audit fix
      - you'll end up with multiple versions of the same package (needlessly), which can lead to issues

    • @sbk2015
      @sbk2015 27 днів тому

      I found if the integrity check fails, it would fail to load the library and your webapp would bascially stop running. Have googled for it, there are some reasons other than malicious attack would also fail the integrity check, that would be a bad user experience for webapp users.

    • @trumpetpunk42
      @trumpetpunk42 26 днів тому

      ​@@sbk2015But if you get hacked, then that's a really bad user experience.

  • @ryo_5748
    @ryo_5748 27 днів тому +14

    The Web is the world's most pervasive and most vulnerable infrastructure.

  • @shaunkruger
    @shaunkruger 24 дні тому +3

    The biggest reason I don’t rely on public cdn published libraries is that I don’t want to find out that a library stopped being published that way by having it disappear and break my web app.

  • @modolief
    @modolief 27 днів тому +2

    Nice, concise - thanks.

  • @krellin
    @krellin 28 днів тому +3

    we need to have some crowdfunded team that goes trough most downloaded/most popular libraries and carefully verifies/validates them

    • @awesome-coding
      @awesome-coding  27 днів тому +2

      Spending money in open source software? I doubt we'll ever do that 🫠

    • @krellin
      @krellin 27 днів тому

      @@awesome-coding then we will keep having these issues, big projects with high downloads are obviously the targets

  • @g-luu
    @g-luu 28 днів тому +11

    Yo that was uncalled-for 😅

  • @kecoje
    @kecoje 27 днів тому +7

    Can we just use a checksum with the CDN library?

    • @LetrixAR
      @LetrixAR 27 днів тому +4

      Yes, but in the case of polyfill, it wouldn't work I think.
      You use the 'integrity' attribute in the script tag.

    • @mig8447
      @mig8447 25 днів тому

      Why wouldn't it work @LetrixAR, isn't the browser supposed to check the integrity hash before executing the script?

    • @ilonachan
      @ilonachan 25 днів тому

      ​@@LetrixARso then the issue is just that Polyfill was a special case where usual security concepts couldn't apply, and you really did need to trust that server implicitly (bad thing)
      Maybe the solution would be to, instead of sending a single JS file that changes based on browser agent in unpredictable ways, send multiple smaller JS snippets (either zipped together, or just a single js file with range markers) for each of the features that are enabled or not. On a whole-file level that would also change unpredictably, but the client could still do checks on the individual snippets: calculate checksums, determine if this snippet is even needed or wanted, etc. Then you'd need a polyfill downloader library for all this complex logic, but that can be provided from a regular CDN with integrity checks.

    • @MattDunlapCO
      @MattDunlapCO 24 дні тому

      ​@@mig8447it wouldn't work because the cdn sending the malicious file is also sending the checksum. Checksums really only help with corrupted packets or man-in-the-middle attacks. If you never care to get an updated version then you could always store your own checksum for the specific file you expect to receive.

  • @wlockuz4467
    @wlockuz4467 27 днів тому +1

    Are you going to cover the drama with the AXObject-query package?

  • @veganaiZe
    @veganaiZe 27 днів тому +2

    You can also just download a specific version of a (cdn) library and deliver that same version to the client. No npm garbage necessary.

    • @awesome-coding
      @awesome-coding  27 днів тому +2

      What if the next time you make a request to your specific version, that script contains a few new malicious lines?

    • @veganaiZe
      @veganaiZe 13 днів тому

      @@awesome-coding It won't. That's the point.

  • @sushiConPorotos
    @sushiConPorotos 25 днів тому +2

    Nobody has time to check the source code to see if there is malicious code. Lack of time is the main reason they use CDNs.

    • @awesome-coding
      @awesome-coding  25 днів тому +1

      Nobody has time for security until they are forced to make time to fix problems caused by bad security.

  • @siliconhawk9293
    @siliconhawk9293 25 днів тому

    i like the philosophy of always local. at least whenever you can

  • @harshrathod50
    @harshrathod50 28 днів тому +5

    Never used CDN at all in my previously built company projects. 😎 (Except fonts from fontsource because they are trustworthy, right?, right?)

    • @awesome-coding
      @awesome-coding  27 днів тому +5

      Yes they are! Just don't ask why your fonts require this little JS script to run in the background. 👍

  • @matwatgd624
    @matwatgd624 27 днів тому +1

    Im not good at this but it generated my a big question, i do my frontends with HTMX and Go, and i usually import my libraries via unpkg cdn, if i try to avoid cdns, how else would i do it?

    • @awesome-coding
      @awesome-coding  27 днів тому +4

      I understand the reasons behind your stack. Basically you use HTMX for minimum JS interaction and this allows you to avoid an extra build step for the frontend (The step that's usually done by node).
      Technically you could download the current versions from CDN locally, run audits on that code to make sure it's safe, and then host those scripts on your server, just like you would host any other static assets (like CSS or images)
      If you want, you could also add an additional build step, where you would download those scripts from NOM and use WebPack or another bundler to combine all those scripts into a single file.

    • @matwatgd624
      @matwatgd624 27 днів тому +1

      @@awesome-coding thank you!

  • @crab-cake
    @crab-cake 27 днів тому

    how long have you worked at deno land?

    • @awesome-coding
      @awesome-coding  27 днів тому

      I am not working for them - I'm just helping with some of their UA-cam content.

  • @kennyfully88
    @kennyfully88 2 дні тому

    Most projects aren't built from scratch. Most being the keyword. Most... Sometimes, I like writing all my code in one HTML file and freaking everyone out when they see games and stuff working smoothly and nearly anywhere, even without a local host. Yup... I'm that strange guy sometimes.

  • @timothywcrane
    @timothywcrane 27 днів тому

    I'm not big on js lib packaging knowledge, but I am pretty sure this applies to all the condas out there as well. I think it is not wildly off to suspect rbrn more though that edu and med get literally hijacked for ransom in the data processing libraries sharing phase... ever count the different URLs (because it only works with this mod) in some demos people grab for client or inhouse use if everything is "clickety split" off of colab or github? I do. Every one of us. We do need more due diligence. That's what the open code is for, and we should honor it. Rather have that than proprietary though in most cases as every install is a zero day by definition.

    • @doc8527
      @doc8527 24 дні тому +1

      Yes, strictly and technically speaking, this applies to everywhere (regardless language and framework) as long as you involve downloading a package from a URL, or fetching a "trust" resource during the runtime and try to execute it. It's just web is more vulnerable to this issue or chain attack due to its nature and history.
      But the social media just prefers to bash the web more since it's already a "dead horse". Make you feel like it's just a web issue.
      The dunning-kruger effect is real. You will see a bunch of "devs" laughing at web all the time, but many didn't even know they need to encrypt the secret key in device or password in DB. Just speak from some real experiences. I have to constantly remind myself don't run into the same issue without context.

  • @EdKolis
    @EdKolis 26 днів тому

    If everybody has a price, and everybody knows that everybody has a price, why has no one offered me my price yet so I can retire in the Cayman Islands?

    • @awesome-coding
      @awesome-coding  26 днів тому +2

      Man.. in this economy I'm happy if somebody simply pays me a salary...

  • @kickeddroid
    @kickeddroid 26 днів тому

    When are we just gonna verify the content with incremental hashing jeeeez loiuzeeeeeeee

  • @kasper369
    @kasper369 27 днів тому

    So vr gonna ignore jsr - nvm

  • @Noritoshi-r8m
    @Noritoshi-r8m 19 днів тому

    Man.. why is Javascript still in the front seat of web development, this is a mess.

  • @MrDpof
    @MrDpof 27 днів тому

    SRI leaving the chat crying: why no one loves me...

  • @sunnyarora3557
    @sunnyarora3557 26 днів тому

    Hi, You are wrong CDN are safe read more about integrity attribute in the script which ought to passed to ensure you are downloading safe correct code.

    • @awesome-coding
      @awesome-coding  26 днів тому

      Somebody else mentioned this, so I'll pin you comment.
      Yes, you are right, the integrity attribute covers the script manipulation issue. However, not all CDN providers support integrity as far as I now.
      Furthermore, if you want to be on the safe side, you would still need to download that script locally and run security tests / audits on it.
      In real world scenarios you could also risk a developer adding a script from a CDN without the integrity attribute, and pass unobserved in code review (that if your team does code reviews).
      So, for real projects where security is a real issue I would just enforce a npm based approach with audits / security checks in the CI / CD process.
      My two cents :)

    • @sunnyarora3557
      @sunnyarora3557 26 днів тому

      @@awesome-coding I agree all the CDN doesn't provide integrity, So we should avoid such CDN providers. Maybe i should start a yt shorts series about Web security🤣.

  • @ryanlog
    @ryanlog 26 днів тому

    This goes against the company u work for bro.... deno uses CDNs in most of the codebase

  • @a-yo9312
    @a-yo9312 28 днів тому +1

    Yo mama?

  • @adrianspikes6454
    @adrianspikes6454 25 днів тому

    Another reason i believe that open-source was pushed so hard... Access 💯 and not due to proprietary hatred!! Just more scammers 😂