fix: XML injection via unsafe CDATA serialization (GHSA-wh4c-j3r5-mjhp)#968
Merged
Conversation
…ains ']]>' Backport of the Phase 1a fix to release-0.8.x. Adapts to 0.8.x code style: bare INVALID_CHARACTER_ERR constant and prose @throws JSDoc style. Refs: GHSA-wh4c-j3r5-mjhp
Backport of the Phase 1b fix to release-0.8.x. Uses string literals
('<![CDATA[', ']]>') instead of the g.CDATA_START/END constants from main.
Mutation-vector tests (appendData, replaceData, .data =, .textContent =)
added to test/dom/serializer.test.js.
Refs: GHSA-wh4c-j3r5-mjhp
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.
Fixes GHSA-wh4c-j3r5-mjhp — XML injection via unsafe CDATA serialization.
Fixed
createCDATASectionnow throwsInvalidCharacterErrorwhendatacontains"]]>", as required by the WHATWG DOM spec.GHSA-wh4c-j3r5-mjhpXMLSerializernow splits CDATASection nodes whose data contains"]]>"into adjacent CDATA sections at serialization time, preventing XML injection via mutation methods (appendData,replaceData,.data =,.textContent =).GHSA-wh4c-j3r5-mjhpCode that passes a string containing
"]]>"tocreateCDATASectionand relied on the previously unsafe behavior will now receiveInvalidCharacterError. Use a mutation method such asappendDataif you intentionally need"]]>"in a CDATASection node's data.