Bug 156176

Summary: Investigate letting foreignObject not taint the canvas when drawing svg into canvas.
Product: WebKit Reporter: Philip Rogers <pdr>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: aman62, ap, bfulgham, chrishtr, dbates, dino, fred.wang, sabouhallawa, simon.fraser, thorton, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=119492
Bug Depends on:    
Bug Blocks: 91523, 131033    
Attachments:
Description Flags
SVG
none
test case none

Philip Rogers
Reported 2016-04-04 13:18:26 PDT
Out of an abundance of caution [1] webkit currently taints the canvas when an svg image containing a foreign object is drawn into the canvas[2]. The core issue is described in https://bugs.webkit.org/show_bug.cgi?id=119492#c33. Blink also has this behavior and we recently reconsidered it in https://crbug.com/294129#c21, but no progress has been made (I will update this bug if there ever is any). I'd think we should change this, but it's risky and I haven't seen a lot of user interest in it. [1] Getting this wrong has serious issues, see: https://goo.gl/78PwDy [2] http://trac.webkit.org/browser/trunk/Source/WebCore/svg/graphics/SVGImage.cpp?rev=198655#L85
Attachments
SVG (725 bytes, image/svg+xml)
2017-01-05 14:27 PST, Said Abou-Hallawa
no flags
test case (1.32 KB, text/html)
2017-01-05 14:28 PST, Said Abou-Hallawa
no flags
Frédéric Wang (:fredw)
Comment 1 2016-04-05 02:22:48 PDT
Philip Rogers
Comment 2 2016-04-05 11:02:22 PDT
@Frederic, on the webkit-dev thread you asked "Maybe it would be worth checking with them what was their rationale to remove that restriction and if it's worth following the same approach for Blink/WebKit...". I think we could remove this restriction today, but I do not trust our implementation of foreignObject to not leak data. This problem is specific to our implementation. I think a path forward will be to have someone look very closely at <foreignObject> and the data it can leak, and then just flip the switch if it is safe (remove SVGImage::hasSingleSecurityOrigin). For WebKit, I would recommend asking someone on Apple's security team to sign off on this too. I support doing this, but it's risky; I haven't done it myself because there hasn't been enough user interest to justify it.
Philip Rogers
Comment 3 2016-12-20 19:04:38 PST
Simon and Said, I think we're going to go ahead with this change in Blink (https://groups.google.com/a/chromium.org/d/msg/blink-dev/yYVVl5ociqA/b5387_fKDwAJ). I follow SVG commits in both Blink and WebKit and I do not know of any security/privacy differences in this area. Would you support the same change in WebKit? I can post the patch but wanted to check with you first.
Said Abou-Hallawa
Comment 4 2017-01-05 14:26:53 PST
(In reply to comment #3) > Simon and Said, > I think we're going to go ahead with this change in Blink > (https://groups.google.com/a/chromium.org/d/msg/blink-dev/yYVVl5ociqA/ > b5387_fKDwAJ). I follow SVG commits in both Blink and WebKit and I do not > know of any security/privacy differences in this area. Would you support the > same change in WebKit? I can post the patch but wanted to check with you > first. I agree with this change since this will make WebKit compliant with the specs and the other browsers. I did a basic testing and I found out WebKt does not apply any linking style when drawing an SVG to a canvas (see attached test case). But I think the WebKit security team needs to sign off on this as well. Brent, do you agree with this change?
Said Abou-Hallawa
Comment 5 2017-01-05 14:27:19 PST
Said Abou-Hallawa
Comment 6 2017-01-05 14:28:25 PST
Created attachment 298135 [details] test case
Philip Rogers
Comment 7 2017-01-05 14:35:30 PST
Thanks Said! Small update on the blink side: junov is currently writing a few more tests just to be sure®. I'll update this bug (along with a link to the patch with tests) once the full change lands in blink.
Aman Vishnani
Comment 8 2018-02-13 09:55:47 PST
Hi there, Any progress on this bug? I came across this bug while using the dom-to-image library for converting an HTML element into a sharable png image. I was hoping that we could make this work without restrictions since Google Chrome and Firefox already allows it. This issue is similar to https://bugs.webkit.org/show_bug.cgi?id=17352
Radar WebKit Bug Importer
Comment 9 2022-07-18 15:39:00 PDT
Note You need to log in before you can comment on or make changes to this bug.