AIStudio2API icon indicating copy to clipboard operation
AIStudio2API copied to clipboard

[Bug] GenerateContent returns Code 7 when Go transport fingerprint diverges from Camoufox

Open DragonFSKY opened this issue 3 months ago • 0 comments

Summary

WAA-protected GenerateContent requests can be rejected with HTTP 403 / protocol code 7 even when the account, cookies, model access, request body, and WAA runtime are valid.

A controlled comparison shows that Google accepts the same request when it is sent by the account's configured Camoufox page, but rejects both an unconfigured Camoufox instance and the current Go HTTP transport.

AI Studio GenerateContent 返回 HTTP 403、协议错误码 7: The caller does not have permission

Reproduction

  1. Import or log in an account and start the generation service on current main.
  2. Confirm the account reaches ready and the WAA worker reaches WorkerReady.
  3. Send a minimal request with all optional tools disabled:
curl http://127.0.0.1:2048/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"gemini-3-flash-preview","messages":[{"role":"user","content":"Reply with exactly OK"}],"stream":false}'

Controlled comparison

The following matrix used the same account state, cookies, network exit, model, prompt, and disabled tools:

Request path Browser-visible fingerprint Result
Configured account Camoufox page Windows Firefox 152, Win32, webdriver=false HTTP 200
Unconfigured Camoufox page Linux UA containing Camoufox/152.0.4-beta.29 HTTP 403 / code 7
Current MakerSuiteHTTPTransport Go tls-client Firefox emulation HTTP 403 / code 7

The successful configured-browser response proves that this is not an account or model entitlement failure.

Findings

  • internal/aistudio/transport_browser.go starts from profiles.Firefox_148, changes the advertised version to 152, and adjusts only part of the ClientHello. The resulting TLS/HTTP2 fingerprint is not identical to the configured Firefox 152 Camoufox runtime.
  • The current header order also differs from the accepted browser request.
  • A fresh WAA snapshot must be generated after synchronizing the binding prompt into the official page state. Generating a proof without updating that state still produces a syntactically valid proof but the protected request is rejected.
  • After fixing the transport, speech requests still completed with finishReason=OTHER and no audio because the current wire sends a default maxOutputTokens and omits the official ## Transcript:\n prefix. The official TTS request omits that default and includes the prefix.

Expected behavior

GenerateContent should preserve the account worker's native Camoufox network and page fingerprint end to end, return a streaming response, and retain cancellation behavior. OpenAI speech requests should produce the same AUDIO wire shape as the official AI Studio TTS page.

Acceptance criteria

  • Minimal text generation returns HTTP 200 through the proxy.
  • Streaming Chat returns valid SSE and [DONE].
  • Client cancellation aborts the browser request without invalidating the worker.
  • POST /v1/audio/speech returns valid WAV/PCM audio for an available TTS model.
  • No account identifiers, cookies, authorization headers, WAA proofs, prompts, or raw private frames are logged or committed.

DragonFSKY avatar Aug 31 '26 16:08 DragonFSKY