Skip to content

fix(grok): keep the proxy override on Grok's own hosts - #55

Merged
Adolanium merged 2 commits into
mainfrom
fix/53-pin-grok-host
Oct 25, 2026
Merged

Adolanium merged 2 commits into
mainfrom
fix/53-pin-grok-host

Conversation

@Adolanium

Copy link
Copy Markdown
Owner

GROK_CLI_CHAT_PROXY_BASE_URL was used as the base for the Grok billing and settings calls with no check. Setting it would send the Grok CLI bearer token to any host. teknium1 raised this in the catalog re-review (#53, item 2).

The new _grok_proxy_base() honours the override only when it is https, its host is grok.com, x.ai or a subdomain of either, and it has no userinfo and no port other than 443. In every other case it returns empty and the probe uses the default https://cli-chat-proxy.grok.com/v1. I kept the override, not dropped it, so the Grok CLI's own staging and regional endpoints still work.

Tests: two new tests in test_grok_usage.py, run against both probe.py and catalog/desktop/probe.py. They record which host each request reaches. Seven rejected overrides all end up on cli-chat-proxy.grok.com: another domain, plain http, grok.com.attacker.example, evilgrok.com, userinfo, port 8443 and a malformed URL. Three accepted overrides reach their own host. Without the fix, 6 subtests fail and 2 error. All workflow steps pass locally:

  • the catalog check, test_catalog_policy, py_compile and node --check
  • both Python unittest groups, including the 14 Grok tests
  • 98 Node tests, plus 70 in catalog mode

Not tested against a live Grok account.

Refs #53

GROK_CLI_CHAT_PROXY_BASE_URL could point the Grok CLI token at any
host. The override is now honoured only for https URLs on grok.com,
x.ai or their subdomains, with no userinfo and no port other than 443.
Anything else is ignored and the default cli-chat-proxy.grok.com is
used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant