Skip to content

Write HTML. Render video. Built for agents.

fix(telemetry): require /proc/version confirmation for 4.4.0 gVisor

James1188814de292
diff --git a/packages/cli/src/telemetry/agent_runtime.test.ts b/packages/cli/src/telemetry/agent_runtime.test.ts
index b87cbea9ae..097a07518b 100644
--- a/packages/cli/src/telemetry/agent_runtime.test.ts
+++ b/packages/cli/src/telemetry/agent_runtime.test.ts
@@ -191,12 +191,40 @@ describe("detectSandboxRuntime — kernel-string path", () => {
expect(detectSandboxRuntime()).toBe("gvisor");
});
- it("reports gvisor for the legacy 4.4.0 Sentry kernel string", async () => {
+ it("reports gvisor for kernel 4.4.0 only when /proc/version confirms gVisor", async () => {
vi.doMock("node:os", async () => {
const actual = await vi.importActual<typeof import("node:os")>("node:os");
return { ...actual, release: () => "4.4.0", platform: () => "linux" };
});
+ vi.doMock("node:fs", async () => {
+ const actual = await vi.importActual<typeof import("node:fs")>("node:fs");
+ return {
+ ...actual,
+ readFileSync: (path: string) =>
+ path === "/proc/version" ? "Linux version 4.4.0 (gVisor)" : actual.readFileSync(path),
+ };
+ });
const { detectSandboxRuntime } = await import("./agent_runtime.js");
expect(detectSandboxRuntime()).toBe("gvisor");
});
+
+ it("does NOT report gvisor for kernel 4.4.0 on a real Ubuntu 16.04 box (no gVisor in /proc/version)", async () => {
+ // Ubuntu 16.04 LTS ships kernel 4.4.0 too — make sure we don't false-positive.
+ vi.doMock("node:os", async () => {
+ const actual = await vi.importActual<typeof import("node:os")>("node:os");
+ return { ...actual, release: () => "4.4.0", platform: () => "linux" };
+ });
+ vi.doMock("node:fs", async () => {
+ const actual = await vi.importActual<typeof import("node:fs")>("node:fs");
+ return {
+ ...actual,
+ readFileSync: (path: string) =>
+ path === "/proc/version"
+ ? "Linux version 4.4.0-1128-aws (buildd@lcy01)"
+ : actual.readFileSync(path),
+ };
+ });
+ const { detectSandboxRuntime } = await import("./agent_runtime.js");
+ expect(detectSandboxRuntime()).not.toBe("gvisor");
+ });
});
diff --git a/packages/cli/src/telemetry/agent_runtime.ts b/packages/cli/src/telemetry/agent_runtime.ts
index 23c4a77c4e..9f8f922c82 100644
--- a/packages/cli/src/telemetry/agent_runtime.ts
+++ b/packages/cli/src/telemetry/agent_runtime.ts
@@ -160,15 +160,19 @@ export function detectAgentRuntime(): AgentRuntime {
/**
* gVisor reports kernel string `4.19.0-gvisor` (current) or `4.4.0` (legacy
- * Sentry kernel). Both are unambiguous: no production Linux box reports
- * either today. /proc/version is the backup signal.
+ * Sentry kernel).
+ *
+ * `4.19.0-gvisor` is unambiguous — no real Linux box reports that string.
+ * `4.4.0` collides with Ubuntu 16.04 LTS / older real kernels, so we only
+ * accept it as a gVisor signal when /proc/version ALSO contains "gVisor".
*/
function isGVisor(): boolean {
const kernel = release();
- if (kernel === "4.4.0" || kernel.includes("gvisor")) return true;
+ if (kernel.includes("gvisor")) return true;
if (platform() !== "linux") return false;
try {
- return readFileSync("/proc/version", "utf-8").includes("gVisor");
+ const procVersion = readFileSync("/proc/version", "utf-8");
+ return procVersion.includes("gVisor");
} catch {
return false;
}