nodejs.org icon indicating copy to clipboard operation
nodejs.org copied to clipboard

https://nodejs.org/dist/ Blocking JFrog Artifactory User Agent: Artifactory

Open adam-browning opened this issue 3 years ago • 29 comments

Version

18.15.0

Platform

Darwin adamb-mac 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

curl -H "Host: nodejs.org" -H "User-Agent: Artifactory/" https://nodejs.org/dist --head
HTTP/2 403
date: Sun, 30 Jul 2023 11:17:09 GMT
content-type: text/html; charset=UTF-8
cache-control: max-age=15
expires: Sun, 30 Jul 2023 11:17:24 GMT
x-frame-options: SAMEORIGIN
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
server: cloudflare
cf-ray: 7eed318d7de809c3-HFA

How often does it reproduce? Is there a required condition?

always

What is the expected behavior? Why is that the expected behavior?

Allow access to https://nodejs.org/dist/ from User Agent: Artifactory

What do you see instead?

HTTP/2 403
date: Thu, 03 Aug 2023 15:50:03 GMT
content-type: text/html; charset=UTF-8
cache-control: max-age=15
expires: Thu, 03 Aug 2023 15:50:18 GMT
x-frame-options: SAMEORIGIN
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
server: cloudflare
cf-ray: 7f0fb6cf8a11416a-LHR

Additional information

Hello, My name is Adam and I'm a Product Manager @JFrog. We recently discovered that our mutual customers are being blocked from accessing the following URL when requesting data from user agent "Artifactory" https://nodejs.org/dist/

We would like to collaborate together to understand why this restriction was enabled and see how we can resolve any issues from the Jfrog Platform source.

We are looking forward to working together Thanks in advance, Adam

adam-browning avatar Aug 03 '23 15:08 adam-browning

Probably better asked over at nodejs/nodejs.org. Maybe an admin can move the issue.

bnoordhuis avatar Aug 03 '23 19:08 bnoordhuis

There is a related discussion in - https://github.com/nodejs/build/issues/3223.

If the complaint is that requests for non Node.js downloads are being blocked, then that issues covers why the project sees those requests as a problem. If it is blocking requests for Node.js downloads that might not be intentional but a side effect of trying to block the spam requests.

mhdawson avatar Aug 03 '23 20:08 mhdawson

@nodejs/build to pull in more of the people who have been in past discussions.

mhdawson avatar Aug 03 '23 20:08 mhdawson

Here's a sample of blocked requests I just took from the Cloudflare logs. You can see that none of these make sense for the nodejs.org origin. We block literally millions of requests every day. They would otherwise overload our server, which is already struggling.

Screenshot of blocked requests

CleanShot 2023-08-04 at 09 05 57

targos avatar Aug 04 '23 07:08 targos

Hi @targos Thanks for sharing the information and we would like to partner together to prevent this from happening in the future specifically for our mutual Saas customers.

We have identified the abusive customer on our end and reached out to them to prevent these redundant requests. We are currently working on a solution to prevent the egress from Artifactory Saas to npmjs.org in cases like these. In the meanwhile, we would kindly request that you switch to IP-based blocking since User Agent is much more aggressive and encompasses a huge number of customers beyond the impact scope. Would that be possible?

One last thing, I would like to create an open communication line between us for issues like this Please feel free to reach out to me at @[email protected] so we can find an easy method to foster the relationship

Thanks in advance, Adam

adam-browning avatar Aug 08 '23 08:08 adam-browning

@adam-browning, @targos would it make sense for use to find a time for a short discussion. Would 10:30 ET on Friday the 18th work for you two?

mhdawson avatar Aug 14 '23 18:08 mhdawson

Hi @mhdawson I'm located in Israel and specifically on the 18th I'm not available. I am available between 9-11am ET on Tuesdays the 22nd and 29 of August Let me know if that could work for you. Thanks in advance! Adam

adam-browning avatar Aug 15 '23 07:08 adam-browning

I'm going to be on holiday until the 4th of September. Let's try to clarify things here first. @adam-browning Our firewall rule tries to accommodate for legitimate URLs. Do you have examples of URLs that Artifactory needs to access and are currently blocked by the rule?

targos avatar Aug 15 '23 07:08 targos

Hi @targos yes, https://nodejs.org/dist/ is currently blocking traffic from user agent: Artifactory/

image

adam-browning avatar Aug 15 '23 07:08 adam-browning

Blocking on a user agent level is very excessive since we have ~7,000+ mutual customers accessing npmjs.org using Artifactory Saas and are masked by this user agent. We have contacted the abusive customer that incorrectly configured a maven repository against the npm url and are working to prevent these issues from happening again.

In addition, I'm adding JFrog's NAT Saas IPs list https://jfrog.com/help/r/what-are-artifactory-cloud-nated-ips If an abusive pattern originates from one of these IPs please contact me directly and we will attempt to block the traffic from our end before you need to block. Thanks in advance,

adam-browning avatar Aug 15 '23 07:08 adam-browning

There is a big misunderstanding here. https://nodejs.org/dist/ is not the same as npmjs.org. It is not the npm registry, nor is it a mirror for it. While we have seen some requests coming from misconfigured maven repositories, the vast majority of requests come from misconfigured npm registry.

targos avatar Aug 15 '23 07:08 targos

