Security rules
NGB067: Sensitive data sent to analytics
Reports sensitive values passed to product-analytics and session-replay SDKs: credentials and payment data sent to Segment, Mixpanel, Amplitude, PostHog (identify / register), Heap, LogRocket, FullStory, Datadog RUM (setUser), New Relic, Hotjar / Clarity (medium severity), and personal data — e-mail addresses, phone numbers, dates of birth, national IDs, IBANs — placed in event payloads of those SDKs, Google Analytics gtag() / dataLayer.push() and Application Insights trackEvent() (low severity).
| Property | Value |
|---|---|
| Rule ID | NGB067 |
| Category | Sensitive data & payment security |
| Default severity | medium |
| CWE | CWE-359, CWE-201 |
| Built-in presets | recommended: warn, strict: error |
Confidence is reported per finding (high, medium, low) and is independent of severity. See Reading findings.
What it checks
Reports sensitive values passed to product-analytics and session-replay SDKs: credentials and payment data sent to Segment, Mixpanel, Amplitude, PostHog (identify / register), Heap, LogRocket, FullStory, Datadog RUM (setUser), New Relic, Hotjar / Clarity (medium severity), and personal data — e-mail addresses, phone numbers, dates of birth, national IDs, IBANs — placed in event payloads of those SDKs, Google Analytics gtag() / dataLayer.push() and Application Insights trackEvent() (low severity). Credentials in gtag, dataLayer, Sentry, PostHog capture, Datadog addAction and Application Insights events are reported by NGB016 and not repeated here.
Why it matters
Analytics events are copied to third-party processors, retained for years, exported to warehouses and visible to marketing staff — none of which are cleared to hold passwords, tokens or card data. Personal data in event properties breaks most analytics terms (Google Analytics forbids PII), creates GDPR / CCPA processing you did not declare, and cannot be selectively deleted afterwards. User-identification APIs (identify, setUser) exist for user IDs and traits; personal data there is a policy decision and is not reported.
Detection behavior and supported patterns
analytics.track/page/identify()(Segment),mixpanel.track/identify/register()/mixpanel.people.set(),amplitude.track/logEvent/setUserId()and named imports from@amplitude/*,posthog.capture/identify/register(),heap.track/identify(),LogRocket.identify/track(),FS.identify/event(),datadogRum.setUser/addAction(),newrelic.addPageAction/setCustomAttribute(),appInsights.trackEvent(),gtag(),dataLayer.push(),hj(),clarity()- Credentials / payment data: value name, type properties, names along the data flow (shared sensitivity model of NGB014–NGB016)
- Personal data: names such as
email,phoneNumber,dateOfBirth,ssn,iban,passportNumberon the value or the keys of an inline payload object
Example
analytics.track('Signed Up', { email: form.email, password: form.password });Safer alternative
analytics.track('Signed Up', { plan: form.plan }); // identify(userId) with an opaque IDRemediation
Send opaque, stable user IDs and coarse attributes (plan, country) instead of personal data; never send tokens, passwords or card data. Strip query strings with tokens before page tracking and enable the SDK's input masking / PII redaction options.
False-positive considerations
- Hashed or pseudonymized identifiers named
emailare reported unless the expression visibly hashes or masks them. - Self-hosted analytics with a data-processing agreement covering personal data may accept e-mail addresses; document an exception.
Known limitations
- SDKs wrapped in a project analytics service are only recognized at the SDK call, not at the wrapper.
- Automatic collection (URL capture, autocapture of input fields, session replay recordings) is configured in the SDK and is not analyzed.
References
Run it
ngbastion explain NGB067