@@ -6,6 +6,11 @@ import type { RequestEventData } from '../types/request';
66import type { WebFetchHeaders , WebFetchRequest } from '../types/webfetchapi' ;
77import { debug } from './debug-logger' ;
88import { safeUnref } from './timer' ;
9+ import {
10+ PII_HEADER_SNIPPETS ,
11+ SENSITIVE_COOKIE_NAME_SNIPPETS ,
12+ SENSITIVE_KEY_SNIPPETS ,
13+ } from '../utils/data-collection/filtering-snippets' ;
914
1015/**
1116 * Maximum size of incoming HTTP request bodies attached to events.
@@ -258,67 +263,6 @@ function getAbsoluteUrl({
258263 return undefined ;
259264}
260265
261- const SENSITIVE_HEADER_SNIPPETS = [
262- 'auth' ,
263- 'token' ,
264- 'secret' ,
265- 'session' , // for the user_session cookie
266- 'password' ,
267- 'passwd' ,
268- 'pwd' ,
269- 'key' ,
270- 'jwt' ,
271- 'bearer' ,
272- 'sso' ,
273- 'saml' ,
274- 'csrf' ,
275- 'xsrf' ,
276- 'credentials' ,
277- // Always treat cookie headers as sensitive in case individual key-value cookie pairs cannot properly be extracted
278- 'set-cookie' ,
279- 'cookie' ,
280- ] ;
281-
282- /**
283- * Extra substrings matched only against individual Cookie / Set-Cookie **names** (not header names),
284- * so we can cover common session secrets that do not match {@link SENSITIVE_HEADER_SNIPPETS}
285- * (e.g. `connect.sid` does not contain `session`) without false positives on arbitrary HTTP headers.
286- *
287- * Cookie names are checked with the same `includes()` list as headers plus these entries; omit redundant
288- * cookie-only snippets that are already implied by a header match (e.g. `oauth` → `auth`, `id_token` → `token`,
289- * `next-auth` → `auth`).
290- */
291- const SENSITIVE_COOKIE_NAME_SNIPPETS = [
292- // Express / Connect default session cookie
293- '.sid' ,
294- // Opaque session ids (PHPSESSID, ASPSESSIONID*, BIGipServer*, *sessid*, …)
295- 'sessid' ,
296- // Laravel etc. "remember me" tokens
297- 'remember' ,
298- // OIDC / OAuth auxiliary (`oauth*` covered by header snippet `auth`)
299- 'oidc' ,
300- 'pkce' ,
301- 'nonce' ,
302- // RFC 6265bis high-security cookie name prefixes
303- '__secure-' ,
304- '__host-' ,
305- // Load balancer / CDN sticky-session cookies (opaque routing tokens)
306- 'awsalb' ,
307- 'awselb' ,
308- 'akamai' ,
309- // BaaS / IdP session cookies (names often omit "session")
310- '__stripe' ,
311- 'cognito' ,
312- 'firebase' ,
313- 'supabase' ,
314- 'sb-' ,
315- // Step-up / MFA cookies
316- 'mfa' ,
317- '2fa' ,
318- ] ;
319-
320- const PII_HEADER_SNIPPETS = [ 'x-forwarded-' , '-user' ] ;
321-
322266/**
323267 * Converts incoming HTTP request or response headers to OpenTelemetry span attributes following semantic conventions.
324268 * Header names are converted to the format: http.<request|response>.header.<key>
@@ -434,8 +378,8 @@ function handleHttpHeader(
434378 isCookieSubKey : boolean = false ,
435379) : string | undefined {
436380 const snippetsForSensitivity = isCookieSubKey
437- ? [ ...SENSITIVE_HEADER_SNIPPETS , ...SENSITIVE_COOKIE_NAME_SNIPPETS ]
438- : SENSITIVE_HEADER_SNIPPETS ;
381+ ? [ ...SENSITIVE_KEY_SNIPPETS , ...SENSITIVE_COOKIE_NAME_SNIPPETS ]
382+ : SENSITIVE_KEY_SNIPPETS ;
439383
440384 const isSensitive = sendPii
441385 ? snippetsForSensitivity . some ( snippet => lowerCasedKey . includes ( snippet ) )
0 commit comments