Can we please switch this conversation to e-mails or Slack (OpenJS)? I definitely don't want see this issue getting polluted with calendar scheduling messages 😅

Also, I'm with @targos here, we have a Firewall rule that allows legitimate JFrog/Artifactory requests for Node.js Binaries.

The screenshot you've (@adam-browning) shown above is not one of those legitimate cases, as it is a directory listening. (If JFrog needs to have directory listening, let us know)

Here's the regex we use for our WAF rule.

(http.user_agent matches "^(Artifactory/|Nexus/|AzureArtifacts/|Gradle/)" and not http.request.uri.path matches "\.(gz|xz|pkg|7z|zip|msi|txt|asc|sig|lib|exe|json|tab)$")

You can see that requests going to Node.js binaries will succeed. But requests that are directory listing requests or NPM package requests will be blocked.

ovflowd avatar Aug 15 '23 10:08 ovflowd

Understood, moving to OpenJS

adam-browning avatar Aug 22 '23 10:08 adam-browning

I am unable to cache the nodejs binaries using Artifactory at this time due to this. We need this functionality as nodejs.org has poor uptime compared to our internal cache. @adam-browning can you make it so there's a way to change the User-Agent header on the self-hosted Artifactory as a workaround here?

crazed avatar Sep 06 '23 19:09 crazed

can you make it so there's a way to change the User-Agent header on the self-hosted Artifactory as a workaround here?

Please don't do this.

I am unable to cache the nodejs binaries using Artifactory at this time due to this.

I assume you haven't read the comments on this issue. This is not an issue on our side but a misconfiguration on Artifactory. nodejs.org should not be used for Artifactory. At least not for NPM packages.

We already have rules that 100% allow Artifactory requests if they go for fetching Node.js binaries. And we even added screenshots here and other comments about how our rules are set in place...

We need this functionality as nodejs.org has poor uptime compared to our internal cache.

That's a blunt assertion. The Node.js Website has very few moments of poor performance on specific cache-purge times. That might create a wrong sensation that the nodejs.org website has poor performance or it is slow. But hey, we serve Petabytes of data every month.


Tackling this in the "let's find ways how to circumvent this issue that is 100% an issue on the user side, is not the way to go with this.

We're still waiting @adam-browning to reach us out on the OpenJS Slack so we can better communicate. But again, the root issue here is that many examples of how to "configure" Artifactory for Node.js out there are wrong, and attempt to make Artifactory request NPM packages against https://nodejs.org/dist, which is wrong. And that's what we are blocking in our Firewalls. This causes your Artifactory instances to fail, because one of the "sources" is giving HTTP 401. The solution is simple, update your artifactory configuration to use https://npmjs.com for NPM packages, and https://nodejs.org for Node.js binaries.

ovflowd avatar Sep 06 '23 21:09 ovflowd

@adam-browning : Are there any updates/ideas on the open questions? We want to use Artifactory only for Node.js binaries - not for NPM packages. This use case still does not run with the current firewall settings. We were not able to identify the real root cause for our problems. A speculative idea might be as follows: Are there initial requests to the root address, before accessing the dist-URLs? Receiving 401 from accessing the root URLs might prevent the real request from being executed. (Just guessing...)

jensborrmann avatar Oct 19 '23 11:10 jensborrmann

@ovflowd I, as a Jfrog customer and the originator of this issue, get the 403 rejection when accessing https://nodejs.org as well as for https://nodejs.org/dist and we want to download the nodejs binaries. this 403 error on https://nodejs.org keeps me from access to https://nodejs.org/download/release/ as well. the last Nodejs version we've downloaded successfully was 18.0.0, 1.5 year ago. for the npm packages we use https://registry.npmjs.org successfully.

Zvikac avatar Dec 05 '23 08:12 Zvikac

As we mentioned before, directory listing for JFrog is prohibited at the moment. You can still directly download binaries via JFrog/Artifactory if they request the binary directly.

If JFrog/Artifactory relies on directory listing to download the versions, that's a bad software design from their side, as "regexing/eval'ing" a directory listing is flaky. I'd recommend that the Artifactory/JFrog team to fix that and simply read the versions from nodejs.org/dist/index.json

Again, the issue is not on our side but on the software you rely on. We're not changing our firewall rules, which will degrade the experience for everyone, because some paid product is misusing our infrastructure.

We might eventually lift these firewall rules once we migrate our binaries "CDN" infra to Cloudflare R2/Cloudflare Workers, which will mitigate the issue of our infrastructure overload/being hammered by a bunch of bots and whatnot.

If you're curious about the progress, here's the issue: https://github.com/nodejs/build/issues/346We we welcomed JFrog (or whatever company behind this software) to join our Slack and talk with us, but apparently, they didn't care enough, so I doubt we're the baddies here. We're open to compromise, but the current way the software you're using is doing things against our infra is just unhealthy.

ovflowd avatar Dec 05 '23 09:12 ovflowd

@ovflowd Yes, but https://nodejs.org/ is not a directory and I still get 403.

Zvikac avatar Dec 05 '23 09:12 Zvikac

@ovflowd

Yes, but https://nodejs.org/ is not a directory and I still get 403.

Why would Artifactory want to open the main page? This is meant for humans not bots.

ovflowd avatar Dec 05 '23 09:12 ovflowd