News for hackers. Stuff that matters.
Re:Remote code execution in cdnjs of Cloudflare by Crazyontap on Friday July 16, 2021 @04:47AM (#27854231)
There is probably no good reason to use such CDNs nowadays:

1) The biggest benefit of using cdn was that scripts stylesheets were often loaded from cache. This is no longer the case anymore.

2) It's adding an unnecessary vulnerability as seen from this case.

3) CDN scripts can be (possibly) used to track your website traffic.

4) They often drop third party cookies which decreases your website load speed among other things.

It's best to just host your script on Digital ocean spaces or S3 and use a Cloudfront proxy.

Re:Remote code execution in cdnjs of Cloudflare by cryptonym on Friday July 16, 2021 @04:59AM (#27854309)
CDN can protect your servers from DDOS and countless attacks, bots, vulnerabilities. It tends to be patched pretty quickly when there is an issue. It can reduce cost by offloading, improve performance by distributing content (with or without computing) from a closer location, optimise delivery in many ways, scale with limited cost...

Extra cookies and scripts are related to specific features. A good CDN will let you configure exactly what you want.

Cloudfront is a CDN.

EDIT: The issue is more related to using a third party domain in order to load assets on you website. I agree, that should be done from first party when possible.

Re:Remote code execution in cdnjs of Cloudflare by judge2020 on Friday July 16, 2021 @07:30AM (#27855181)
Yes, I think OP meant “cdnjs” when he was talking about CDNs, not reverse proxies like Cloudflare, Cloudfront or Akamai.
Re:Remote code execution in cdnjs of Cloudflare by hansel_der on Friday July 16, 2021 @08:12AM (#27855457)
i think op was referring to the practice of using a separate cdn for specific resources (like fonts and scripts), not using a cdn per se.
Re:Remote code execution in cdnjs of Cloudflare by zinekeller on Friday July 16, 2021 @05:25AM (#27854464)
Some rebuttals:

> 1) The biggest benefit of using cdn was that scripts stylesheets were often loaded from cache. This is no longer the case anymore.

This is indeed true. However, most websites (despite the relative ease of activating a CDN service) only host their website in a single location. In those cases, library CDNs (to differentiate from other uses of CDNs) can still benefit the website, even when you consider optimisation strategies such as HTTP/2. Additionally, the stress on their servers are decreased because it's handled by their library CDN provider.

> 2) It's adding an unnecessary vulnerability as seen from this case.

> 3) CDN scripts can be (possibly) used to track your website traffic.

Good points and something that I can't rebut easily. It is indeed on the onus of the website to check the reputation of library CDNs, and it may violate privacy guarantees (you're trusting Google/CloudFlare/Microsoft/Amazon/Fastly/MaxCDN etc.) Specifically on 2) however, they knew that they are large: the speed of fixes (as shown) here proves that library CDNs can benefit websites' security, which tends that its software stack is updated slower (by the website operator's fault). You can also leverage subresource integrity (https://developer.mozilla.org/en-US/docs/Web/Security/Subres...) to fail hard.

> 4) They often drop third party cookies which decreases your website load speed among other things.

Citation needed here. As far as I checked (and just verified as I post this, to ensure that this is still true), every library CDNs I knew (even in weird places such as Japan- and China-centric library CDNs) do not place cookies in the library URLs themselves (some do on their websites themselves, but it is usually separated by domain names).

> It's best to just host your script on Digital ocean spaces or S3 and use a Cloudfront proxy.

If you're a large website or basically need to ensure the privacy is guaranteed, sure! I see that large websites do in fact use their own choice of CDN providers (most websites including Amazon themselves uses Fastly though). Some even do a step-up: some websites (for example) use Fastly for their American traffic, KeyCDN for European traffic and Quantil for Asian traffic. However, I only knew of two CDN providers which provides a flat-rate and reasonable costs: CloudFlare (uhh, CDNJS operator) and DDOS-Guard (which some consider shady).

Re:Remote code execution in cdnjs of Cloudflare by z3t4 on Friday July 16, 2021 @06:59AM (#27854953)
A CDN is really only useful if you store your entire website with all it's content on it. Or if you serve a lot of data (petabyte egress) where the CDN have better peering deals for lower bandwidth cost. If you operate a "normal" static website, make sure http2 is activated, and that assets that never change are cached. And if possible use a hosting provider in the same country your users are located.
Re:Remote code execution in cdnjs of Cloudflare by zinekeller on Monday July 19, 2021 @09:48AM (#27882622)
> Make sure http2 is activated

HTTP/2 suffers from Head-of-Line blocking, which may impede rather than help speed up the connection. In most cases, this doesn't happen, but when they do happen it's consistent. Testing is required, because there are cases where HTTP/2 backfires spectacularly.

> That assets that never change are cached

Fair point, I also strongly recommend this. Plus, if your server supports statically compressing resources ahead of time it pays serious dividends (and activating Brotli, if you can custom compile applications or lucky to use a distribution that built it).

> And if possible use a hosting provider in the same country your users are located.

In Europe, this is relatively easy. In the US and Russia, probably two servers (for East and West coast/okrugs). In Asia? Surprisingly difficult, unless you're in East Asia (I'm not discussing why here since there's plenty of resources to learn more about why it's a pain in the rear). Africa? Actually, despite improvements in connectivity I strongly recommend to make the pages small and simple (as the requirements allow).

Re:Remote code execution in cdnjs of Cloudflare by tobr on Friday July 16, 2021 @05:01AM (#27854321)
It’s often the lowest-friction way to include a library in a project. You’ll often see “getting started“ documentation using cdnjs.com because it’s so easy. That’s not a good reason, but probably a very real one.
Re:Remote code execution in cdnjs of Cloudflare by torgard on Friday July 16, 2021 @05:16AM (#27854418)
> Cloudfront proxy

I mean, CloudFront is a CDN too.

EDIT: Oh, I misread. You weren't dismissing CDNs entirely. Only this type of CDNs. In that, I agree.

Re:Remote code execution in cdnjs of Cloudflare by johne20 on Friday July 16, 2021 @06:27AM (#27854757)
We have ran with s3 origin and a CDN for our static files for years. It has been super solid, almost zero downtime.

One thing that has become an issue, is s3 doesn't let add custom headers, eg. CSP, CORP etc.

We are considering firebase hosting or our own origins behind a CDN for more control over headers. Anyone have any other suggestions?

Re:Remote code execution in cdnjs of Cloudflare by twistedpair on Friday July 16, 2021 @08:36AM (#27855598)
I'd suggest GCS+Cloud CDN or S3+CloudFront.

I've been running several sites off Firebase Hosting the last 4 years and have seen surprisingly high downtime, cache clearing errors, and unexplained 502 errors from Firebase Hosting.

Re:Remote code execution in cdnjs of Cloudflare by dubcanada on Friday July 16, 2021 @06:46AM (#27854864)
Cloudfront with a lambda setup can add all the custom headers you want.