fix(trace-viewer): neutralize object and embed tags in snapshot renderer#40761
Merged
pavelfeldman merged 2 commits intomicrosoft:mainfrom May 10, 2026
Merged
Conversation
Neutralize <object data> and <embed src> attributes in the snapshot renderer. Both can load arbitrary HTML in the trace viewer's origin via /sha1/ resources, bypassing the script and iframe sanitization added in microsoft#40655 and microsoft#40676. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
| attrName = '__playwright_' + attr.toLowerCase() + '__'; | ||
| } | ||
| if (upperName === 'OBJECT' && attr.toLowerCase() === 'data') { | ||
| // Neutralize <object data> - it can load arbitrary HTML in the trace |
Member
There was a problem hiding this comment.
Let's drop all thees "neutralize" comments, they are noise.
Contributor
Author
There was a problem hiding this comment.
Done, dropped all the comments.
pavelfeldman
approved these changes
May 10, 2026
Contributor
Test results for "MCP"2 failed 7055 passed, 1068 skipped Merge workflow run. |
Contributor
Test results for "tests 1"3 flaky41731 passed, 850 skipped Merge workflow run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<object data>and<embed src>in the snapshot renderer. Both can load arbitrary HTML in the trace viewer's origin, bypassing the script and iframe sanitization added in fix(trace-viewer): sanitize snapshot renderer against XSS from crafted traces #40655 and fix(trace-viewer): strip event handlers and neutralize IFRAME srcdoc/sandbox in snapshot renderer #40676.Attack scenario
A crafted trace can include a resource containing malicious HTML/JS with content type
text/html, and a snapshot referencing it via<object data="/sha1/<sha1>" type="text/html">. The service worker serves the resource at/sha1/with the attacker-controlled content type. The<object>tag renders it in a browsing context within the trace viewer's origin, giving the attacker full JS execution. This allows exfiltrating sensitive data from the trace (API keys, cookies, auth tokens from the tested application).<embed src>has the same issue. Althoughsrcis processed byrewriteURLForCustomProtocol, relative URLs (like/sha1/...) pass through unchanged becausenew URL(relativePath)throws and the catch block returns the URL as-is.Fix
Rename
dataon<object>andsrcon<embed>to__playwright_data__/__playwright_src__, following the same pattern used for<iframe src>and<iframe srcdoc>since #40676.Origin
The iframe
srcneutralization was introduced by Simon Knott (2024-09-04). It was expanded in #40676 to coversrcdocandsandbox, but<object>and<embed>were not covered.