Skip to content

🐛 [RUM-SR] Mask <video poster> under MASK privacy levels - #5297

Open
kcro303913 wants to merge 2 commits into
mainfrom
kaleb.cross/mask-video-poster
Open

kcro303913 wants to merge 2 commits into
mainfrom
kaleb.cross/mask-video-poster

Conversation

@kcro303913

Copy link
Copy Markdown

Motivation

A customer with Session Replay enabled and the default defaultPrivacyLevel: 'mask'
reported that the image on a <video> element rendered unmasked in the replay.

The culprit is the poster attribute. shouldMaskAttribute() masks <img src/srcset>
and <source src/srcset>, but never <video poster>. A poster is an image (very often
a data: URL embedding an actual frame/screenshot) rendered in the video's box before
playback, so leaving it unmasked leaks user data exactly like an unmasked <img src>.

Changes

Treat <video poster> like <img src>:

  • privacy.ts — shouldMaskAttribute() now returns true for VIDEO/poster under the
    mask and mask-unless-allowlisted levels.
  • serializeAttribute.ts — when masked, emit a censored placeholder sized to the video's
    bounding box (censoredImageForSize), falling back to CENSORED_IMG_MARK when the size
    is unknown, so the replay keeps the video's layout.

Behavior matches the existing <img src> contract: unmasked under allow/mask-user-input,
dropped under hidden, masked under mask/mask-unless-allowlisted.

Test instructions

  1. On a page with DD_RUM.init({ ..., defaultPrivacyLevel: 'mask' }) and Session Replay on,
    add <video poster="data:image/png;base64,...">.
  2. Record a session and open the replay — the poster now renders as a silver placeholder
    sized to the video, not the original image.

Unit tests added to serializeAttributes.spec.ts (<video poster> → maskable-image,
<div poster> → always-unmasked). Ran locally:

  • serializeAttributes.spec.ts — 13/13 pass
  • privacy.spec.ts — 88/88 pass

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@kcro303913
kcro303913 requested review from a team as code owners November 18, 2026 17:03
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

The `poster` attribute on <video> elements was never masked. Under the
default `mask` privacy level this leaks the poster image — often a data
URL embedding an actual frame/screenshot — into Session Replay, exactly
like an unmasked <img src>.

Treat `<video poster>` like `<img src>`: flag it in shouldMaskAttribute()
and, when masked, emit a size-matched censored placeholder so the replay
keeps the video's layout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@datadog-official

datadog-official Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 58.33%
• Overall Coverage: 77.92% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 624ed2a | Docs | View more details | Give us feedback!

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 192.85 KiB 192.87 KiB +27 B +0.01% ✅
Rum 192.82 KiB 192.85 KiB +27 B +0.01% ✅
Rum Salesforce Profiler 8.01 KiB 8.01 KiB 0 B 0.00% ✅
Rum Profiler 8.01 KiB 8.01 KiB 0 B 0.00% ✅
Rum Salesforce Recorder 32.62 KiB 33.02 KiB +409 B +1.22% ✅
Rum Recorder 32.62 KiB 33.02 KiB +409 B +1.22% ✅
Logs 60.25 KiB 60.25 KiB 0 B 0.00% ✅
Rum Slim 148.67 KiB 148.70 KiB +27 B +0.02% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 224.18 KiB 224.61 KiB +436 B +0.19% ✅
Rum Shopify Profiler 8.00 KiB 8.00 KiB 0 B 0.00% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 0 B 0.00% ✅

@kcro303913
kcro303913 force-pushed the kaleb.cross/mask-video-poster branch from 4f461d0 to 930c413 Compare November 18, 2026 17:09
@kcro303913

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

Videos sized by their posters can grow in replay because the masked placeholder includes borders, padding, and CSS transforms in its intrinsic dimensions.

Open Bits AI session

🤖 Bits Code Review · Commit 930c413

…Attribute.ts

Co-authored-by: datadog-official[bot] <214633350+datadog-official[bot]@users.noreply.github.com>

@datadog-official datadog-official Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

The PR masks video posters under mask and mask-unless-allowlisted privacy levels. The follow-up fixes the earlier border, padding, and transform sizing regression by using content-box dimensions; focused browser checks confirm layout preservation, and no findings remain open.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 624ed2a

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant