Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- fix(mitm): forward passthrough traffic to the actual requested Host instead of misrouting every non-TARGET_HOSTS request to the hardcoded Antigravity sandbox host (#10479)
9 changes: 8 additions & 1 deletion src/mitm/server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,14 @@ function getTargetHost(req) {
const host = String(req.headers.host || "")
.split(":")[0]
.toLowerCase();
return TARGET_HOSTS.has(host) ? host : "daily-cloudcode-pa.sandbox.googleapis.com";
// #10479: the non-TARGET_HOSTS branch used to hardcode a fallback host — in
// the original Antigravity DNS-spoof flow, req.headers.host is always a
// TARGET_HOSTS member, so it was dead code. The passthrough() call path
// added for transparent-redirect/HTTP-proxy clients can reach ANY internet
// host, so the real requested Host header must always be forwarded, never
// a hardcoded default (which silently misrouted every non-TARGET_HOSTS
// request to an unrelated backend).
return host;
}

async function resolveTargetIP(targetHost) {
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/mitm-passthrough-real-host-10479.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import url from "node:url";

const here = path.dirname(url.fileURLToPath(import.meta.url));
const serverPath = path.resolve(here, "../../src/mitm/server.cjs");
const src = fs.readFileSync(serverPath, "utf-8");

test("issue #10479: getTargetHost() must not reroute unknown/passthrough hosts to the hardcoded Antigravity default", () => {
const fnMatch = src.match(/function getTargetHost\(req\) \{[\s\S]*?\n\}/);
assert.ok(fnMatch, "getTargetHost() must exist in server.cjs");
const fnBody = fnMatch[0];
assert.doesNotMatch(
fnBody,
/:\s*"daily-cloudcode-pa\.sandbox\.googleapis\.com"/,
"getTargetHost() must not hardcode the Antigravity sandbox host as the " +
"fallback target for hosts outside TARGET_HOSTS — passthrough traffic " +
"for e.g. example.org must be forwarded to example.org, not to Google's " +
"Cloud Code API (issue #10479)"
);
});
Loading