Repository navigation
fix: beat Cloudflare TLS-fingerprint challenge with a curl_cffi egress sidecar - #10
Merged
NextLevelManagementAdvisors merged 2 commits intoAug 20, 2026
Merged
Conversation
Cloudflare bot management on api.turnoverbnb.com classifies on the TLS/HTTP2 fingerprint, so Node's fetch got 403 + cf-mitigated:challenge on every request, credentials or not. curl_cffi impersonating Chrome gets a clean 401 from the same host in the same second; WARP egress and IPv4-vs-IPv6 make no difference, so it is not IP reputation. - egress/: pinned single-upstream curl_cffi passthrough, compose-network only - TurnoClient rewrites the Turno host to the sidecar per request, because each bearer carries its own base URL in its JWT (an env swap misses live bearers) - log giving-up outbound failures at warn; the outage produced zero log lines - correct TurnoCloudflareError to name the fingerprint cause, not the IP - CLAUDE.md: drop the stale "no Docker" / "no test suite" notes Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MRNHYDXanAxEQHJWVMbbCn
4 tasks done
#9 landed the same cf-ray fix from the other side. Kept its precedence (the response header is authoritative, body scrape is the fallback) and this branch's header-tolerant read, warn-level logging, and header-aware challenge detection. Also fixes lowerCaseHeaders against a get-only headers shim: it exposes no enumerable entries, so every header read came back undefined. #9's new test uses exactly that shape and caught it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MRNHYDXanAxEQHJWVMbbCn
NextLevelManagementAdvisors
deleted the
fix/cloudflare-fingerprint-egress
branch
August 20, 2026 04:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #7, which correctly stopped blaming credentials for a Cloudflare 403 but attributed it to egress-IP reputation and advised routing through WARP. Measurement says otherwise, and the recommended workaround does not work.
What is actually happening
Cloudflare bot management on
api.turnoverbnb.comclassifies on the TLS/HTTP2 fingerprint, not the IP. From one VPS, same second, same request:fetch(undici)403+cf-mitigated: challengecurl403+cf-mitigated: challengecurlvia WARP (socks5://127.0.0.1:40000)403+cf-mitigated: challengecurl -4/curl -6403both wayscurl_cffiimpersonating Chrome401 {"error":"Unauthenticated."}The 401 is the correct answer to a request carrying no valid credentials, so the API is fully reachable once the fingerprint looks like a browser. Confirmations: the whole zone is affected (
/andapi.turno.comtoo), it is not rate-limited or intermittent (5/5 challenged), and it hits unauthenticated requests, so it cannot be credential-related.This blocked the live
turno.nlma.ioOAuth enrollment: every attempt rendered "Turno rejected these credentials (HTTP 403)" against a valid Secret Key.Changes
egress/— a pinned, single-upstreamcurl_cffipassthrough. Replays each request with a browser fingerprint and returns the upstream status and body verbatim, soTurnoClient's retry ladder and error surfacing keep working untouched. Upstream is pinned by env and only origin-form paths are accepted, so it is not usable as an SSRF pivot; no published port, compose network only.TurnoClientrewrites the Turno host to the sidecar per request (applyEgress). Deliberately not aTURNO_BASE_URLswap: every bearer carries its own base URL in its JWTbclaim, so an env change would silently fix only newly issued bearers and leave every live one broken.debug, and the challenge atinfo. On a server runningLOG_LEVEL=infothe outage produced zero log lines, which cost most of the debugging time. Both arewarnnow.TurnoCloudflareError— message corrected to name the fingerprint cause and point atTURNO_EGRESS_URL; the old text sends operators to WARP, which is also challenged. Detection now also acceptscf-mitigated: challenge, which survives Cloudflare reformatting its interstitial, and picks upcf-rayfrom the response header when the body has nocRay.validateTurnoCredentialshandlesTurnoCloudflareErrorexplicitly so the form says "not your keys, do not rotate them" instead of falling through to a generic "Couldn't reach Turno".CLAUDE.md— dropped two stale notes that actively misled this debugging session: "No Docker. Don't add Dockerfile/compose deploy paths" (the service has been containerized since cbe39cc, and there is noturno-mcp.service) and "There is no test suite yet". Documented the Cloudflare behavior and the/opt/turno-mcp-is-not-a-git-checkout deploy path.Validation
npm run typecheckandnpm testclean (41 tests, including the 3 from #7). Deployed and verified on the VPS:turno-egress/_healthreachable from insideturno-mcpGET /v2/userinfowith garbage creds through the full container path:401 {"error":"Unauthenticated."}(was403challenge)POST /oauth/authorizewith a bogus token now renders "rejected these credentials (HTTP 401)" and logsstatus:401at warn400 {"error":"egress: only origin-form paths are proxied"}Durability
Fingerprint impersonation is an arms race: Cloudflare eventually flags stale fingerprints.
EGRESS_IMPERSONATEis env-tunable without a rebuild, and the sidecar logschallenge SURVIVED impersonate=...at warn when a bump is needed. The real fix is Turno excluding partner-token/v2traffic from bot management, which is worth raising with their support.Note: CI here fails in ~4s with
startup_failureon every run (no Actions billing on this account), so the green/red signal is meaningless; validation above was run locally and on the VPS.🤖 Generated with Claude Code
https://claude.ai/code/session_01MRNHYDXanAxEQHJWVMbbCn