Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix(security): crypto-secure cloud-agent IDs + exact-hostname check (CodeQL #251, #252)
diegosouzapw34e62d872595
diff --git a/src/lib/cloudAgent/baseAgent.ts b/src/lib/cloudAgent/baseAgent.tsindex 9f5689b90b..0acf3cb475 100644--- a/src/lib/cloudAgent/baseAgent.ts+++ b/src/lib/cloudAgent/baseAgent.ts@@ -1,3 +1,4 @@+import { randomBytes } from "node:crypto";import type {CloudAgentTask,CloudAgentStatus,@@ -86,10 +87,12 @@ export abstract class CloudAgentBase {}protected generateTaskId(): string {- return `task_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;+ // Cryptographically secure suffix (not Math.random) — task IDs flow into+ // session/external identifiers, so they must be unpredictable (CodeQL js/insecure-randomness).+ return `task_${Date.now()}_${randomBytes(8).toString("hex")}`;}protected generateActivityId(): string {- return `act_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;+ return `act_${Date.now()}_${randomBytes(8).toString("hex")}`;}}diff --git a/tests/unit/antigravity-discovery-bootstrap.test.ts b/tests/unit/antigravity-discovery-bootstrap.test.tsindex 3d0aa82f98..11f8c43097 100644--- a/tests/unit/antigravity-discovery-bootstrap.test.ts+++ b/tests/unit/antigravity-discovery-bootstrap.test.ts@@ -152,7 +152,10 @@ describe("ensureAntigravityProjectAssigned", () => {const mockFetch = async (url: string, _init?: RequestInit): Promise<Response> => {hitUrls.push(url);- if (url.includes("daily-cloudcode-pa.googleapis.com")) {+ // Exact hostname match (not substring .includes) so the check can't be fooled by a+ // look-alike host like daily-cloudcode-pa.googleapis.com.evil.com (CodeQL+ // js/incomplete-url-substring-sanitization).+ if (new URL(url).hostname === "daily-cloudcode-pa.googleapis.com") {// First URL failsreturn new Response("not found", { status: 404 });}