Skip to content

Commit 51ccd5e

Browse files
authored
fix(aio): drop the OTLP telemetry token from process env after reading it
The sandbox delivers POSTHOG_AGENT_OTEL_LOGS_TOKEN via the container environment, which agent-spawned tool subprocesses inherit - so any `env` dump in a persisted transcript or PR body would leak the key (flagged by review bots on PostHog/posthog#71100). bin.ts is the only consumer: parse it into the server config, then delete it from process.env so children never see it. Defense in depth, not a boundary - same-UID processes can still read the container's initial env via /proc; the key itself remains a write-only capture token scoped to a dedicated telemetry project. No test: a one-line env mutation at the CLI entry with no cheap seam; exercising it would mean spawning the CLI end to end. Generated-By: PostHog Code Task-Id: 0c511836-2180-455a-9b58-45df2a0661ec
1 parent 18df0f6 commit 51ccd5e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • packages/agent/src/server

packages/agent/src/server/bin.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ program
170170

171171
const env = envResult.data;
172172

173+
// The telemetry token is only ever consumed here (into the server config);
174+
// drop it from the process environment so tool subprocesses spawned by the
175+
// agent don't inherit it and `env` dumps in persisted transcripts or PR
176+
// bodies can't leak it. Defense in depth, not a boundary: same-UID
177+
// processes can still read the container's initial env via /proc.
178+
delete process.env.POSTHOG_AGENT_OTEL_LOGS_TOKEN;
179+
173180
const mode = options.mode === "background" ? "background" : "interactive";
174181
const createPr = parseBooleanOption(options.createPr, "--createPr");
175182
const autoPublish = parseBooleanOption(

0 commit comments

Comments
 (0)