fix(Gradient): escape colorStop colors in SVG export (backport GHSA-w22m to 6.x)#11032
Open
greymoth-jp wants to merge 1 commit into
Open
fix(Gradient): escape colorStop colors in SVG export (backport GHSA-w22m to 6.x)#11032greymoth-jp wants to merge 1 commit into
greymoth-jp wants to merge 1 commit into
Conversation
Backport of the v7.4.0 fix for GHSA-w22m-hvvm-xmwx. On 6.x, Gradient.toSVG inlines each colorStop color into the style="stop-color:..." attribute without escaping, so a crafted color can break out of the attribute and inject SVG markup. Normalize values that are not safe SVG style tokens through Color(...).toRgba() and escape the result, matching the active major. Safe values are preserved.
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
Author
|
Closing this since CI is red and I can't verify it properly. I'd rather not leave a broken PR in your queue. Sorry for the noise. |
Member
|
No worries i ll get here. I have just to be sure things work properly. |
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.
The 6.x line is missing the gradient colorStop escaping that shipped on the active major in v7.4.0 for GHSA-w22m-hvvm-xmwx. On 6.9.1,
Gradient.toSVG()inlines each colorStopcolorstraight into thestyle="stop-color:..."attribute with no escaping, so a crafted color breaks out of the attribute and injects arbitrary SVG. This is reachable whenever a gradient comes from untrusted input (e.g.loadFromJSON) and the canvas is later serialized withtoSVG().Repro on 6.9.1:
This backports the v7.4.0 fix: a value that is not a safe SVG style token is normalized through
Color(...).toRgba(), and the result is passed throughescapeXmlfor the attribute context. Becausestyle="stop-color:..."is a CSS declaration, XML-escaping alone is not enough, hence the normalization step. Safe values (currentColor,var(--x),rgb(...), named colors) are left as-is, so existing output is preserved.escapeXmlalready exists on 6.x; the only new file is theisSafeSvgStyleValuehelper, copied from the v7 implementation. Added unit tests covering the HTML, CSS-declaration and url payloads plus the safe-value passthrough.Oracle: GHSA-w22m-hvvm-xmwx, fixed on the active major in v7.4.0.