Skip to content

Commit 0e3550c

Browse files
committed
fix(telemetry): never attach operator collector credentials to browser events
/api/telemetry relays unauthenticated input, so sending it with OTEL_EXPORTER_OTLP_HEADERS let anyone write spans into the operator's authenticated collector. Browser events now go only to TELEMETRY_ENDPOINT or the configured anonymous collector, without credentials; the server's own export keeps using the operator's collector.
1 parent 7d01d20 commit 0e3550c

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

‎apps/sim/app/api/telemetry/route.ts‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ import { parseRequest } from '@/lib/api/server'
77
import { isProd } from '@/lib/core/config/env-flags'
88
import { enforceIpRateLimit } from '@/lib/core/rate-limiter'
99
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
10-
import {
11-
isTelemetryDisabled,
12-
normalizeOtlpTracesUrl,
13-
resolveOtlpTarget,
14-
} from '@/lib/monitoring/otlp'
10+
import { isTelemetryDisabled, normalizeOtlpTracesUrl } from '@/lib/monitoring/otlp'
1511
import telemetryConfig from '@/telemetry.config'
1612

1713
const logger = createLogger('TelemetryAPI')
@@ -58,8 +54,9 @@ function createSafeAttributes(
5854
}
5955

6056
/**
61-
* Forwards a browser telemetry event as one span to the collector the server's own OpenTelemetry
62-
* export uses, and not at all when the operator turned telemetry off.
57+
* Forwards a browser telemetry event as one span, and not at all when the operator turned telemetry
58+
* off. Browser events are unauthenticated input, so they never travel with the operator's
59+
* collector credentials: they go to `TELEMETRY_ENDPOINT` or the configured anonymous collector.
6360
*/
6461
async function forwardToCollector(data: Record<string, unknown>): Promise<boolean> {
6562
if (!data || typeof data !== 'object') {
@@ -68,8 +65,9 @@ async function forwardToCollector(data: Record<string, unknown>): Promise<boolea
6865
}
6966
if (isTelemetryDisabled()) return false
7067

71-
const target = resolveOtlpTarget(telemetryConfig.endpoint)
72-
const endpoint = normalizeOtlpTracesUrl(target.endpoint)
68+
const endpoint = normalizeOtlpTracesUrl(
69+
process.env.TELEMETRY_ENDPOINT || telemetryConfig.endpoint
70+
)
7371
const timeout = DEFAULT_TIMEOUT
7472

7573
try {
@@ -124,7 +122,6 @@ async function forwardToCollector(data: Record<string, unknown>): Promise<boolea
124122
const options = {
125123
method: 'POST',
126124
headers: {
127-
...target.headers,
128125
'Content-Type': 'application/json',
129126
},
130127
body: JSON.stringify(payload),

0 commit comments

Comments
 (0)