15

Currently, there's a reproducible issue with Cloudflare blocking (via user/browser challenge as in this question) all API and WebSocket traffic from several sources. This is impacting the AI analysis tools that both I and another user have written for the Gen-AI Heuristics Group.

Other posts here about the issue seem to me to be related to authentication, but in this case very simple GET requests that don't require authentication are being blocked.

The problem is occurring with:

  • Nushell on Linux. E.g.:

    http get -ef https://api.stackexchange.com/2.3/answers?order=desc&sort=activity&site=stackoverflow
    
  • Python using websocket-client (the other user's system):

    import websocket
    socket = websocket.WebSocketApp("wss://qa.sockets.stackexchange.com")
    websocket.enableTrace(True)
    socket.run_forever()
    

This is reproducible from multiple systems and IP addresses, even on remote hosts which I've freshly created to reproduce the issue.

The API works from (oddly) Nushell for Windows as well as PowerShell (Invoke-WebRequest) and browsers.

In addition to trying a different system, I've tried:

  • Changing the User-Agent request header
  • With and without a key param on the API request
  • Creating a new StackApp registration and trying a new key

Did some new fingerprinting go into effect with Cloudflare and the SE API's that is blocking us?

The AI-Heuristic team could use some urgent assistance on getting back to normal, as we are losing data (I won't go into detail publicly on what) and hindered in our ability to review AI-generated content.

This code was previously running and stopped working (for me, via API GET) at 2:48 PM UTC, and for the other user (via websocket-client) around 3:25 PM UTC.


Additional debugging details from the websocket response:

--- request header ---
GET / HTTP/1.1
Upgrade: websocket
Host: qa.sockets.stackexchange.com
Origin: https://qa.sockets.stackexchange.com
Sec-WebSocket-Key: gOhJJXt1D2r6VUcUPYHFeQ==
Sec-WebSocket-Version: 13
Connection: Upgrade


-----------------------
--- response header ---
HTTP/1.1 403 Forbidden
Date: Tue, 09 Jul 2024 22:15:04 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 15598
Connection: close
Accept-CH: Sec-CH-UA-Bitness, Sec-CH-UA-Arch, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Platform, Sec-CH-UA, UA-Bitness, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform-Version, UA-Platform, UA
Critical-CH: Sec-CH-UA-Bitness, Sec-CH-UA-Arch, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Platform, Sec-CH-UA, UA-Bitness, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform-Version, UA-Platform, UA
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin
Origin-Agent-Cluster: ?1
Permissions-Policy: accelerometer=(),autoplay=(),browsing-topics=(),camera=(),clipboard-read=(),clipboard-write=(),geolocation=(),gyroscope=(),hid=(),interest-cohort=(),magnetometer=(),microphone=(),payment=(),publickey-credentials-get=(),screen-wake-lock=(),serial=(),sync-xhr=(),usb=()
Referrer-Policy: same-origin
X-Content-Options: nosniff
X-Frame-Options: SAMEORIGIN
cf-mitigated: challenge
cf-chl-out: LHO4XpX09AwG8Mlp4gzWLOc2jNeIohU6DY5X/rqfSE6KB56afHQPE10lfxQjJTH02e5+U1zRk1uG1Dmf4uC36gwMErb5wUYoKLiGdgDV3cR9vpyZNRYRG9MLVP04a480oICZGs1juv4WJbChUF4mhw==$U9e7rmVNAXg4fcYa2H5IBw==
Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Set-Cookie: __cf_bm=Y3xQzwwFzwN9JTBowBao6p0hFfXy5TVXBazDqQQ_oFE-1720563304-1.0.1.1-WU76lEBQTdjMlxsW_ArVirEbsq6XkEQ8N3QQyuauLjAf1HeLHRxZFUisSYMVPVz.GgEbuLNc72rMKmHX7pwQjQ; path=/; expires=Tue, 09-Jul-24 22:45:04 GMT; domain=.qa.sockets.stackexchange.com; HttpOnly; Secure
Server: cloudflare
CF-RAY: 8a0babac2d18bf7c-ATL
-----------------------
Handshake status 403 Forbidden -+-+- {'date': 'Tue, 09 Jul 2024 22:15:04 GMT', 'content-type': 'text/html; charset=UTF-8', 'content-length': '15598', 'connection': 'close', 'accept-ch': 'Sec-CH-UA-Bitness, Sec-CH-UA-Arch, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Platform, Sec-CH-UA, UA-Bitness, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform-Version, UA-Platform, UA', 'critical-ch': 'Sec-CH-UA-Bitness, Sec-CH-UA-Arch, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Platform, Sec-CH-UA, UA-Bitness, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform-Version, UA-Platform, UA', 'cross-origin-embedder-policy': 'require-corp', 'cross-origin-opener-policy': 'same-origin', 'cross-origin-resource-policy': 'same-origin', 'origin-agent-cluster': '?1', 'permissions-policy': 'accelerometer=(),autoplay=(),browsing-topics=(),camera=(),clipboard-read=(),clipboard-write=(),geolocation=(),gyroscope=(),hid=(),interest-cohort=(),magnetometer=(),microphone=(),payment=(),publickey-credentials-get=(),screen-wake-lock=(),serial=(),sync-xhr=(),usb=()', 'referrer-policy': 'same-origin', 'x-content-options': 'nosniff', 'x-frame-options': 'SAMEORIGIN', 'cf-mitigated': 'challenge', 'cf-chl-out': 'LHO4XpX09AwG8Mlp4gzWLOc2jNeIohU6DY5X/rqfSE6KB56afHQPE10lfxQjJTH02e5+U1zRk1uG1Dmf4uC36gwMErb5wUYoKLiGdgDV3cR9vpyZNRYRG9MLVP04a480oICZGs1juv4WJbChUF4mhw==$U9e7rmVNAXg4fcYa2H5IBw==', 'cache-control': 'private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'expires': 'Thu, 01 Jan 1970 00:00:01 GMT', 'set-cookie': '__cf_bm=Y3xQzwwFzwN9JTBowBao6p0hFfXy5TVXBazDqQQ_oFE-1720563304-1.0.1.1-WU76lEBQTdjMlxsW_ArVirEbsq6XkEQ8N3QQyuauLjAf1HeLHRxZFUisSYMVPVz.GgEbuLNc72rMKmHX7pwQjQ; path=/; expires=Tue, 09-Jul-24 22:45:04 GMT; domain=.qa.sockets.stackexchange.com; HttpOnly; Secure', 'server': 'cloudflare', 'cf-ray': '8a0babac2d18bf7c-ATL'} -+-+- b'<!DOCTYPE html><html lang="en-US"><head><title>Just a moment...</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=Edge"><meta name="robots" content="noindex,nofollow"><meta name="viewport" content="width=device-width,initial-scale=1"><style>*{box-sizing:border-box;margin:0;padding:0}html{line-height:1.15;-webkit-text-size-adjust:100%;color:#313131}button,html{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}@media (prefers-color-scheme:dark){body{background-color:#222;color:#d9d9d9}body a{color:#fff}body a:hover{color:#ee730a;text-decoration:underline}body .lds-ring div{border-color:#999 transpar' - goodbye
True
1
  • 4
    Updated to status-planned. Josh is working with the CMs on a fix.
    – Rosie StaffMod
    Commented Jul 10 at 14:26

1 Answer 1

10

Thanks for including the full response, it helped quickly identify the issue. We have been fighting a botnet that has been creating a large amount of fake accounts, unfortunately the code your team is running was also caught by one of the countermeasures that was implemented yesterday.

Edit: We found a better solution than the original fix that doesn't need any changes on your end and have pushed it out. Your code should not encounter any blocks now.

13
  • 2
    Is there a delay needed for your change to propagate? Both the other user and I are still experiencing the issue. Commented Jul 10 at 16:34
  • 2
    @NotTheDr01ds Are y'all hitting the path /ai/queries? The block events went to zero after we pushed the change at 11:45 AM Eastern.
    – Josh Zhang StaffMod
    Commented Jul 10 at 17:56
  • I'm using the same examples (endpoint /2.3/answers) as in the original question). Not sure about /ai/queries - Was that the workaround that we were going to get? Commented Jul 10 at 18:00
  • I also retested with the Python code above (on a newly provisioned virtual host) and failed as well with the same results. Commented Jul 10 at 18:01
  • In case it helps, I just hit https://api.stackexchange.com/2.3/answers?order=desc&sort=activity&site=stackoverflow about 5 times in 10 seconds to see if it shows up in your logs. Commented Jul 10 at 18:04
  • And in cases it helps, it's not just API. Just a basic http get https://stackoverflow.com is challenged as well, but of course that might be expected - API shouldn't be. Commented Jul 10 at 18:07
  • 1
    I suspect the failed attempts have triggered Cloudflare's higher level anti-botnet defenses. I didn't carve out that route but rather the inverse, sorry can't get into too much details. I'll keep digging to find the culprit.
    – Josh Zhang StaffMod
    Commented Jul 10 at 18:10
  • 1
    If you want to create a private chat, I can pull the other user in as well (or you can join us in AI Domination chat). Keep in mind that the newly created cloud-virtual host had no prior failed attempts, so it's not something at the IP-address level. Commented Jul 10 at 18:14
  • BTW, I've temporarily shifted my code over to Nushell on Windows, so I'm hobbling with duct-tape for now and at least not losing data. The other user doesn't have a workaround, though. Commented Jul 10 at 18:17
  • 1
    We can do a private chat but I'm fairly busy the rest of the day, can we do async through e-mail? jzhang1@SO
    – Josh Zhang StaffMod
    Commented Jul 10 at 18:27
  • @NotTheDr01ds oh one thing that's not new but since I noticed in the original result, Cloudflare will block requests that don't have a User-Agent, that's always been the case for the main site but it was hit or miss depending on which part of the site.
    – Josh Zhang StaffMod
    Commented Jul 10 at 18:45
  • Ironically, I'm in the middle of some migration of my personal e-mail at the moment. I could make it work, but private chat would be best. Commented Jul 10 at 18:57
  • 2
    Private chat is fine, I just won't be super responsive for the rest of the day if that's ok. I'll check in when I can.
    – Josh Zhang StaffMod
    Commented Jul 10 at 19:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .