fix: correct x-statsig-id format to bypass anti-bot rules#567
Merged
Conversation
The grok.com frontend's fetch interceptor generates x-statsig-id by
running a Statsig SDK evaluation per request. When that evaluation
fails (headless, first paint, etc.), it falls back to:
btoa("x1:" + error.toString())
The old code used the prefix "e:" instead of "x1:", which Grok's
anti-bot now detects and rejects with HTTP 403.
Verified against 3 SSO tokens — all return 200 on app-chat endpoints.
Fixes chenyme#562
c8e4a2d to
7015258
Compare
Closed
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.
Problem
Grok's website added new anti-bot controls (issue #562). All HTTP API endpoints except WebSocket
imaginereturn:Root Cause
Grok's frontend JavaScript intercepts every
fetchcall and computes thex-statsig-idheader via a Statsig SDK evaluation. When that evaluation fails (headless, first paint, etc.), it falls back to:The old code generated values with the prefix
e:(e.g.e:TypeError: Cannot read properties of undefined...), but the real browser uses the prefixx1:(e.g.x1:TypeError: ...). Grok's server validates this prefix and rejects anything else.Fix
Changed the prefix in
_statsig_id()frome:tox1:, matching exactly what the real browser's fetch interceptor produces as a Statsig evaluation fallback. Thedynamic_statsigconfig toggle is now effectively always-on (each request gets a randomized error variable name).Validation
Tested directly against
grok.com/rest/app-chat/conversations/newwith 3 different SSO tokens — all returned 200 where they previously returned 403. Also deployed to local Docker and confirmed the service works end-to-end.Fixes #562