-
Notifications
You must be signed in to change notification settings - Fork 293
fetch('https://www.php.net') using official nodejs binaries results in 503 - but 200 on other binaries, in browser, curl, etc. #4516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was able to reproduce this from raspberry pi 4B for node 22.12 and node 18.19. @nodejs/net Can you check
|
I can reproduce this myself: requests with Node are all rejected, while other tools all work correctly. This happens with fetch and the It looks like php.net (or more likely the CDN they're using) now blocks some of Node.js's TLS fingerprints completely. Not all of them (not the fingerprint from Macs, by the sounds of @preveen-stack's tests) but at least requests from Node on Linux. I'd guess they've seen some bot traffic with that signature, and some anti-bot mechanisms somewhere have marked it as suspicious. Testing with HTTP Toolkit to check: making the request with any recent Node returns 503, making the request via HTTP Toolkit (which proxies the same content with identical header data etc, but does affect the TLS fingerprint) returns a 200. HTTP Toolkit itself is actually built with Node.js, but modifies its own fingerprint to roughly match Firefox here: https://github.com/httptoolkit/mockttp/blob/703fa1f06fdfa91ddc3ba8494c94747c90462c31/src/rules/passthrough-handling.ts#L25-L100 Copying that logic, if I make a request with the equivalent cipher list, it works:
This prints I wrote an article about workarounds to solve TLS fingerprinting issues in general a while back here: https://httptoolkit.com/blog/tls-fingerprinting-node-js/. There's an issue discussing possible solutions in Node at nodejs/node#41112 but no real fix coming imminently there I'm afraid. For now, the easiest way to resolve this will be to tweak your request's TLS config somehow as above. |
Thanks, this explains everything. Also found confirmations in https://github.com/php/web-php/issues that other types of clients get blocked sometimes too. |
for anyone following along at home, php.net no longer blocks whether you re-arrange the ciphers or not sicne I'm pretty sure they turned off any cdn bot protection. There's nothing in the response headers that would point to akamai or cloudflare. At least on my machine, at this specific point in time. The thing is, the blocking techniques used are getting more sophisticated and crude, naive re-arrangement of ciphers is very easy to block. For instance, no matter what ciphers you limit the request to in node, openssl will add |
I fixed that exact issue in OpenSSL a few months ago 😄. OpenSSL 3.4.0+ no longer sends the TLS_EMPTY_RENEGOTIATION_INFO_SCSV for modern TLS: openssl/openssl#24161. This fingerprinting is problematic, but there's quite a bit of progress that can be made here! I think it's quite plausible to get to a stage in future where you can configure Node with an TLS fingerprint indistinguishable from browsers (although it'll take plenty of time: more changes in OpenSSL, plus time to migrate Node to those versions). There'll always be more tiny fingerprinting differences elsewhere of course, but there's also a limit to how strict most servers can be since they need to avoid e.g. unexpectedly blocking new browser releases. |
Node.js Version
v22.12.0
NPM Version
10.9.0
Operating System
Linux amezin-laptop.home.arpa 6.12.4-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Mon, 09 Dec 2024 14:30:31 +0000 x86_64 GNU/Linux
Subsystem
https
Description
await fetch('https://www.php.net')
Result:
When I do the same
await fetch('https://www.php.net')
innodejs-lts-iron-20.18.1-1
, ornodejs-23.4.0-1
, provided by Arch Linux, I get:Also the page opens successfully in Firefox, curl successfully downloads it.
Why does it happen and can it be fixed?
Minimal Reproduction
No response
Output
No response
Before You Submit
The text was updated successfully, but these errors were encountered: