Out of an abundance of caution  webkit currently taints the canvas when an svg image containing a foreign object is drawn into the canvas. 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.
 Getting this wrong has serious issues, see: https://goo.gl/78PwDy
FWIW, the MDN page: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas
@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.
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.
(In reply to comment #3)
> Simon and Said,
> I think we're going to go ahead with this change in Blink
> 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
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?
Created attachment 298134 [details]
Created attachment 298135 [details]
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.
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