Skip to main content
TagManifest /Docs Dashboard

Base64 encoding used for PII

Detects Custom HTML tags using btoa() to encode data, which is trivially reversible and not a substitute for proper hashing.

On this page 6

Summary

  • rule_id — btoa-pii
  • purpose — Detect btoa() calls in Custom HTML tags that may be encoding PII
  • effect — Reversible "encoding" of user identifiers; not a substitute for hashing
  • layer — container
  • reversibility — non-destructive

What fires this

The rule checks active Custom HTML tags for codeAnalysis.hasBtoa, set by the parser when it detects a btoa( call in the tag code. Every tag with a btoa call is flagged — the rule does not distinguish PII encoding from legitimate uses (binary transport, opaque tokens). Manual triage is required when this rule fires. Paused tags are excluded.

Why it matters

Base64 is encoding, not encryption. btoa('user@example.com') produces dXNlckBleGFtcGxlLmNvbQ==, reversible in one step via atob(). Any platform, vendor, or breach recipient receiving the encoded value can recover the original PII. The combination of btoa in a tracking-tag context is a strong signal of an engineer encoding user identifiers before sending them to analytics. Use SHA-256 hashing for one-way transformation. Regulatory: GDPR Art. 5, Art. 32.

Before / after

dataLayer.push({
  user_id: btoa(user.email)  // reversible — flagged
})
const buf = await crypto.subtle.digest(
  'SHA-256',
  new TextEncoder().encode(user.email)
)
const hex = Array.from(new Uint8Array(buf))
  .map(b => b.toString(16).padStart(2, '0')).join('')

dataLayer.push({ user_id: hex })

Remediation

  1. Open each flagged tag and identify what is passed to btoa().
  2. Determine whether the value is a user identifier (email, user ID, phone) or non-PII (binary, opaque token).
  3. If PII: replace with SHA-256 (crypto.subtle.digest).
  4. If non-PII: add a code comment documenting the purpose.
  5. Verify the destination platform receives the correct hashed value.
  6. If the data should not be collected at all, remove the call.

Metadata

Severity
high
Tier
error
Category
pii
Layer
container
Version
1
Effort
2hr (about 2 hours)
Reversibility
non-destructive
Regulatory
GDPR Art. 5 (data minimization), GDPR Art. 32 (security of processing)

See also

Examples

Evaluate
curl https://developer.tagmanifest.com/v1/evaluate-rule \
  -H "Authorization: Bearer $TM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"rule_id":"btoa-pii","url":"https://example.com"}'